Class: Gem::Commands::InfoCommand
- Inherits:
-
Command
- Object
- Command
- Gem::Commands::InfoCommand
- Defined in:
- lib/rubygems_plugin.rb
Instance Method Summary collapse
- #arguments ⇒ Object
- #default_str ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ InfoCommand
constructor
A new instance of InfoCommand.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ InfoCommand
Returns a new instance of InfoCommand.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rubygems_plugin.rb', line 9 def initialize super 'info', "Print information about a gem. Fuzzy matching available." add_option('-1', '--exactly-one', "Fail if not exactly 1 match.") do |value, | [:exactly_one] = true end add_option('-f', '--format STRING', "Format of output (see below).") do |value, | [:format] = value end add_option('-N', '--no-newlines', "Suppress printing of newlines after each gem") do |value, | [:no_newlines] = true end end |
Instance Method Details
#arguments ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rubygems_plugin.rb', line 22 def arguments <<-EOS.gsub(/^ *\|/, '') |NAME (fuzzy) name of the gem |VERSION (fuzzy) version of the gem EOS end |
#default_str ⇒ Object
33 34 35 |
# File 'lib/rubygems_plugin.rb', line 33 def default_str '' end |
#description ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rubygems_plugin.rb', line 37 def description <<-EOS.gsub(/^ *\|/, '') |Print information about matching gems. The NAME and |VERSION are fuzzy-matched according to the following |algorithm: | | * Look for gems exactly matching NAME. | * If none found, look for gems containing NAME. e.g., | "inf" matches "gem_info" | * If none found, look for gems containing the characters | of NAME in the same order. e.g, "e_nf" matches | "gem_info" | * Filter the results above with the version string in the | same way. | |The format string (--format option) has the following |escapes available: | |%rubygems_version | Rubygems version that built the gemspec |%specification_version | Version of the gem's gemspec |%name | Gem name |%version | Gem version |%date |%date[STRFTIME_FORMAT] | Date the gem was released. STRFTIME_FORMAT may contain | any %-escapes honored by Time#strftime |%summary | Summary of the gem |%email | Email address of the gem author |%homepage | Homepage of the gem |%rubyforge_project | Name of the rubyforge project |%description | Gem description |%executables | List of executables (comma separated) |%bindir | Directory the gem's executables are installed into |%required_ruby_version | Ruby version required for the gem |%required_rubygems_version | Rubygems version required for the gem |%platform | Platform the gem is built for |%signing_key | Key which signed the gem |%cert_chain | Certificate chain used for signing ("\\n\\n" separated) |%post_install_message | Message displayed upon installation |%authors | List of author names (comma separated) |%licenses | List of license names (comma separated) |%dependencies | List of dependencies (comma separated) |%path | Path of the installed gem |%% | A '%' character |%N | A newline EOS end |
#execute ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/rubygems_plugin.rb', line 108 def execute begin GemInfo::Runner.run(, *[:args]) rescue GemInfo::UsageError STDERR.puts "USAGE: #{usage}" terminate_interaction(1) rescue GemInfo::Error => e STDERR.puts e. terminate_interaction(1) rescue Object => e puts "Unexpected error! Debug with DEBUG=1" if ENV['DEBUG'] STDERR.puts "#{exception.class}: #{exception.}" exception.backtrace.each do |line| STDERR.puts " #{line}" end end raise end end |
#usage ⇒ Object
29 30 31 |
# File 'lib/rubygems_plugin.rb', line 29 def usage "#{program_name} NAME [VERSION]" end |