diff options
Diffstat (limited to 'Library/Homebrew/formula.rb')
| -rw-r--r-- | Library/Homebrew/formula.rb | 37 |
1 files changed, 31 insertions, 6 deletions
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 |
