aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-02-19 10:15:52 -0600
committerJack Nagel2013-02-19 10:15:52 -0600
commit594590e5ad52ddcf1736f8fd2863a84d018beb50 (patch)
treec37305bddbebfad756367cf747cf3e304849e417 /Library
parentdb0749b3e3d7a9dfa069814d608489145ed8e6bb (diff)
downloadhomebrew-594590e5ad52ddcf1736f8fd2863a84d018beb50.tar.bz2
Fix X11 proxy constant lookup under 1.9+
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/requirements.rb30
1 files changed, 20 insertions, 10 deletions
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index f2d9dfeb8..34273a0f3 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -109,19 +109,29 @@ class X11Dependency < Requirement
class Proxy < self
PACKAGES = [:libpng, :freetype, :fontconfig]
- def self.for(name, *tags)
- constant = name.capitalize
-
- if const_defined?(constant)
- klass = const_get(constant)
- else
- klass = Class.new(self) do
- def initialize(name, *tags) super end
+ class << self
+ def defines_const?(const)
+ if ::RUBY_VERSION >= "1.9"
+ const_defined?(const, false)
+ else
+ const_defined?(const)
end
+ end
- const_set(constant, klass)
+ def for(name, *tags)
+ constant = name.capitalize
+
+ if defines_const?(constant)
+ klass = const_get(constant)
+ else
+ klass = Class.new(self) do
+ def initialize(name, *tags) super end
+ end
+
+ const_set(constant, klass)
+ end
+ klass.new(name, *tags)
end
- klass.new(name, *tags)
end
end
end