Reorganize resource download methods

This commit is contained in:
Jack Nagel 2013-09-17 21:25:40 -05:00
parent 978f0887cb
commit e3a3a0c320

View File

@ -30,10 +30,21 @@ class Resource
end end
def downloader def downloader
download_name = name == :default ? owner.name : "#{owner.name}--#{name}"
@downloader ||= download_strategy.new(download_name, self) @downloader ||= download_strategy.new(download_name, self)
end end
def download_name
name == :default ? owner.name : "#{owner.name}--#{name}"
end
def download_strategy
@download_strategy ||= DownloadStrategyDetector.detect(url, using)
end
def cached_download
downloader.cached_location
end
# Download the resource # Download the resource
# If a target is given, unpack there; else unpack to a temp folder # If a target is given, unpack there; else unpack to a temp folder
# If block is given, yield to that block # If block is given, yield to that block
@ -51,14 +62,6 @@ class Resource
end end
end end
def download_strategy
@download_strategy ||= DownloadStrategyDetector.detect(url, using)
end
def cached_download
downloader.cached_location
end
# For brew-fetch and others. # For brew-fetch and others.
def fetch def fetch
# Ensure the cache exists # Ensure the cache exists