diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:39:21 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:39:21 +0000 |
commit | e76eb06feb024828034379797129d92522e28516 (patch) | |
tree | 1326c625c233ba2554043203a7697f5e3d4c49e5 /ruby_1_9_3/lib/rubygems/commands/which_command.rb | |
parent | aa6e98139c8e1ea442fb2182341aaa08ff55b529 (diff) | |
parent | bede15ac5e701ed08f3fc64c2dba03d3f393c652 (diff) |
add tag v1_9_3_426v1_9_3_426
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_3_426@40737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_9_3/lib/rubygems/commands/which_command.rb')
-rw-r--r-- | ruby_1_9_3/lib/rubygems/commands/which_command.rb | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/ruby_1_9_3/lib/rubygems/commands/which_command.rb b/ruby_1_9_3/lib/rubygems/commands/which_command.rb deleted file mode 100644 index 6495278a87..0000000000 --- a/ruby_1_9_3/lib/rubygems/commands/which_command.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'rubygems/command' - -class Gem::Commands::WhichCommand < Gem::Command - def initialize - super 'which', 'Find the location of a library file you can require', - :search_gems_first => false, :show_all => false - - add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options| - options[:show_all] = show_all - end - - add_option '-g', '--[no-]gems-first', - 'search gems before non-gems' do |gems_first, options| - options[:search_gems_first] = gems_first - end - end - - def arguments # :nodoc: - "FILE name of file to find" - end - - def defaults_str # :nodoc: - "--no-gems-first --no-all" - end - - def execute - found = false - - options[:args].each do |arg| - arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, '') - dirs = $LOAD_PATH - - spec = Gem::Specification.find_by_path arg - - if spec then - if options[:search_gems_first] then - dirs = gem_paths(spec) + $LOAD_PATH - else - dirs = $LOAD_PATH + gem_paths(spec) - end - end - - # TODO: this is totally redundant and stupid - paths = find_paths arg, dirs - - if paths.empty? then - alert_error "Can't find ruby library file or shared library #{arg}" - else - say paths - found = true - end - end - - terminate_interaction 1 unless found - end - - def find_paths(package_name, dirs) - result = [] - - dirs.each do |dir| - Gem.suffixes.each do |ext| - full_path = File.join dir, "#{package_name}#{ext}" - if File.exist? full_path and not File.directory? full_path then - result << full_path - return result unless options[:show_all] - end - end - end - - result - end - - def gem_paths(spec) - spec.require_paths.collect { |d| File.join spec.full_gem_path, d } - end - - def usage # :nodoc: - "#{program_name} FILE [FILE ...]" - end - -end - |