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.
This commit is contained in:
		
							parent
							
								
									853399da44
								
							
						
					
					
						commit
						d157301cdc
					
				@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user