~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/rubygems/commands/contents_command.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    end.flatten
53
53
 
54
54
    path_kind = if spec_dirs.empty? then
55
 
                  spec_dirs = Gem::SourceIndex.installed_spec_directories
 
55
                  spec_dirs = Gem::Specification.dirs
56
56
                  "default gem paths"
57
57
                else
58
58
                  "specified path"
59
59
                end
60
60
 
61
 
    si = Gem::SourceIndex.from_gems_in(*spec_dirs)
62
 
 
63
61
    gem_names = if options[:all] then
64
 
                  si.map { |_, spec| spec.name }
 
62
                  Gem::Specification.map(&:name)
65
63
                else
66
64
                  get_all_gem_names
67
65
                end
68
66
 
69
67
    gem_names.each do |name|
70
 
      gem_spec = si.find_name(name, version).last
 
68
      # HACK: find_by_name fails for some reason... ARGH
 
69
      # How many places must we embed our resolve logic?
 
70
      spec = Gem::Specification.find_all_by_name(name, version).last
71
71
 
72
 
      unless gem_spec then
 
72
      unless spec then
73
73
        say "Unable to find gem '#{name}' in #{path_kind}"
74
74
 
75
75
        if Gem.configuration.verbose then
80
80
        terminate_interaction 1 if gem_names.length == 1
81
81
      end
82
82
 
83
 
      files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
84
 
 
85
 
      files.each do |f|
86
 
        path = if options[:prefix] then
87
 
                 File.join gem_spec.full_gem_path, f
88
 
               else
89
 
                 f
90
 
               end
91
 
 
92
 
        say path
 
83
      gem_path = spec.full_gem_path
 
84
      extra    = "/{#{spec.require_paths.join ','}}" if options[:lib_only]
 
85
      glob     = "#{gem_path}#{extra}/**/*"
 
86
      files    = Dir[glob]
 
87
 
 
88
      gem_path = File.join gem_path, '' # add trailing / if missing
 
89
 
 
90
      files.sort.each do |file|
 
91
        next if File.directory? file
 
92
 
 
93
        file = file.sub gem_path, '' unless options[:prefix]
 
94
 
 
95
        say file
93
96
      end
94
97
    end
95
98
  end