2
require 'rubygems/command'
3
require 'rubygems/local_remote_options'
4
require 'rubygems/version_option'
5
require 'rubygems/source_info_cache'
7
class Gem::Commands::SpecificationCommand < Gem::Command
9
include Gem::LocalRemoteOptions
10
include Gem::VersionOption
13
super 'specification', 'Display gem specification (in yaml)',
14
:domain => :local, :version => Gem::Requirement.default
16
add_version_option('examine')
19
add_option('--all', 'Output specifications for all versions of',
20
'the gem') do |value, options|
24
add_local_remote_options
27
def arguments # :nodoc:
28
"GEMFILE name of gem to show the gemspec for"
31
def defaults_str # :nodoc:
32
"--local --version '#{Gem::Requirement.default}'"
36
"#{program_name} [GEMFILE]"
41
gem = get_one_gem_name
44
source_index = Gem::SourceIndex.from_installed_gems
45
specs.push(*source_index.search(/\A#{gem}\z/, options[:version]))
49
alert_warning "Remote information is not complete\n\n"
51
Gem::SourceInfoCache.cache_data.each do |_,sice|
52
specs.push(*sice.source_index.search(gem, options[:version]))
57
alert_error "Unknown gem '#{gem}'"
58
terminate_interaction 1
61
output = lambda { |s| say s.to_yaml; say "\n" }
66
spec = specs.sort_by { |s| s.version }.last