aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dependencies.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2012-03-20 19:43:41 -0700
committerAdam Vandenberg2012-03-20 19:43:41 -0700
commit07736cb8fa372e8479e2cc24a67d1f73ee6030cd (patch)
tree721f02b893a8a4624401d1c41841ac01093dba4e /Library/Homebrew/dependencies.rb
parent54f1837d237b2c1b09d96815bd8a990ac1c951e5 (diff)
downloadbrew-07736cb8fa372e8479e2cc24a67d1f73ee6030cd.tar.bz2
Allow a different package and import name for language deps.
Some times the module to import is different than the module to install when dealing with external dependencies. This change allows an optional import name to be specififed when it is different from the module name. Closes Homebrew/homebrew#11078.
Diffstat (limited to 'Library/Homebrew/dependencies.rb')
-rw-r--r--Library/Homebrew/dependencies.rb29
1 files changed, 15 insertions, 14 deletions
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index 3d92d45e6..06fa4b5d0 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -36,7 +36,7 @@ class DependencyCollector
when Array
@deps << Dependency.new(key, value)
when *LANGUAGE_MODULES
- @external_deps << LanguageModuleDependency.new(key, value)
+ @external_deps << LanguageModuleDependency.new(value, key)
else
# :optional, :recommended, :build, :universal and "32bit" are predefined
@deps << Dependency.new(key, [value])
@@ -92,9 +92,10 @@ end
# A dependency on a language-specific module.
class LanguageModuleDependency < Requirement
- def initialize module_name, type
+ def initialize language, module_name, import_name=nil
+ @language = language
@module_name = module_name
- @type = type
+ @import_name = import_name || module_name
end
def fatal?; true; end
@@ -105,26 +106,26 @@ class LanguageModuleDependency < Requirement
def message; <<-EOS.undent
Unsatisfied dependency: #{@module_name}
- Homebrew does not provide #{@type.to_s.capitalize} dependencies; install with:
+ Homebrew does not provide #{@language.to_s.capitalize} dependencies; install with:
#{command_line} #{@module_name}
EOS
end
def the_test
- case @type
- when :chicken then %W{/usr/bin/env csi -e (use #{@module_name})}
- when :jruby then %W{/usr/bin/env jruby -rubygems -e require\ '#{@module_name}'}
- when :lua then %W{/usr/bin/env luarocks show #{@module_name}}
- when :node then %W{/usr/bin/env node -e require('#{@module_name}');}
- when :perl then %W{/usr/bin/env perl -e use\ #{@module_name}}
- when :python then %W{/usr/bin/env python -c import\ #{@module_name}}
- when :ruby then %W{/usr/bin/env ruby -rubygems -e require\ '#{@module_name}'}
- when :rbx then %W{/usr/bin/env rbx -rubygems -e require\ '#{@module_name}'}
+ case @language
+ when :chicken then %W{/usr/bin/env csi -e (use #{@import_name})}
+ when :jruby then %W{/usr/bin/env jruby -rubygems -e require\ '#{@import_name}'}
+ when :lua then %W{/usr/bin/env luarocks show #{@import_name}}
+ when :node then %W{/usr/bin/env node -e require('#{@import_name}');}
+ when :perl then %W{/usr/bin/env perl -e use\ #{@import_name}}
+ when :python then %W{/usr/bin/env python -c import\ #{@import_name}}
+ when :ruby then %W{/usr/bin/env ruby -rubygems -e require\ '#{@import_name}'}
+ when :rbx then %W{/usr/bin/env rbx -rubygems -e require\ '#{@import_name}'}
end
end
def command_line
- case @type
+ case @language
when :chicken then "chicken-install"
when :jruby then "jruby -S gem install"
when :lua then "luarocks install"