summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/contents_command.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
commitd22130922e7842226d38d59680e4bbb48a28a5f0 (patch)
tree39594d3a14641dd5488a99a5e633239296fa5742 /lib/rubygems/commands/contents_command.rb
parent4752539e3f3e563d559732c52424206bd6f12dbd (diff)
Import rubygems 1.8.5 (released @ 137c80f)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/contents_command.rb')
-rw-r--r--lib/rubygems/commands/contents_command.rb31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 42ae913b01..8e015ae9da 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -58,24 +58,24 @@ class Gem::Commands::ContentsCommand < Gem::Command
end.flatten
path_kind = if spec_dirs.empty? then
- spec_dirs = Gem::SourceIndex.installed_spec_directories
+ spec_dirs = Gem::Specification.dirs
"default gem paths"
else
"specified path"
end
- si = Gem::SourceIndex.from_gems_in(*spec_dirs)
-
gem_names = if options[:all] then
- si.map { |_, spec| spec.name }
+ Gem::Specification.map(&:name)
else
get_all_gem_names
end
gem_names.each do |name|
- gem_spec = si.find_name(name, version).last
+ # HACK: find_by_name fails for some reason... ARGH
+ # How many places must we embed our resolve logic?
+ spec = Gem::Specification.find_all_by_name(name, version).last
- unless gem_spec then
+ unless spec then
say "Unable to find gem '#{name}' in #{path_kind}"
if Gem.configuration.verbose then
@@ -86,16 +86,19 @@ class Gem::Commands::ContentsCommand < Gem::Command
terminate_interaction 1 if gem_names.length == 1
end
- files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
+ gem_path = spec.full_gem_path
+ extra = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
+ glob = "#{gem_path}#{extra}/**/*"
+ files = Dir[glob]
+
+ gem_path = File.join gem_path, '' # add trailing / if missing
+
+ files.sort.each do |file|
+ next if File.directory? file
- files.each do |f|
- path = if options[:prefix] then
- File.join gem_spec.full_gem_path, f
- else
- f
- end
+ file = file.sub gem_path, '' unless options[:prefix]
- say path
+ say file
end
end
end