2015-04-11 19:18:40 +01:00
|
|
|
class RubyRequirement < Requirement
|
|
|
|
fatal true
|
2015-04-27 14:06:43 +01:00
|
|
|
default_formula "ruby"
|
2015-04-11 19:18:40 +01:00
|
|
|
|
|
|
|
def initialize(tags)
|
2016-09-11 17:42:44 +01:00
|
|
|
@version = tags.shift if /(\d\.)+\d/ =~ tags.first
|
2015-04-11 19:18:40 +01:00
|
|
|
raise "RubyRequirement requires a version!" unless @version
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2016-09-17 15:32:44 +01:00
|
|
|
satisfy build_env: false do
|
2016-01-02 23:21:58 +08:00
|
|
|
which_all("ruby").detect do |ruby|
|
|
|
|
version = /\d\.\d/.match Utils.popen_read(ruby, "--version")
|
|
|
|
next unless version
|
2016-07-11 16:09:35 +03:00
|
|
|
Version.create(version.to_s) >= Version.create(@version)
|
2016-01-02 23:21:58 +08:00
|
|
|
end
|
2015-04-11 19:18:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
2015-05-08 14:41:19 +08:00
|
|
|
s = "Ruby #{@version} is required to install this formula."
|
2015-04-11 19:18:40 +01:00
|
|
|
s += super
|
|
|
|
s
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
"#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>"
|
|
|
|
end
|
|
|
|
end
|