aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2009-09-11 14:22:46 +0100
committerMax Howell2009-09-11 17:42:53 +0100
commitfa598eddfca7ab9a5be07ba8355f73ae8d93955c (patch)
tree1508e5776d65d3765bae310e14c62ca94c174952 /Library
parent1e5611fcc4751e2b6821bf6ff69d4bbfd05bb858 (diff)
downloadhomebrew-fa598eddfca7ab9a5be07ba8355f73ae8d93955c.tar.bz2
Overriding Object.class was not my intention
Renamed to Formula::class_s.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brew.h.rb2
-rw-r--r--Library/Homebrew/formula.rb4
-rwxr-xr-xLibrary/Homebrew/unittest.rb8
3 files changed, 10 insertions, 4 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb
index 8b3939968..60fce7eb8 100644
--- a/Library/Homebrew/brew.h.rb
+++ b/Library/Homebrew/brew.h.rb
@@ -35,7 +35,7 @@ def make url
template=<<-EOS
require 'brewkit'
- class #{Formula.class $1} <Formula
+ class #{Formula.class_s $1} <Formula
@url='#{url}'
@homepage=''
@md5=''
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 7faabbae6..e995f88d1 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -151,14 +151,14 @@ class Formula
"-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None"
end
- def self.class name
+ def self.class_s name
#remove invalid characters and camelcase
name.capitalize.gsub(/[-_\s]([a-zA-Z0-9])/) { $1.upcase }
end
def self.factory name
require self.path(name)
- return eval(self.class(name)).new(name)
+ return eval(self.class_s(name)).new(name)
rescue LoadError
raise FormulaUnavailableError.new(name)
end
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
index 62cc356be..0ef29f4f2 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/unittest.rb
@@ -318,7 +318,7 @@ class BeerTasting <Test::Unit::TestCase
FOOBAR='foo-bar'
def test_formula_funcs
- classname=Formula.class(FOOBAR)
+ classname=Formula.class_s(FOOBAR)
path=Formula.path(FOOBAR)
assert_equal "FooBar", classname
@@ -471,4 +471,10 @@ class BeerTasting <Test::Unit::TestCase
assert_raises(RuntimeError) {Pathname.getwd.install 'non_existant_file'}
end
+
+ def test_formula_class_func
+ assert_equal Formula.class_s('s-lang'), 'SLang'
+ assert_equal Formula.class_s('pkg-config'), 'PkgConfig'
+ assert_equal Formula.class_s('foo_bar'), 'FooBar'
+ end
end