From d157301cdc926cd0e3f9ecdf9d4b25442f470a4f Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 5 Dec 2014 22:11:23 -0500 Subject: Pass the downloader a proxy object instead of the resource We need to limit the interface that is exposed to the downloader in order to make future changes easier. This will be important for work on new features, such as selecting a mirror from the command line. In the future, the existing Resource class will probably be split into multiple classes. --- Library/Homebrew/resource.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 9cbce9acb..f6b417fc5 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -16,6 +16,28 @@ class Resource # formula name before initialization of the formula attr_accessor :name, :owner + class Download + def initialize(resource) + @resource = resource + end + + def url + @resource.url + end + + def specs + @resource.specs + end + + def version + @resource.version + end + + def mirrors + @resource.mirrors + end + end + def initialize name=nil, &block @name = name @url = nil @@ -28,7 +50,7 @@ class Resource end def downloader - @downloader ||= download_strategy.new(download_name, self) + @downloader ||= download_strategy.new(download_name, Download.new(self)) end # Removes /s from resource names; this allows go package names -- cgit v1.2.3