aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2012-06-26 12:44:43 -0500
committerJack Nagel2012-07-04 22:47:35 -0500
commitc235395fd7f58c7f76537d3c603809c61c46d213 (patch)
treebfa94f9564f2c71eecb7615befb6c54d43246d3b /Library
parent56fe164e952e888496bc81495cfc0f66338d50d5 (diff)
downloadbrew-c235395fd7f58c7f76537d3c603809c61c46d213.tar.bz2
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>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/create.rb6
-rw-r--r--Library/Homebrew/formula_support.rb10
2 files changed, 9 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb
index a1f0cb8ca..03018d407 100644
--- a/Library/Homebrew/cmd/create.rb
+++ b/Library/Homebrew/cmd/create.rb
@@ -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
diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb
index 6440846a0..540d2db71 100644
--- a/Library/Homebrew/formula_support.rb
+++ b/Library/Homebrew/formula_support.rb
@@ -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