lib/kapost/bootstrapper.rb in kapost-bootstrapper-1.0.3 vs lib/kapost/bootstrapper.rb in kapost-bootstrapper-1.0.4
- old
+ new
@@ -89,21 +89,32 @@
_, status = cli.capture2e "bash -c 'type #{command}'"
status.success?
end
def right_version?(command, expected_version)
- version, status = cli.capture2e "#{command} --version"
- if expected_version[0] == '^'
+ version, status = get_version(command)
+ if expected_version[0] == "^"
next_major = (expected_version[1].to_i + 1).to_s
Gem::Version.new(version) >= Gem::Version.new(expected_version[1..-1]) && Gem::Version.new(version) < Gem::Version.new(next_major)
elsif expected_version[0] == "="
Gem::Version.new(version) == Gem::Version.new(expected_version[1..-1])
else
local_version = Semantic::Version.new(version)
local_version.satisfies?(expected_version)
end
end
+ def get_version(command)
+ version, status = cli.capture2e "#{command} --version"
+ if version[0] == "v"
+ version = version[1..-1]
+ elsif version.include?("ruby")
+ version.slice! "ruby "
+ version = version[0..4]
+ else
+ version
+ end
+ end
def say(message)
if block_given?
# If we're given a block print a label with a success indicator
printer.print message.to_s