Class: Gem::Commands::CompareCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::CompareCommand
- Includes:
- VersionOption
- Defined in:
- lib/rubygems/commands/compare_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ CompareCommand
constructor
A new instance of CompareCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ CompareCommand
Returns a new instance of CompareCommand.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 |
# File 'lib/rubygems/commands/compare_command.rb', line 8 def initialize super 'compare', 'Compare gem\'s versions and generate a report of changes', :output => Dir.pwd add_option('-a', '--all', 'Show every comparison') do [:log_all] = true end add_option('-k', '--keep-all', 'Keep downloaded and extracted gem files') do [:keep_all] = true end add_option('-n', '--no-color', 'Do not colorize output') do [:no_color] = true end # Speficy the platform using --platform=PLATFORM add_platform_option add_option('-pPARAM', '--param PARAM', 'Compare only a given gemspec parameter (like "version")') do |param, | [:param] = param end add_option('-r', '--runtime', 'Compare only runtime dependencies') do [:param] = 'runtime_dependency' end add_option('-d', '--development', 'Compare only development dependencies') do [:param] = 'development_dependency' end add_option('-f', '--files', 'Compare only files for runtime') do [:param] = 'files' end add_option('-F', '--diff', 'Diff file contents') do [:diff] = true [:param] = 'files' end add_option('-g', '--gemfiles', 'Compare only Gemfiles') do [:param] = 'gemfiles' end add_option('-b', '--brief', 'Include only important changes in the report') do [:log_all] = false [:brief] = true end add_option('-sSOURCES', '--sources SOURCES', 'Use different source URIs for gems (separated by comma)') do |sources, | [:sources] = sources.split ',' end end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
63 64 65 66 67 68 69 |
# File 'lib/rubygems/commands/compare_command.rb', line 63 def arguments # :nodoc: args = <<-EOF GEMNAME gem name VERSION [VERSION ...] list of versions to compare EOF return args.gsub(/^\s+/, '') end |
#description ⇒ Object
:nodoc:
71 72 73 74 75 76 77 |
# File 'lib/rubygems/commands/compare_command.rb', line 71 def description # :nodoc: desc = <<-EOF gem-compare is a RubyGems plugin that compares versions of the given gem. It searches for differences in metadata as well as in files. EOF return desc.gsub(/^\s+/, '') end |
#execute ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rubygems/commands/compare_command.rb', line 83 def execute gem_name = [:args].shift versions = [:args] # No gem specified unless gem_name raise Gem::CommandLineError, "Please specify a gem (e.g. gem compare foo VERSION [VERSION ...])" end # No versions specified if versions.empty? raise Gem::CommandLineError, "Please specify versions you want to compare (e.g. gem compare foo 0.1.0 0.2.0)" end comparator = Gem::Comparator.new() comparator.compare_versions(gem_name, versions) comparator.print_results end |
#usage ⇒ Object
:nodoc:
79 80 81 |
# File 'lib/rubygems/commands/compare_command.rb', line 79 def usage # :nodoc: "#{program_name} GEMNAME VERSION [VERSION ...]" end |