diff options
Diffstat (limited to 'lib/rubygems/commands/contents_command.rb')
-rw-r--r-- | lib/rubygems/commands/contents_command.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 603f1d072a..15657f31a2 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -8,7 +8,8 @@ class Gem::Commands::ContentsCommand < Gem::Command def initialize super 'contents', 'Display the contents of the installed gems', - :specdirs => [], :lib_only => false, :prefix => true + :specdirs => [], :lib_only => false, :prefix => true, + :show_install_dir => false add_version_option @@ -32,6 +33,11 @@ class Gem::Commands::ContentsCommand < Gem::Command options[:prefix] = prefix end + add_option( '--[no-]show-install-dir', + 'Show only the gem install dir') do |show, options| + options[:show_install_dir] = show + end + @path_kind = nil @spec_dirs = nil @version = nil @@ -65,7 +71,12 @@ prefix or only the files that are requireable. names = gem_names names.each do |name| - found = gem_contents name + found = + if options[:show_install_dir] then + gem_install_dir name + else + gem_contents name + end terminate_interaction 1 unless found or names.length > 1 end @@ -115,6 +126,16 @@ prefix or only the files that are requireable. true end + def gem_install_dir name + spec = spec_for name + + return false unless spec + + say spec.gem_dir + + true + end + def gem_names # :nodoc: if options[:all] then Gem::Specification.map(&:name) |