Sha256: d40be9fdbb3f109a038e25e5467178d3c248e091dfff28c06b5ff16bde45f6cc
Contents?: true
Size: 978 Bytes
Versions: 5
Compression:
Stored size: 978 Bytes
Contents
module GhostAdapter class IncompatibleVersion < StandardError def initialize(version = nil) message = %( #{version.nil? ? 'gh-ost not installed' : "gh-ost incompatible version #{version} installed."} please install version: [#{VersionChecker::ALLOWED_RANGE}] for latest release, visit: https://github.com/github/gh-ost/releases/latest) super(message) end end class VersionChecker ALLOWED_RANGE = Gem::Requirement.new('>= 1.1.0', '< 2') class << self def validate_executable! found_version = fetch_version raise IncompatibleVersion, found_version unless ALLOWED_RANGE.satisfied_by? found_version end private def fetch_version stdout, status = Open3.capture2('gh-ost', '--version') raise IncompatibleVersion unless status.success? begin Gem::Version.new(stdout) rescue ArgumentError raise IncompatibleVersion end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems