Proposed changes
This commit is contained in:
parent
f5a0ae176a
commit
b4a2fe502c
@ -8,10 +8,10 @@ class RubyRequirement < Requirement
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
satisfy(build_env: false) { suitable_ruby }
|
satisfy(build_env: false) { new_enough_ruby }
|
||||||
|
|
||||||
env do
|
env do
|
||||||
ENV.prepend_path "PATH", suitable_ruby
|
ENV.prepend_path "PATH", new_enough_ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
def message
|
def message
|
||||||
@ -34,19 +34,20 @@ class RubyRequirement < Requirement
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def suitable_ruby
|
def new_enough_ruby
|
||||||
rubies.detect { |ruby| suitable?(ruby) }
|
rubies.detect { |ruby| new_enough?(ruby) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def rubies
|
def rubies
|
||||||
rubies = which_all("ruby")
|
rubies = which_all("ruby")
|
||||||
|
ruby_formula = Formula["ruby"]
|
||||||
if ruby_formula && ruby_formula.installed?
|
if ruby_formula && ruby_formula.installed?
|
||||||
rubies.unshift Pathname.new(ruby_formula.bin/"ruby")
|
rubies.unshift ruby_formula.bin/"ruby"
|
||||||
end
|
end
|
||||||
rubies.uniq
|
rubies.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def suitable?(ruby)
|
def new_enough?(ruby)
|
||||||
version = Utils.popen_read(ruby, "-e", "print RUBY_VERSION").strip
|
version = Utils.popen_read(ruby, "-e", "print RUBY_VERSION").strip
|
||||||
version =~ /^\d+\.\d+/ && Version.create(version) >= min_version
|
version =~ /^\d+\.\d+/ && Version.create(version) >= min_version
|
||||||
end
|
end
|
||||||
@ -54,11 +55,4 @@ class RubyRequirement < Requirement
|
|||||||
def min_version
|
def min_version
|
||||||
@min_version ||= Version.create(@version)
|
@min_version ||= Version.create(@version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ruby_formula
|
|
||||||
@ruby_formula ||= Formula["ruby"]
|
|
||||||
rescue FormulaUnavailableError
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user