Hello community, here is the log from the commit of package rubygem-commander for openSUSE:Factory checked in at 2015-04-10 09:53:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-commander (Old) and /work/SRC/openSUSE:Factory/.rubygem-commander.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-commander" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-commander/rubygem-commander.changes 2015-02-11 16:45:17.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-commander.new/rubygem-commander.changes 2015-04-10 09:53:05.000000000 +0200 @@ -1,0 +2,11 @@ +Wed Apr 8 09:32:30 UTC 2015 - coolo@suse.com + +- updated to version 4.3.2 + * Version bump to publish new location of Commander to Rubygems. Moved to https://github.com/commander-rb/commander + +------------------------------------------------------------------- +Sat Mar 28 05:30:13 UTC 2015 - coolo@suse.com + +- updated to version 4.3.1 + +------------------------------------------------------------------- Old: ---- commander-4.3.0.gem New: ---- commander-4.3.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-commander.spec ++++++ --- /var/tmp/diff_new_pack.O57PIA/_old 2015-04-10 09:53:05.000000000 +0200 +++ /var/tmp/diff_new_pack.O57PIA/_new 2015-04-10 09:53:05.000000000 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-commander -Version: 4.3.0 +Version: 4.3.2 Release: 0 %define mod_name commander %define mod_full_name %{mod_name}-%{version} @@ -33,7 +33,7 @@ BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives -Url: https://github.com/tj/commander +Url: https://github.com/commander-rb/commander Source: http://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: The complete solution for Ruby command-line executables ++++++ commander-4.3.0.gem -> commander-4.3.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml --- old/.rubocop.yml 2015-02-08 02:26:24.000000000 +0100 +++ new/.rubocop.yml 2015-04-01 07:55:48.000000000 +0200 @@ -4,7 +4,6 @@ Encoding: Enabled: false -# Offense count: 1 -LineLength: - Max: 242 - +# Enforce trailing comma after last item of multiline hashes. +Style/TrailingComma: + EnforcedStyleForMultiline: comma diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop_todo.yml new/.rubocop_todo.yml --- old/.rubocop_todo.yml 2015-02-08 02:26:24.000000000 +0100 +++ new/.rubocop_todo.yml 2015-04-01 07:55:48.000000000 +0200 @@ -1,19 +1,10 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2015-02-07 17:05:05 -0800 using RuboCop version 0.29.0. +# on 2015-02-16 16:08:54 -0800 using RuboCop version 0.29.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 5 -Lint/AmbiguousOperator: - Enabled: false - -# Offense count: 1 -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: - Enabled: false - # Offense count: 2 Lint/Eval: Enabled: false @@ -22,19 +13,6 @@ Lint/HandleExceptions: Enabled: false -# Offense count: 1 -Lint/RescueException: - Enabled: false - -# Offense count: 2 -Lint/ShadowingOuterLocalVariable: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Lint/UnusedBlockArgument: - Enabled: false - # Offense count: 5 Metrics/AbcSize: Max: 29 @@ -42,13 +20,13 @@ # Offense count: 1 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 221 + Max: 230 # Offense count: 4 Metrics/CyclomaticComplexity: Max: 13 -# Offense count: 2 +# Offense count: 89 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: Max: 242 @@ -56,7 +34,7 @@ # Offense count: 7 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 33 + Max: 36 # Offense count: 4 Metrics/PerceivedComplexity: @@ -66,147 +44,34 @@ Style/AccessorMethodName: Enabled: false -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/AndOr: - Enabled: false - -# Offense count: 1 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/ClassAndModuleChildren: - Enabled: false - # Offense count: 18 Style/Documentation: Enabled: false -# Offense count: 2 -Style/EachWithObject: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/EmptyLinesAroundClassBody: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/EmptyLinesAroundMethodBody: - Enabled: false - -# Offense count: 5 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/FormatString: - Enabled: false - # Offense count: 12 # Configuration parameters: AllowedVariables. Style/GlobalVars: Enabled: false -# Offense count: 2 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Enabled: false - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/HashSyntax: - Enabled: false - # Offense count: 1 # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -Style/Lambda: - Enabled: false - -# Offense count: 17 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/MethodDefParentheses: - Enabled: false - # Offense count: 1 Style/MultilineBlockChain: Enabled: false # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/MultilineOperationIndentation: - Enabled: false - -# Offense count: 1 Style/MultilineTernaryOperator: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/Not: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Enabled: false - # Offense count: 5 Style/RescueModifier: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/SignalException: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpecialGlobalVars: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. -Style/TrailingComma: - Enabled: false - -# Offense count: 74 -# Cop supports --auto-correct. -Style/TrailingWhitespace: - Enabled: false - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. Style/TrivialAccessors: Enabled: false - -# Offense count: 1 -Style/UnlessElse: - Enabled: false - -# Offense count: 1 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/VariableName: - Enabled: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.rdoc new/History.rdoc --- old/History.rdoc 2015-02-08 02:26:24.000000000 +0100 +++ new/History.rdoc 2015-04-01 07:55:48.000000000 +0200 @@ -1,3 +1,12 @@ +=== 4.3.2 / 2015-03-31 + +* Version bump to publish new location of Commander to Rubygems. Moved to https://github.com/commander-rb/commander + +=== 4.3.1 / 2015-03-27 + +* Fix various Ruby warnings for circular requires, etc. +* Update to use highline 1.7 (@SkyTrix) + === 4.3.0 / 2015-02-07 * Drops support for Ruby 1.8. Please use 4.2.1 if you still need Ruby 1.8 compatibility. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2015-02-08 02:26:24.000000000 +0100 +++ new/README.md 2015-04-01 07:55:48.000000000 +0200 @@ -1,5 +1,5 @@ -[<img src="https://secure.travis-ci.org/ggilder/commander.png?branch=master" alt="Build Status" />](http://travis-ci.org/ggilder/commander) -[![Inline docs](http://inch-ci.org/github/tj/commander.png)](http://inch-ci.org/github/tj/commander) +[<img src="https://secure.travis-ci.org/commander-rb/commander.png?branch=master" alt="Build Status" />](http://travis-ci.org/commander-rb/commander) +[![Inline docs](http://inch-ci.org/github/commander-rb/commander.png)](http://inch-ci.org/github/commander-rb/commander) # Commander @@ -449,7 +449,7 @@ ## Contrib Feel free to fork and request a pull, or submit a ticket -http://github.com/tj/commander/issues +http://github.com/commander-rb/commander/issues ## License diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bin/commander new/bin/commander --- old/bin/commander 2015-02-08 02:26:24.000000000 +0100 +++ new/bin/commander 2015-04-01 07:55:48.000000000 +0200 @@ -48,7 +48,7 @@ end File.chmod 0755, file say "Initialized template in #{file}" - rescue Exception => e + rescue => e abort e end end Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/commander.gemspec new/commander.gemspec --- old/commander.gemspec 2015-02-08 02:26:24.000000000 +0100 +++ new/commander.gemspec 2015-04-01 07:55:48.000000000 +0200 @@ -8,7 +8,7 @@ s.authors = ['TJ Holowaychuk', 'Gabriel Gilder'] s.email = ['gabriel@gabrielgilder.com'] s.license = 'MIT' - s.homepage = 'https://github.com/tj/commander' + s.homepage = 'https://github.com/commander-rb/commander' s.summary = 'The complete solution for Ruby command-line executables' s.description = 'The complete solution for Ruby command-line executables. Commander bridges the gap between other terminal related libraries you know and love (OptionParser, HighLine), while providing many new features, and an elegant API.' @@ -17,10 +17,10 @@ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } s.require_paths = ['lib'] - s.add_runtime_dependency('highline', '~> 1.6.11') + s.add_runtime_dependency('highline', '~> 1.7.1') - s.add_development_dependency('rspec', '~> 2.14') + s.add_development_dependency('rspec', '~> 3.2') s.add_development_dependency('rake') s.add_development_dependency('simplecov') - s.add_development_dependency('rubocop', '~> 0.29.0') + s.add_development_dependency('rubocop', '~> 0.29.1') end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/blank.rb new/lib/commander/blank.rb --- old/lib/commander/blank.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/blank.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - module Blank def self.included(base) base.class_eval do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/command.rb new/lib/commander/command.rb --- old/lib/commander/command.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/command.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - require 'optparse' module Commander @@ -112,7 +111,7 @@ args: args, proc: proc, switches: switches, - description: description + description: description, } end @@ -162,7 +161,7 @@ def parse_options_and_call_procs(*args) return args if args.empty? - @options.inject OptionParser.new do |opts, option| + @options.each_with_object(OptionParser.new) do |option, opts| opts.on(*option[:args], &option[:proc]) opts end.parse! args @@ -187,7 +186,7 @@ # collected by the #option_proc. def proxy_option_struct - proxy_options.inject Options.new do |options, (option, value)| + proxy_options.each_with_object(Options.new) do |(option, value), options| # options that are present will evaluate to true value = true if value.nil? options.__send__ :"#{option}=", value @@ -201,7 +200,7 @@ # and work with option values. def option_proc(switches) - lambda { |value| proxy_options << [Runner.switch_to_sym(switches.last), value] } + ->(value) { proxy_options << [Runner.switch_to_sym(switches.last), value] } end def inspect diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/configure.rb new/lib/commander/configure.rb --- old/lib/commander/configure.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/configure.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,6 +1,3 @@ -require 'commander' -require 'commander/methods' - module Commander def configure(*configuration_opts, &configuration_block) configuration_module = Module.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/core_ext/array.rb new/lib/commander/core_ext/array.rb --- old/lib/commander/core_ext/array.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/core_ext/array.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - class Array ## # Split _string_ into an array. Used in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/core_ext/object.rb new/lib/commander/core_ext/object.rb --- old/lib/commander/core_ext/object.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/core_ext/object.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - class Object ## # Return the current binding. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/core_ext.rb new/lib/commander/core_ext.rb --- old/lib/commander/core_ext.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/core_ext.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,3 +1,2 @@ - require 'commander/core_ext/array' require 'commander/core_ext/object' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/delegates.rb new/lib/commander/delegates.rb --- old/lib/commander/delegates.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/delegates.rb 2015-04-01 07:55:48.000000000 +0200 @@ -12,8 +12,8 @@ never_trace! ).each do |meth| eval <<-END, binding, __FILE__, __LINE__ - def #{meth} *args, &block - ::Commander::Runner.instance.#{meth} *args, &block + def #{meth}(*args, &block) + ::Commander::Runner.instance.#{meth}(*args, &block) end END end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/help_formatters/base.rb new/lib/commander/help_formatters/base.rb --- old/lib/commander/help_formatters/base.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/help_formatters/base.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - module Commander ## # = Help Formatter diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/help_formatters/terminal.rb new/lib/commander/help_formatters/terminal.rb --- old/lib/commander/help_formatters/terminal.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/help_formatters/terminal.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - require 'erb' module Commander diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/help_formatters/terminal_compact.rb new/lib/commander/help_formatters/terminal_compact.rb --- old/lib/commander/help_formatters/terminal_compact.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/help_formatters/terminal_compact.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - require 'erb' module Commander diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/help_formatters.rb new/lib/commander/help_formatters.rb --- old/lib/commander/help_formatters.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/help_formatters.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - module Commander module HelpFormatter autoload :Base, 'commander/help_formatters/base' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/import.rb new/lib/commander/import.rb --- old/lib/commander/import.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/import.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,6 +1,4 @@ - require 'commander' -require 'commander/delegates' include Commander::UI include Commander::UI::AskForClass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/methods.rb new/lib/commander/methods.rb --- old/lib/commander/methods.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/methods.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,10 +1,9 @@ -require 'commander' -require 'commander/delegates' +module Commander + module Methods + include Commander::UI + include Commander::UI::AskForClass + include Commander::Delegates -module Commander::Methods - include Commander::UI - include Commander::UI::AskForClass - include Commander::Delegates - - $terminal.wrap_at = HighLine::SystemExtensions.terminal_size.first - 5 rescue 80 if $stdin.tty? + $terminal.wrap_at = HighLine::SystemExtensions.terminal_size.first - 5 rescue 80 if $stdin.tty? + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/platform.rb new/lib/commander/platform.rb --- old/lib/commander/platform.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/platform.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,4 +1,3 @@ - module Commander module Platform def self.jruby? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/runner.rb new/lib/commander/runner.rb --- old/lib/commander/runner.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/runner.rb 2015-04-01 07:55:48.000000000 +0200 @@ -2,71 +2,77 @@ module Commander class Runner - #-- # Exceptions #++ class CommandError < StandardError; end class InvalidCommandError < CommandError; end - + ## # Array of commands. - + attr_reader :commands - + ## # Global options. - + attr_reader :options - + ## # Hash of help formatter aliases. - + attr_reader :help_formatter_aliases ## # Initialize a new command runner. Optionally # supplying _args_ for mocking, or arbitrary usage. - - def initialize args = ARGV + + def initialize(args = ARGV) @args, @commands, @aliases, @options = args, {}, {}, [] @help_formatter_aliases = help_formatter_alias_defaults @program = program_defaults + @always_trace = false + @never_trace = false create_default_commands end - + ## # Return singleton Runner instance. - + def self.instance @singleton ||= new end - + ## # Run command parsing and execution process. - + def run! trace = @always_trace || false require_program :version, :description trap('INT') { abort program(:int_message) } if program(:int_message) trap('INT') { program(:int_block).call } if program(:int_block) global_option('-h', '--help', 'Display help documentation') do - args = @args - %w[-h --help] + args = @args - %w(-h --help) command(:help).run(*args) return end - global_option('-v', '--version', 'Display version information') { say version; return } + global_option('-v', '--version', 'Display version information') do + say version + return + end global_option('-t', '--trace', 'Display backtrace when an error occurs') { trace = true } unless @never_trace || @always_trace parse_global_options remove_global_options options, @args - unless trace + if trace + run_active_command + else begin run_active_command rescue InvalidCommandError => e abort "#{e}. Use --help for more information" rescue \ - OptionParser::InvalidOption, + OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e abort e.to_s @@ -77,16 +83,14 @@ abort "error: #{e}. Use --trace to view backtrace" end end - else - run_active_command end end - + ## # Return program version. - + def version - '%s %s' % [program(:name), program(:version)] + format('%s %s', program(:name), program(:version)) end ## @@ -109,7 +113,7 @@ # Assign program information. # # === Examples - # + # # # Set data # program :name, 'Commander' # program :version, Commander::VERSION @@ -119,7 +123,7 @@ # program :int_message 'Bye bye!' # program :help_formatter, :compact # program :help_formatter, Commander::HelpFormatter::TerminalCompact - # + # # # Get data # program :name # => 'Commander' # @@ -132,9 +136,9 @@ # :help Allows addition of arbitrary global help blocks # :int_message Message to display when interrupted (CTRL + C) # - - def program key, *args, &block - if key == :help and !args.empty? + + def program(key, *args, &block) + if key == :help && !args.empty? @program[:help] ||= {} @program[:help][args.first] = args.at(1) elsif key == :help_formatter && !args.empty? @@ -148,150 +152,154 @@ @program[key] end end - + ## # Creates and yields a command instance when a block is passed. # Otherwise attempts to return the command, raising InvalidCommandError when # it does not exist. # # === Examples - # + # # command :my_command do |c| # c.when_called do |args| # # Code # end # end # - - def command name, &block + + def command(name, &block) yield add_command(Commander::Command.new(name)) if block @commands[name.to_s] end - + ## # Add a global option; follows the same syntax as Command#option # This would be used for switches such as --version, --trace, etc. - - def global_option *args, &block - switches, description = Runner.separate_switches_from_description *args + + def global_option(*args, &block) + switches, description = Runner.separate_switches_from_description(*args) @options << { - :args => args, - :proc => block, - :switches => switches, - :description => description, + args: args, + proc: block, + switches: switches, + description: description, } end - + ## # Alias command _name_ with _alias_name_. Optionally _args_ may be passed # as if they were being passed straight to the original command via the command-line. - - def alias_command alias_name, name, *args + + def alias_command(alias_name, name, *args) @commands[alias_name.to_s] = command name @aliases[alias_name.to_s] = args end - + ## # Default command _name_ to be used when no other # command is found in the arguments. - - def default_command name + + def default_command(name) @default_command = name end - + ## # Add a command object to this runner. - - def add_command command + + def add_command(command) @commands[command.name] = command end - + ## # Check if command _name_ is an alias. - - def alias? name + + def alias?(name) @aliases.include? name.to_s end - + ## # Check if a command _name_ exists. - - def command_exists? name + + def command_exists?(name) @commands[name.to_s] end - + #:stopdoc: - + ## # Get active command within arguments passed to this runner. - + def active_command @__active_command ||= command(command_name_from_args) end - + ## # Attempts to locate a command name from within the arguments. # Supports multi-word commands, using the largest possible match. - + def command_name_from_args @__command_name_from_args ||= (valid_command_names_from(*@args.dup).sort.last || @default_command) end - + ## # Returns array of valid command names found within _args_. - - def valid_command_names_from *args + + def valid_command_names_from(*args) arg_string = args.delete_if { |value| value =~ /^-/ }.join ' ' commands.keys.find_all { |name| name if /^#{name}\b/.match arg_string } end - + ## # Help formatter instance. - + def help_formatter @__help_formatter ||= program(:help_formatter).new self end - + ## # Return arguments without the command name. - + def args_without_command_name removed = [] parts = command_name_from_args.split rescue [] @args.dup.delete_if do |arg| - removed << arg if parts.include?(arg) and not removed.include?(arg) + removed << arg if parts.include?(arg) && !removed.include?(arg) end end - + ## # Returns hash of help formatter alias defaults. - + def help_formatter_alias_defaults - return :compact => HelpFormatter::TerminalCompact + { + compact: HelpFormatter::TerminalCompact, + } end - + ## # Returns hash of program defaults. - + def program_defaults - return :help_formatter => HelpFormatter::Terminal, - :name => File.basename($0) + { + help_formatter: HelpFormatter::Terminal, + name: File.basename($PROGRAM_NAME), + } end - + ## - # Creates default commands such as 'help' which is + # Creates default commands such as 'help' which is # essentially the same as using the --help switch. - + def create_default_commands command :help do |c| c.syntax = 'commander help [command]' c.description = 'Display global or [command] help documentation' c.example 'Display global help', 'command help' c.example "Display help for 'foo'", 'command help foo' - c.when_called do |args, options| + c.when_called do |args, _options| UI.enable_paging if args.empty? - say help_formatter.render + say help_formatter.render else command = command args.join(' ') begin @@ -304,33 +312,33 @@ end end end - + ## # Raises InvalidCommandError when a _command_ is not found. - - def require_valid_command command = active_command - raise InvalidCommandError, 'invalid command', caller if command.nil? + + def require_valid_command(command = active_command) + fail InvalidCommandError, 'invalid command', caller if command.nil? end - + ## # Removes global _options_ from _args_. This prevents an invalid # option error from occurring when options are parsed # again for the command. - - def remove_global_options options, args + + def remove_global_options(options, args) # TODO: refactor with flipflop, please TJ ! have time to refactor me ! options.each do |option| switches = option[:switches].dup next if switches.empty? - if switchHasArg = switches.any? { |s| s =~ /[ =]/ } + if (switch_has_arg = switches.any? { |s| s =~ /[ =]/ }) switches.map! { |s| s[0, s.index('=') || s.index(' ') || s.length] } end past_switch, arg_removed = false, false args.delete_if do |arg| if switches.any? { |s| arg[0, s.length] == s } - arg_removed = !switchHasArg + arg_removed = !switch_has_arg past_switch = true elsif past_switch && !arg_removed && arg !~ /^-/ arg_removed = true @@ -341,14 +349,13 @@ end end end - + ## # Parse global command options. - - def parse_global_options + def parse_global_options parser = options.inject(OptionParser.new) do |options, option| - options.on *option[:args], &global_option_proc(option[:switches], &option[:proc]) + options.on(*option[:args], &global_option_proc(option[:switches], &option[:proc])) end options = @args.dup @@ -360,44 +367,44 @@ retry end end - + ## # Returns a proc allowing for commands to inherit global options. # This functionality works whether a block is present for the global # option or not, so simple switches such as --verbose can be used # without a block, and used throughout all commands. - - def global_option_proc switches, &block + + def global_option_proc(switches, &block) lambda do |value| unless active_command.nil? active_command.proxy_options << [Runner.switch_to_sym(switches.last), value] end - yield value if block and !value.nil? + yield value if block && !value.nil? end end - + ## # Raises a CommandError when the program any of the _keys_ are not present, or empty. - - def require_program *keys + + def require_program(*keys) keys.each do |key| - raise CommandError, "program #{key} required" if program(key).nil? or program(key).empty? + fail CommandError, "program #{key} required" if program(key).nil? || program(key).empty? end end - + ## # Return switches and description separated from the _args_ passed. - def self.separate_switches_from_description *args - switches = args.find_all { |arg| arg.to_s =~ /^-/ } - description = args.last unless !args.last.is_a? String or args.last.match(/^-/) - return switches, description + def self.separate_switches_from_description(*args) + switches = args.find_all { |arg| arg.to_s =~ /^-/ } + description = args.last if args.last.is_a?(String) && !args.last.match(/^-/) + [switches, description] end - + ## # Attempts to generate a method name symbol from +switch+. # For example: - # + # # -h # => :h # --trace # => :trace # --some-switch # => :some_switch @@ -405,26 +412,25 @@ # --file FILE # => :file # --list of,things # => :list # - - def self.switch_to_sym switch + + def self.switch_to_sym(switch) switch.scan(/[\-\]](\w+)/).join('_').to_sym rescue nil end - + ## # Run the active command. - + def run_active_command require_valid_command if alias? command_name_from_args - active_command.run *(@aliases[command_name_from_args.to_s] + args_without_command_name) + active_command.run(*(@aliases[command_name_from_args.to_s] + args_without_command_name)) else - active_command.run *args_without_command_name - end - end - - def say *args #:nodoc: - $terminal.say *args + active_command.run(*args_without_command_name) + end end + def say(*args) #:nodoc: + $terminal.say(*args) + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/user_interaction.rb new/lib/commander/user_interaction.rb --- old/lib/commander/user_interaction.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/user_interaction.rb 2015-04-01 07:55:48.000000000 +0200 @@ -53,7 +53,7 @@ # def log(action, *args) - say '%15s %s' % [action, args.join(' ')] + say format('%15s %s', action, args.join(' ')) end ## @@ -165,18 +165,24 @@ def converse(prompt, responses = {}) i, commands = 0, responses.map { |_key, value| value.inspect }.join(',') - statement = responses.inject '' do |statement, (key, value)| - statement << (((i += 1) == 1 ? - %(if response is "#{value}" then\n) : %(else if response is "#{value}" then\n))) << - %(do shell script "echo '#{key}'"\n) + statement = responses.inject '' do |inner_statement, (key, value)| + inner_statement << + ( + (i += 1) == 1 ? + %(if response is "#{value}" then\n) : + %(else if response is "#{value}" then\n) + ) << + %(do shell script "echo '#{key}'"\n) end - applescript(%( + applescript( + %( tell application "SpeechRecognitionServer" set response to listen for {#{commands}} with prompt "#{prompt}" #{statement} end if end tell - )).strip.to_sym + ), + ).strip.to_sym end ## @@ -214,10 +220,9 @@ def io(input = nil, output = nil, &block) $stdin = File.new(input) if input $stdout = File.new(output, 'r+') if output - if block - yield - reset_io - end + return unless block + yield + reset_io end ## @@ -279,7 +284,8 @@ if Kernel.fork $stdin.reopen read - write.close; read.close + write.close + read.close Kernel.select [$stdin] ENV['LESS'] = 'FSRX' unless ENV.key? 'LESS' pager = ENV['PAGER'] || 'less' @@ -288,7 +294,8 @@ # subprocess $stdout.reopen write $stderr.reopen write if $stderr.tty? - write.close; read.close + write.close + read.close end rescue NotImplementedError ensure @@ -318,15 +325,17 @@ module AskForClass # All special cases in HighLine::Question#convert, except those that implement #parse - ([Float, Integer, String, Symbol, Regexp, Array, File, Pathname] + - # All Classes that respond to #parse - Object.constants.map do |const| - # const_get(:Config) issues a deprecation warning on ruby 1.8.7 - # TODO: clean up now that we're not supporting Ruby 1.8 - Object.const_get(const) unless const == :Config - end.select do |const| - const.class == Class && const.respond_to?(:parse) - end).each do |klass| + ( + [Float, Integer, String, Symbol, Regexp, Array, File, Pathname] + + # All Classes that respond to #parse + Object.constants.map do |const| + # const_get(:Config) issues a deprecation warning on ruby 1.8.7 + # TODO: clean up now that we're not supporting Ruby 1.8 + Object.const_get(const) unless const == :Config + end.select do |const| + const.class == Class && const.respond_to?(:parse) + end + ).each do |klass| define_method "ask_for_#{klass.to_s.downcase}" do |prompt| $terminal.ask(prompt, klass) end @@ -337,8 +346,8 @@ # Substitute _hash_'s keys with their associated values in _str_. def replace_tokens(str, hash) #:nodoc: - hash.inject str do |str, (key, value)| - str.gsub ":#{key}", value.to_s + hash.inject(str) do |string, (key, value)| + string.gsub ":#{key}", value.to_s end end @@ -465,8 +474,8 @@ step: @step, steps_remaining: steps_remaining, total_steps: @total_steps, - time_elapsed: '%0.2fs' % time_elapsed, - time_remaining: @step > 0 ? '%0.2fs' % time_remaining : '' + time_elapsed: format('%0.2fs', time_elapsed), + time_remaining: @step > 0 ? format('%0.2fs', time_remaining) : '', }.merge! @tokens end @@ -474,13 +483,12 @@ # Output the progress bar. def show - unless finished? - erase_line - if completed? - $terminal.say UI.replace_tokens(@complete_message, generate_tokens) if @complete_message.is_a? String - else - $terminal.say UI.replace_tokens(@format, generate_tokens) << ' ' - end + return if finished? + erase_line + if completed? + $terminal.say UI.replace_tokens(@complete_message, generate_tokens) if @complete_message.is_a? String + else + $terminal.say UI.replace_tokens(@format, generate_tokens) << ' ' end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander/version.rb new/lib/commander/version.rb --- old/lib/commander/version.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander/version.rb 2015-04-01 07:55:48.000000000 +0200 @@ -1,3 +1,3 @@ module Commander - VERSION = '4.3.0' + VERSION = '4.3.2' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/commander.rb new/lib/commander.rb --- old/lib/commander.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/lib/commander.rb 2015-04-01 07:55:48.000000000 +0200 @@ -30,5 +30,6 @@ require 'commander/command' require 'commander/help_formatters' require 'commander/platform' +require 'commander/delegates' require 'commander/methods' require 'commander/configure' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-02-08 02:26:24.000000000 +0100 +++ new/metadata 2015-04-01 07:55:48.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: commander version: !ruby/object:Gem::Version - version: 4.3.0 + version: 4.3.2 platform: ruby authors: - TJ Holowaychuk @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2015-02-08 00:00:00.000000000 Z +date: 2015-04-01 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: highline @@ -17,28 +17,28 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: 1.6.11 + version: 1.7.1 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 1.6.11 + version: 1.7.1 - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '2.14' + version: '3.2' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '2.14' + version: '3.2' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement @@ -73,14 +73,14 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: 0.29.0 + version: 0.29.1 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 0.29.0 + version: 0.29.1 description: The complete solution for Ruby command-line executables. Commander bridges the gap between other terminal related libraries you know and love (OptionParser, HighLine), while providing many new features, and an elegant API. @@ -136,7 +136,7 @@ - spec/runner_spec.rb - spec/spec_helper.rb - spec/ui_spec.rb -homepage: https://github.com/tj/commander +homepage: https://github.com/commander-rb/commander licenses: - MIT metadata: {} @@ -156,7 +156,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.3 +rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: The complete solution for Ruby command-line executables diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/core_ext/object_spec.rb new/spec/core_ext/object_spec.rb --- old/spec/core_ext/object_spec.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/spec/core_ext/object_spec.rb 2015-04-01 07:55:48.000000000 +0200 @@ -3,7 +3,7 @@ describe Object do describe '#get_binding' do it 'should return the objects binding' do - expect(lambda {}.get_binding).to be_instance_of(Binding) + expect(-> {}.get_binding).to be_instance_of(Binding) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/runner_spec.rb new/spec/runner_spec.rb --- old/spec/runner_spec.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/spec/runner_spec.rb 2015-04-01 07:55:48.000000000 +0200 @@ -274,7 +274,6 @@ describe '--trace' do it 'should display pretty errors by default' do - pending("JRuby's Kernel.abort implementation is not testable") if Commander::Platform.jruby? expect do new_command_runner 'foo' do command(:foo) { |c| c.when_called { fail 'cookies!' } } @@ -356,7 +355,6 @@ describe 'with invalid options' do it 'should output an invalid option message' do - pending("JRuby's Kernel.abort implementation is not testable") if Commander::Platform.jruby? expect do run('test', '--invalid-option') end.to raise_error(SystemExit, /invalid option: --invalid-option/) @@ -365,7 +363,6 @@ describe 'with invalid command passed' do it 'should output an invalid command message' do - pending("JRuby's Kernel.abort implementation is not testable") if Commander::Platform.jruby? expect do run('foo') end.to raise_error(SystemExit, /invalid command. Use --help for more information/) @@ -374,7 +371,6 @@ describe 'with invalid command passed to help' do it 'should output an invalid command message' do - pending("JRuby's Kernel.abort implementation is not testable") if Commander::Platform.jruby? expect do run('help', 'does_not_exist') end.to raise_error(SystemExit, /invalid command. Use --help for more information/) @@ -383,7 +379,6 @@ describe 'with invalid command passed to --help' do it 'should output an invalid command message' do - pending("JRuby's Kernel.abort implementation is not testable") if Commander::Platform.jruby? expect do run('--help', 'does_not_exist') end.to raise_error(SystemExit, /invalid command. Use --help for more information/) @@ -392,7 +387,6 @@ describe 'with invalid option passed to --help' do it 'should output an invalid option message' do - pending("JRuby's Kernel.abort implementation is not testable") if Commander::Platform.jruby? expect do run('--help', 'test', '--invalid-option') end.to raise_error(SystemExit, /invalid option: --invalid-option/) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb --- old/spec/spec_helper.rb 2015-02-08 02:26:24.000000000 +0100 +++ new/spec/spec_helper.rb 2015-04-01 07:55:48.000000000 +0200 @@ -31,7 +31,7 @@ c.example 'description 2', 'command 2' c.option '-v', '--verbose', 'verbose description' c.when_called do |args, _options| - 'test %s' % args.join + format('test %s', args.join) end end @command = command :test