diff options
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/ARGV+yeast.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/brew.h.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 37 | ||||
| -rwxr-xr-x | Library/Homebrew/unittest.rb | 23 |
4 files changed, 58 insertions, 14 deletions
diff --git a/Library/Homebrew/ARGV+yeast.rb b/Library/Homebrew/ARGV+yeast.rb index f9f50c01a..8825718d4 100644 --- a/Library/Homebrew/ARGV+yeast.rb +++ b/Library/Homebrew/ARGV+yeast.rb @@ -66,6 +66,9 @@ module HomebrewArgvExtension def quieter? flag? '--quieter' end + def interactive? + flag? '--interactive' + end def flag? flag options.each do |arg| diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index f482559f6..d02d44dc1 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -144,6 +144,15 @@ def clean f end +def expand_deps ff + deps = [] + ff.deps.collect do |f| + deps += expand_deps(Formula.factory(f)) + end + deps << ff +end + + def prune $n=0 $d=0 diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index ee9bd36f6..ffb71bb44 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -116,9 +116,7 @@ class Formula # } # The final option is to return DATA, then put a diff after __END__. You # can still return a Hash with DATA as the value for a patch level key. - def patches; end - # reimplement and specify dependencies - def deps; end + def patches; [] end # sometimes the clean process breaks things, return true to skip anything def skip_clean? path; false end # rarely, you don't want your library symlinked into the main prefix @@ -129,7 +127,7 @@ class Formula def brew validate_variable :name validate_variable :version - + stage do begin patch @@ -165,6 +163,7 @@ class Formula end def self.factory name + return name if name.kind_of? Formula path = Pathname.new(name) if path.absolute? require name @@ -181,6 +180,10 @@ class Formula HOMEBREW_PREFIX+'Library'+'Formula'+"#{name.downcase}.rb" end + def deps + self.class.deps or [] + end + protected # Pretty titles the command and buffers stdout/stderr # Throws if there's an error @@ -327,9 +330,31 @@ private end class <<self - attr_reader :url, :version, :homepage, :head + attr_reader :url, :version, :homepage, :head, :deps attr_reader *CHECKSUM_TYPES - end + + def depends_on name, *args + @deps ||= [] + + case name + when String + # noop + when Hash + name = name.keys.first # indeed, we only support one mapping + when Symbol + name = name.to_s + when Formula + @deps << name + return # we trust formula dev to not dupe their own instantiations + else + raise "Unsupported type #{name.class}" + end + + # we get duplicates because every new fork of this process repeats this + # step for some reason I am not sure about + @deps << name unless @deps.include? name + end + end end # see ack.rb for an example usage diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb index 0b2d7df7f..15336ebde 100755 --- a/Library/Homebrew/unittest.rb +++ b/Library/Homebrew/unittest.rb @@ -42,7 +42,8 @@ class MostlyAbstractFormula <Formula end class TestBall <Formula - def initialize + # name parameter required for some Formula::factory + def initialize name=nil @url="file:///#{Pathname.new(ABS__FILE__).parent.realpath}/testball-0.1.tbz" super "testball" end @@ -123,9 +124,13 @@ def nostdout end module ExtendArgvPlusYeast - def stick_an_arg_in_thar + def reset @named=nil - unshift 'foo' + @formulae=nil + @kegs=nil + while ARGV.count > 0 + ARGV.shift + end end end ARGV.extend ExtendArgvPlusYeast @@ -372,8 +377,9 @@ class BeerTasting <Test::Unit::TestCase end def test_no_ARGV_dupes - ARGV.unshift'foo' - ARGV.unshift'foo' + ARGV.reset + ARGV.unshift 'foo' + ARGV.unshift 'foo' n=0 ARGV.named.each{|arg| n+=1 if arg == 'foo'} assert_equal 1, n @@ -385,9 +391,10 @@ class BeerTasting <Test::Unit::TestCase assert_raises(UsageError) { ARGV.kegs } assert ARGV.named_empty? - (HOMEBREW_CELLAR+'foo'+'0.1').mkpath + (HOMEBREW_CELLAR+'mxcl'+'10.0').mkpath - ARGV.stick_an_arg_in_thar + ARGV.reset + ARGV.unshift 'mxcl' assert_equal 1, ARGV.named.length assert_equal 1, ARGV.kegs.length assert_raises(FormulaUnavailableError) { ARGV.formulae } @@ -425,7 +432,7 @@ class BeerTasting <Test::Unit::TestCase nostdout do assert_nothing_raised do f=TestBall.new - make 'http://example.com/testball-0.1.tbz' + make f.url info f.name clean f prune |
