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? # XXX: why is "and version" here?
unless ARGV.include? "--no-fetch" and version unless ARGV.include? "--no-fetch" and version
r = Resource.new(:default, url, version) r = Resource.new
r.owner = self r.url, r.version, r.owner = url, version, self
@sha1 = r.fetch.sha1 if r.download_strategy == CurlDownloadStrategy @sha1 = r.fetch.sha1 if r.download_strategy == CurlDownloadStrategy
end end

View File

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

View File

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