Clean up SoftwareSpec and Resource initializers

This commit is contained in:
Jack Nagel 2013-09-23 21:39:19 -05:00
parent 567f3448c9
commit c464c7549f
3 changed files with 12 additions and 12 deletions

View File

@ -104,8 +104,8 @@ class FormulaCreator
# XXX: why is "and version" here?
unless ARGV.include? "--no-fetch" and version
r = Resource.new(:default, url, version)
r.owner = self
r = Resource.new
r.url, r.version, r.owner = url, version, self
@sha1 = r.fetch.sha1 if r.download_strategy == CurlDownloadStrategy
end

View File

@ -10,18 +10,16 @@ class Resource
attr_reader :name
attr_reader :checksum, :mirrors, :specs, :using
attr_writer :url, :checksum, :version
# Formula name must be set after the DSL, as we have no access to the
# formula name before initialization of the formula
attr_accessor :owner
# XXX: for bottles, address this later
attr_writer :url, :checksum
def initialize name, url=nil, version=nil, &block
def initialize name=nil, &block
@name = name
@url = url
@version = version
@url = nil
@version = nil
@mirrors = []
@specs = {}
@checksum = nil
@ -34,7 +32,7 @@ class Resource
end
def download_name
name == :default ? owner.name : "#{owner.name}--#{name}"
name.nil? ? owner.name : "#{owner.name}--#{name}"
end
def download_strategy

View File

@ -17,8 +17,8 @@ class SoftwareSpec
def_delegators :@resource, :checksum, :mirrors, :specs, :using, :downloader
def_delegators :@resource, :url, :version, :mirror, *Checksum::TYPES
def initialize url=nil, version=nil
@resource = Resource.new(:default, url, version)
def initialize
@resource = Resource.new
@resources = {}
@build = BuildOptions.new(ARGV.options_only)
@dependency_collector = DependencyCollector.new
@ -65,8 +65,10 @@ class SoftwareSpec
end
class HeadSoftwareSpec < SoftwareSpec
def initialize url=nil, version=Version.new(:HEAD)
def initialize
super
@resource.url = url
@resource.version = Version.new('HEAD')
end
def verify_download_integrity fn