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