    # File lib/rubygems/commands/specification_command.rb, line 40
      def execute
        specs = []
        gem = get_one_gem_name

        if local? then
          if File.exist? gem then
            specs << Gem::Format.from_file_by_path(gem).spec rescue nil
          end

          if specs.empty? then
            specs.push(*Gem.source_index.search(/\A#{gem}\z/, options[:version]))
          end
        end

        if remote? then
          dep = Gem::Dependency.new gem, options[:version]
          found = Gem::SpecFetcher.fetcher.fetch dep

          specs.push(*found.map { |spec,| spec })
        end

        if specs.empty? then
          alert_error "Unknown gem '#{gem}'"
          terminate_interaction 1
        end

        output = lambda { |s| say s.to_yaml; say "\n" }

        if options[:all] then
          specs.each(&output)
        else
          spec = specs.sort_by { |s| s.version }.last
          output[spec]
        end
      end