From 197dbe56011a656784e4c1dae734fabc3a3d512f Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 16 Jul 2014 18:12:27 -0500 Subject: [PATCH] Remove dead code Formula objects are always constructed with an explicit name, so we no longer need to special case an empty name or the name "__UNKNOWN__". --- Library/Homebrew/download_strategy.rb | 13 ++----------- Library/Homebrew/test/test_download_strategies.rb | 10 ---------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 83317af043..0a025da1b1 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -1,5 +1,4 @@ require 'utils/json' -require 'erb' class AbstractDownloadStrategy attr_reader :name, :resource @@ -53,11 +52,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy end def cache_filename(tag=cache_tag) - if name.empty? || name == '__UNKNOWN__' - "#{ERB::Util.url_encode(@url)}--#{tag}" - else - "#{name}--#{tag}" - end + "#{name}--#{tag}" end def cache_tag @@ -79,11 +74,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy end def tarball_path - @tarball_path ||= if name.empty? || name == '__UNKNOWN__' - Pathname.new("#{HOMEBREW_CACHE}/#{basename_without_params}") - else - Pathname.new("#{HOMEBREW_CACHE}/#{name}-#{resource.version}#{ext}") - end + @tarball_path ||= Pathname.new("#{HOMEBREW_CACHE}/#{name}-#{resource.version}#{ext}") end def temporary_path diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb index 16ee283699..b228c563a7 100644 --- a/Library/Homebrew/test/test_download_strategies.rb +++ b/Library/Homebrew/test/test_download_strategies.rb @@ -50,16 +50,6 @@ class VCSDownloadStrategyTests < Homebrew::TestCase downloader = @strategy.new("baz", @resource) assert_equal "baz--foo", downloader.cache_filename("foo") end - - def test_empty_name - downloader = @strategy.new("", @resource) - assert_equal escaped("foo"), downloader.cache_filename("foo") - end - - def test_unknown_name - downloader = @strategy.new("__UNKNOWN__", @resource) - assert_equal escaped("foo"), downloader.cache_filename("foo") - end end class DownloadStrategyDetectorTests < Homebrew::TestCase