diff options
| author | Jack Nagel | 2013-03-18 14:59:10 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-03-18 15:10:36 -0500 |
| commit | c8168d8a4a73ae1cbf473064b532854a93e6c082 (patch) | |
| tree | 604f03350ec84da048c5b49465d65e4581c1d496 /Library | |
| parent | 456386c9b1cbe599bcc42c96099321ea13afc544 (diff) | |
| download | brew-c8168d8a4a73ae1cbf473064b532854a93e6c082.tar.bz2 | |
Simplify SoftwareSpec checksum methods
Reader methods for specific checksum types have been absent from the
Formula class for some time, so there isn't any reason to expose them in
SoftwareSpec, either.
Thus, these methods now only act as setters, and #checksum should be
used to access the constructed Checksum object.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/compat/compatibility.rb | 17 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/formula_support.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 4 |
4 files changed, 11 insertions, 31 deletions
diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb index 51969330f..aee5da63f 100644 --- a/Library/Homebrew/compat/compatibility.rb +++ b/Library/Homebrew/compat/compatibility.rb @@ -202,22 +202,15 @@ end # MD5 support class Formula - def self.md5(val=nil) - unless val.nil? - @stable ||= SoftwareSpec.new - @stable.md5(val) - end - return @stable ? @stable.md5 : @md5 + def self.md5(val) + @stable ||= SoftwareSpec.new + @stable.md5(val) end end class SoftwareSpec - def md5(val=nil) - if val.nil? - @checksum if checksum.nil? or @checksum.hash_type == :md5 - else - @checksum = Checksum.new(:md5, val) - end + def md5(val) + @checksum = Checksum.new(:md5, val) end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 77b1fabdb..490b517a6 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -677,12 +677,9 @@ private Checksum::TYPES.each do |cksum| class_eval <<-EOS, __FILE__, __LINE__ + 1 - def #{cksum}(val=nil) - unless val.nil? - @stable ||= SoftwareSpec.new - @stable.#{cksum}(val) - end - return @stable ? @stable.#{cksum} : @#{cksum} + def #{cksum}(val) + @stable ||= SoftwareSpec.new + @stable.#{cksum}(val) end EOS end diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 4c044c53a..40bb561b8 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -33,12 +33,8 @@ class SoftwareSpec # The methods that follow are used in the block-form DSL spec methods Checksum::TYPES.each do |cksum| class_eval <<-EOS, __FILE__, __LINE__ + 1 - def #{cksum}(val=nil) - if val.nil? - @checksum if @checksum.nil? or @checksum.hash_type == :#{cksum} - else - @checksum = Checksum.new(:#{cksum}, val) - end + def #{cksum}(val) + @checksum = Checksum.new(:#{cksum}, val) end EOS end @@ -94,11 +90,9 @@ class Bottle < SoftwareSpec # a Hash, which indicates the platform the checksum applies on. Checksum::TYPES.each do |cksum| class_eval <<-EOS, __FILE__, __LINE__ + 1 - def #{cksum}(val=nil) + def #{cksum}(val) @#{cksum} ||= Hash.new case val - when nil - @#{cksum}[MacOS.cat] when Hash key, value = val.shift @#{cksum}[value] = Checksum.new(:#{cksum}, key) diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 554a189fb..bcd00a99b 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -111,10 +111,6 @@ class FormulaTests < Test::Unit::TestCase assert_match /[0-9a-fA-F]{40}/, f.stable.checksum.hexdigest assert_match /[0-9a-fA-F]{64}/, f.devel.checksum.hexdigest - assert_nil f.stable.sha256 - assert_nil f.bottle.sha256 - assert_nil f.devel.sha1 - assert_equal 1, f.stable.mirrors.length assert f.bottle.mirrors.empty? assert_equal 1, f.devel.mirrors.length |
