From c235395fd7f58c7f76537d3c603809c61c46d213 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 26 Jun 2012 12:44:43 -0500 Subject: [PATCH] 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 --- Library/Homebrew/cmd/create.rb | 6 ++---- Library/Homebrew/formula_support.rb | 10 +++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb index a1f0cb8cab..03018d4076 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 6440846a08..540d2db71b 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