aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2009-11-16 13:24:41 -0800
committerAdam Vandenberg2009-11-19 14:03:07 -0800
commited4992f467e0c3b8b84959d279e2be9d8be25ab1 (patch)
tree15498ec7177579d8e309f4aea6585aa810e35e5b /Library
parent59a686e3c2d1885c9f3880a41dee7f7c25163f5c (diff)
downloadbrew-ed4992f467e0c3b8b84959d279e2be9d8be25ab1.tar.bz2
Add a Formulary class for managing the Formulae
These methods could be static on Formula, but splitting them out makes it clear to formular authors that these functions don't have anything to do with writing new formulas.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 5d3564476..247d67824 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -33,6 +33,28 @@ class FormulaUnavailableError <RuntimeError
end
+# The Formulary is the collection of all Formulae, of course.
+class Formulary
+ # Returns all formula names as strings, with or without aliases
+ def self.names with_aliases=false
+ everything = (HOMEBREW_REPOSITORY+'Library/Formula').children.map{|f| f.basename('.rb').to_s }
+ everything.push *Formulary.get_aliases.keys if with_aliases
+ everything.sort
+ end
+
+ # Loads all formula classes.
+ def self.read_all
+ Formulary.names.each do |name|
+ require Formula.path(name)
+ klass_name = Formula.class_s(name)
+ klass = eval(klass_name)
+
+ yield name, klass
+ end
+ end
+end
+
+
# Derive and define at least @url, see Library/Formula for examples
class Formula
# Homebrew determines the name