Sha256: c0c753b3e0aba79ad7393b230d56f02603113e9714f8dff6cfed9ece37f6ae4d
Contents?: true
Size: 995 Bytes
Versions: 12
Compression:
Stored size: 995 Bytes
Contents
require 'open3' 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
12 entries across 12 versions & 1 rubygems