diff options
| author | Jack Nagel | 2014-08-01 20:15:57 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-08-01 20:15:57 -0500 |
| commit | 525e5f791f992556b9ffbe0b0f4b61c44a94d3b6 (patch) | |
| tree | d7e4efdad50176d93a38c7e3c7fcf36084a98f4a /Library | |
| parent | 426737eb9eb1effdf144d9eeed8cde8b5a7d34db (diff) | |
| download | brew-525e5f791f992556b9ffbe0b0f4b61c44a94d3b6.tar.bz2 | |
Remove knowledge of DSL implementation from initialize
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/compilers.rb | 27 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 4 |
2 files changed, 19 insertions, 12 deletions
diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index eb861f38a..6f329d380 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -49,20 +49,27 @@ class CompilerFailure end end - def initialize compiler, &block - instance_eval(&block) if block_given? + def self.create(spec, &block) # Non-Apple compilers are in the format fails_with compiler => version - if compiler.is_a? Hash - # currently the only compiler for this case is GCC - _, @major_version = compiler.first - @compiler = 'gcc-' + @major_version + if spec.is_a?(Hash) + _, major_version = spec.first + compiler = "gcc-#{major_version}" # so fails_with :gcc => '4.8' simply marks all 4.8 releases incompatible - @version ||= @major_version + '.999' + version = "#{major_version}.999" else - @compiler = compiler - @version ||= 9999 - @version = @version.to_i + compiler = spec + version = 9999 + major_version = nil end + + new(compiler, version, major_version, &block) + end + + def initialize(compiler, version, major_version, &block) + @compiler = compiler + @version = version + @major_version = major_version + instance_eval(&block) if block_given? end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 6907406b5..fcad7ed54 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -745,9 +745,9 @@ class Formula # fails_with :gcc => '4.8' do # version '4.8.1' # end - def fails_with compiler, &block + def fails_with spec, &block @cc_failures ||= Set.new - @cc_failures << CompilerFailure.new(compiler, &block) + @cc_failures << CompilerFailure.create(spec, &block) end def needs *standards |
