Class: Gem::SpecificationCommand
- Includes:
- CommandAids, LocalRemoteOptions, VersionOption
- Defined in:
- lib/rubygems/gem_commands.rb
Instance Attribute Summary
Attributes inherited from Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
- #arguments ⇒ Object
- #defaults_str ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ SpecificationCommand
constructor
A new instance of SpecificationCommand.
- #usage ⇒ Object
Methods included from CommandAids
#begins?, #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument
Methods included from LocalRemoteOptions
#add_local_remote_options, #local?, #remote?
Methods included from VersionOption
Methods inherited from Command
add_common_option, #add_option, add_specific_extra_args, common_options, extra_args, extra_args=, #handles?, #invoke, #merge_options, #remove_option, #show_help, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from DefaultUserInteraction
#ui, ui, #ui=, ui=, #use_ui, use_ui
Constructor Details
#initialize ⇒ SpecificationCommand
Returns a new instance of SpecificationCommand.
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 |
# File 'lib/rubygems/gem_commands.rb', line 1329 def initialize super('specification', 'Display gem specification (in yaml)', {:domain=>:local, :version=>"> 0.0.0"}) add_version_option('examine') add_option('--all', 'Output specifications for all versions of', 'the gem') do |value, | [:all] = true end end |
Instance Method Details
#arguments ⇒ Object
1348 1349 1350 |
# File 'lib/rubygems/gem_commands.rb', line 1348 def arguments "GEMFILE Name of a .gem file to examine" end |
#defaults_str ⇒ Object
1340 1341 1342 |
# File 'lib/rubygems/gem_commands.rb', line 1340 def defaults_str "--local --version '(latest)'" end |
#execute ⇒ Object
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 |
# File 'lib/rubygems/gem_commands.rb', line 1352 def execute if local? gem = get_one_gem_name gem_specs = Gem::SourceIndex.from_installed_gems.search(gem, [:version]) unless gem_specs.empty? require 'yaml' output = lambda { |spec| say spec.to_yaml; say "\n" } if [:all] gem_specs.each(&output) else spec = gem_specs.sort_by { |spec| spec.version }.last output[spec] end else alert_error "Unknown gem #{gem}" end end if remote? say "(Remote 'info' operation is not yet implemented.)" # NOTE: when we do implement remote info, make sure we don't # duplicate huge swabs of local data. If it's the same, just # say it's the same. end end |
#usage ⇒ Object
1344 1345 1346 |
# File 'lib/rubygems/gem_commands.rb', line 1344 def usage "#{program_name} GEMFILE" end |