Give SoftwareSpec an initializer

Tools like `brew create` need to create and manipulate SoftwareSpec
objects. It is useful to be able to do this directly, rather than by
proxy through the special methods that serve the main formula DSL.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-06-26 12:44:43 -05:00
parent 56fe164e95
commit c235395fd7
2 changed files with 9 additions and 7 deletions

View File

@ -88,10 +88,8 @@ class FormulaCreator
end end
unless ARGV.include? "--no-fetch" and version unless ARGV.include? "--no-fetch" and version
strategy = DownloadStrategyDetector.new(url).detect spec = SoftwareSpec.new(url, version)
spec = SoftwareSpec.new strategy = spec.download_strategy
spec.url(url)
spec.version(version)
@sha1 = strategy.new(name, spec).fetch.sha1 if strategy == CurlDownloadStrategy @sha1 = strategy.new(name, spec).fetch.sha1 if strategy == CurlDownloadStrategy
end end

View File

@ -4,6 +4,11 @@ require 'checksums'
class SoftwareSpec class SoftwareSpec
attr_reader :checksum, :mirrors, :specs attr_reader :checksum, :mirrors, :specs
def initialize url=nil, version=nil
@url = url
@version = version
end
# Was the version defined in the DSL, or detected from the URL? # Was the version defined in the DSL, or detected from the URL?
def explicit_version? def explicit_version?
@explicit_version || false @explicit_version || false
@ -67,9 +72,8 @@ class SoftwareSpec
end end
class HeadSoftwareSpec < SoftwareSpec class HeadSoftwareSpec < SoftwareSpec
def initialize def initialize url=nil, version='HEAD'
super super
@version = 'HEAD'
end end
def verify_download_integrity fn def verify_download_integrity fn
@ -81,7 +85,7 @@ class Bottle < SoftwareSpec
attr_writer :url attr_writer :url
attr_reader :revision attr_reader :revision
def initialize def initialize url=nil, version=nil
super super
@revision = 0 @revision = 0
end end