Merge pull request #3548 from sjackman/x11

X11Requirement: Inherit from generic class [macOS]
This commit is contained in:
ilovezfs 2017-12-08 13:35:17 -08:00 committed by GitHub
commit e57da601d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 26 deletions

View File

@ -1,21 +1,9 @@
require "requirement"
class XQuartzRequirement < Requirement
include Comparable
fatal true
class X11Requirement < Requirement
cask "xquartz"
download "https://xquartz.macosforge.org"
env { ENV.x11 }
def initialize(name = "x11", tags = [])
@name = name
# no-op on version specified as a tag argument
tags.shift if /(\d\.)+\d/ =~ tags.first
super(tags)
end
def min_version
MacOS::XQuartz.minimum_version
end
@ -28,15 +16,4 @@ class XQuartzRequirement < Requirement
def message
"XQuartz #{min_version} (or newer) is required to install this formula. #{super}"
end
def <=>(other)
return unless other.is_a? X11Requirement
0
end
def inspect
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
end
end
X11Requirement = XQuartzRequirement

View File

@ -170,8 +170,10 @@ class Requirement
attr_rw :fatal, :default_formula
attr_rw :cask, :download
def satisfy(options = {}, &block)
@satisfied ||= Requirement::Satisfier.new(options, &block)
def satisfy(options = nil, &block)
return @satisfied if options.nil? && !block_given?
options = {} if options.nil?
@satisfied = Requirement::Satisfier.new(options, &block)
end
def env(*settings, &block)