diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 9ea88cae70..29791f03f6 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -14,8 +14,8 @@ class AbstractDownloadStrategy end end - attr_reader :meta, :name, :version - attr_reader :shutup + attr_reader :meta, :name, :version, :shutup + private :meta, :name, :version, :shutup def initialize(url, name, version, **meta) @url = url @@ -52,8 +52,22 @@ class AbstractDownloadStrategy .extract_nestedly(basename: basename_without_params, extension_only: true, verbose: ARGV.verbose? && !shutup) + chdir end + def chdir + entries = Dir["*"] + case entries.length + when 0 then raise "Empty archive" + when 1 then begin + Dir.chdir entries.first + rescue + nil + end + end + end + private :chdir + # @!attribute [r] cached_location # The path to the cached file or directory associated with the resource. def cached_location; end @@ -180,18 +194,6 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy private - def chdir - entries = Dir["*"] - case entries.length - when 0 then raise "Empty archive" - when 1 then begin - Dir.chdir entries.first - rescue - nil - end - end - end - def ext # We need a Pathname because we've monkeypatched extname to support double # extensions (e.g. tar.gz).