diff options
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/bottles.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/bottle.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/software_spec.rb | 11 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_bottle_filename.rb | 6 |
4 files changed, 17 insertions, 10 deletions
diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 90c9aba08..f2b5fffe4 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -19,11 +19,6 @@ def bottle_file_outdated? f, file bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext end -def bottle_suffix revision - revision = revision > 0 ? ".#{revision}" : "" - ".bottle#{revision}.tar.gz" -end - def bottle_native_regex /(\.#{bottle_tag}\.bottle\.(\d+\.)?tar\.gz)$/o end diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 8bd1c4b9e..954f6eb78 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -192,10 +192,7 @@ module Homebrew puts output if ARGV.include? '--rb' - bottle_base = filename.to_s.gsub(bottle_suffix(bottle_revision), '') - File.open "#{bottle_base}.bottle.rb", 'w' do |file| - file.write output - end + File.open("#{filename.prefix}.bottle.rb", "w") { |file| file.write(output) } end end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 5382103d4..9a9db69fc 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -124,9 +124,18 @@ class Bottle end def to_s - "#{name}-#{version}.#{tag}#{bottle_suffix(revision)}" + prefix + suffix end alias_method :to_str, :to_s + + def prefix + "#{name}-#{version}.#{tag}" + end + + def suffix + s = revision > 0 ? ".#{revision}" : "" + ".bottle#{s}.tar.gz" + end end extend Forwardable diff --git a/Library/Homebrew/test/test_bottle_filename.rb b/Library/Homebrew/test/test_bottle_filename.rb index 09dc29e5f..cad538be9 100644 --- a/Library/Homebrew/test/test_bottle_filename.rb +++ b/Library/Homebrew/test/test_bottle_filename.rb @@ -6,6 +6,12 @@ class BottleFilenameTests < Homebrew::TestCase Bottle::Filename.new("foo", "1.0", :tag, revision) end + def test_prefix_suffix + assert_equal "foo-1.0.tag", fn(0).prefix + assert_equal ".bottle.tar.gz", fn(0).suffix + assert_equal ".bottle.1.tar.gz", fn(1).suffix + end + def test_to_str expected = "foo-1.0.tag.bottle.tar.gz" assert_equal expected, fn(0).to_s |
