execute (Gem::Commands::ContentsCommand)

    # File lib/rubygems/commands/contents_command.rb, line 47
      def execute
        version = options[:version] || Gem::Requirement.default

        spec_dirs = options[:specdirs].map do |i|
          [i, File.join(i, "specifications")]
        end.flatten

        path_kind = if spec_dirs.empty? then
                      spec_dirs = Gem::SourceIndex.installed_spec_directories
                      "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 }
                    else
                      get_all_gem_names
                    end

        gem_names.each do |name|
          gem_spec = si.find_name(name, version).last

          unless gem_spec then
            say "Unable to find gem '#{name}' in #{path_kind}"

            if Gem.configuration.verbose then
              say "\nDirectories searched:"
              spec_dirs.each { |dir| say dir }
            end

            terminate_interaction 1 if gem_names.length == 1
          end

          files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files

          files.each do |f|
            path = if options[:prefix] then
                     File.join gem_spec.full_gem_path, f
                   else
                     f
                   end

            say path
          end
        end
      end