diff options
| author | Jack Nagel | 2013-02-19 10:15:52 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-02-19 10:15:52 -0600 |
| commit | 9561b4bc8e0fee449af60f8957c7ea510e41b561 (patch) | |
| tree | a18ddadaa0229ab1e16d4783568082b07c423436 /Library | |
| parent | 3701081b65cbfd09024b95b0de2e154a3ba7478d (diff) | |
| download | brew-9561b4bc8e0fee449af60f8957c7ea510e41b561.tar.bz2 | |
Fix X11 proxy constant lookup under 1.9+
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/requirements.rb | 30 |
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 |
