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:
parent
56fe164e95
commit
c235395fd7
@ -88,10 +88,8 @@ class FormulaCreator
|
||||
end
|
||||
|
||||
unless ARGV.include? "--no-fetch" and version
|
||||
strategy = DownloadStrategyDetector.new(url).detect
|
||||
spec = SoftwareSpec.new
|
||||
spec.url(url)
|
||||
spec.version(version)
|
||||
spec = SoftwareSpec.new(url, version)
|
||||
strategy = spec.download_strategy
|
||||
@sha1 = strategy.new(name, spec).fetch.sha1 if strategy == CurlDownloadStrategy
|
||||
end
|
||||
|
||||
|
||||
@ -4,6 +4,11 @@ require 'checksums'
|
||||
class SoftwareSpec
|
||||
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?
|
||||
def explicit_version?
|
||||
@explicit_version || false
|
||||
@ -67,9 +72,8 @@ class SoftwareSpec
|
||||
end
|
||||
|
||||
class HeadSoftwareSpec < SoftwareSpec
|
||||
def initialize
|
||||
def initialize url=nil, version='HEAD'
|
||||
super
|
||||
@version = 'HEAD'
|
||||
end
|
||||
|
||||
def verify_download_integrity fn
|
||||
@ -81,7 +85,7 @@ class Bottle < SoftwareSpec
|
||||
attr_writer :url
|
||||
attr_reader :revision
|
||||
|
||||
def initialize
|
||||
def initialize url=nil, version=nil
|
||||
super
|
||||
@revision = 0
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user