Provide version reader method

This commit is contained in:
Jack Nagel 2014-12-10 00:53:57 -05:00
parent 0909b12eb9
commit 5201411a6d
2 changed files with 5 additions and 4 deletions

View File

@ -3,12 +3,13 @@ require 'utils/json'
class AbstractDownloadStrategy class AbstractDownloadStrategy
include FileUtils include FileUtils
attr_reader :meta, :name, :resource attr_reader :meta, :name, :version, :resource
def initialize name, resource def initialize name, resource
@name = name @name = name
@resource = resource @resource = resource
@url = resource.url @url = resource.url
@version = resource.version
@meta = resource.specs @meta = resource.specs
end end
@ -120,7 +121,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
end end
def head? def head?
resource.version.head? version.head?
end end
private private
@ -155,7 +156,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
def initialize(name, resource) def initialize(name, resource)
super super
@mirrors = resource.mirrors.dup @mirrors = resource.mirrors.dup
@tarball_path = HOMEBREW_CACHE.join("#{name}-#{resource.version}#{ext}") @tarball_path = HOMEBREW_CACHE.join("#{name}-#{version}#{ext}")
@temporary_path = Pathname.new("#{cached_location}.incomplete") @temporary_path = Pathname.new("#{cached_location}.incomplete")
end end

View File

@ -2,7 +2,7 @@ require 'testing_env'
require 'download_strategy' require 'download_strategy'
class ResourceDouble class ResourceDouble
attr_reader :url, :specs attr_reader :url, :specs, :version
def initialize(url="http://example.com/foo.tar.gz", specs={}) def initialize(url="http://example.com/foo.tar.gz", specs={})
@url = url @url = url