Hello community, here is the log from the commit of package rubygem-commander for openSUSE:Factory checked in at 2020-05-11 13:40:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-commander (Old) and /work/SRC/openSUSE:Factory/.rubygem-commander.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-commander" Mon May 11 13:40:36 2020 rev:27 rq:802329 version:4.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-commander/rubygem-commander.changes 2020-03-07 21:37:37.872247544 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-commander.new.2738/rubygem-commander.changes 2020-05-11 13:40:39.585031110 +0200 @@ -1,0 +2,16 @@ +Thu May 7 20:34:32 UTC 2020 - Stephan Kulow <co...@suse.com> + +- updated to version 4.5.2 + see installed History.rdoc + + === 4.5.2 / 2020-03-12 + + * Fix bug handling global options provided in option=value form (#47). (@orien) + * Fix ERB warnings under Ruby 2.7. (@esotericpig) + * Fix bug handling global options placed before command name (#32). (@orien) + + === 4.5.1 / 2020-03-08 + + * Fix bug causing global options to be ignored when arguments are present (#86). (@orien) + +------------------------------------------------------------------- Old: ---- commander-4.5.0.gem New: ---- commander-4.5.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-commander.spec ++++++ --- /var/tmp/diff_new_pack.6QT7C2/_old 2020-05-11 13:40:40.369032773 +0200 +++ /var/tmp/diff_new_pack.6QT7C2/_new 2020-05-11 13:40:40.369032773 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-commander -Version: 4.5.0 +Version: 4.5.2 Release: 0 %define mod_name commander %define mod_full_name %{mod_name}-%{version} ++++++ commander-4.5.0.gem -> commander-4.5.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.rdoc new/History.rdoc --- old/History.rdoc 2020-01-21 19:34:25.000000000 +0100 +++ new/History.rdoc 2020-03-12 22:42:42.000000000 +0100 @@ -1,3 +1,13 @@ +=== 4.5.2 / 2020-03-12 + +* Fix bug handling global options provided in option=value form (#47). (@orien) +* Fix ERB warnings under Ruby 2.7. (@esotericpig) +* Fix bug handling global options placed before command name (#32). (@orien) + +=== 4.5.1 / 2020-03-08 + +* Fix bug causing global options to be ignored when arguments are present (#86). (@orien) + === 4.5.0 / 2020-01-21 * Drop support for Ruby < 2.3. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2020-01-21 19:34:25.000000000 +0100 +++ new/README.md 2020-03-12 22:42:42.000000000 +0100 @@ -1,5 +1,5 @@ -[<img src="https://api.travis-ci.org/commander-rb/commander.svg" alt="Build Status" />](http://travis-ci.org/commander-rb/commander) -[![Inline docs](http://inch-ci.org/github/commander-rb/commander.svg)](http://inch-ci.org/github/commander-rb/commander) +[<img src="https://api.travis-ci.org/commander-rb/commander.svg" alt="Build Status" />](https://travis-ci.org/commander-rb/commander) +[![Inline docs](https://inch-ci.org/github/commander-rb/commander.svg)](https://inch-ci.org/github/commander-rb/commander) # Commander @@ -243,8 +243,8 @@ ## Growl Notifications Commander provides methods for displaying Growl notifications. To use these -methods you need to install http://github.com/tj/growl which utilizes -the [growlnotify](http://growl.info/extras.php#growlnotify) executable. Note that +methods you need to install https://github.com/tj/growl which utilizes +the [growlnotify](https://growl.info/extras.php#growlnotify) executable. Note that growl is auto-imported by Commander when available, no need to require. ```ruby @@ -449,7 +449,7 @@ ## ASCII Tables -For feature rich ASCII tables for your terminal app check out the terminal-table gem at http://github.com/tj/terminal-table +For feature rich ASCII tables for your terminal app check out the terminal-table gem at https://github.com/tj/terminal-table +----------+-------+----+--------+-----------------------+ | Terminal | Table | Is | Wicked | Awesome | @@ -468,7 +468,7 @@ ## Contrib Feel free to fork and request a pull, or submit a ticket -http://github.com/commander-rb/commander/issues +https://github.com/commander-rb/commander/issues ## License Binary 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 2020-01-21 19:34:25.000000000 +0100 +++ new/commander.gemspec 2020-03-12 22:42:42.000000000 +0100 @@ -12,6 +12,13 @@ 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.' + s.metadata = { + 'bug_tracker_uri' => "#{s.homepage}/issues", + 'changelog_uri' => "#{s.homepage}/blob/master/History.rdoc", + 'documentation_uri' => "https://www.rubydoc.info/gems/commander/#{s.version}", + 'homepage_uri' => s.homepage, + 'source_code_uri' => "#{s.homepage}/tree/v#{s.version}", + } s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 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 2020-01-21 19:34:25.000000000 +0100 +++ new/lib/commander/command.rb 2020-03-12 22:42:42.000000000 +0100 @@ -4,6 +4,7 @@ class Command attr_accessor :name, :examples, :syntax, :description attr_accessor :summary, :proxy_options, :options + attr_reader :global_options ## # Options struct. @@ -38,6 +39,7 @@ def initialize(name) @name, @examples, @when_called = name.to_s, [], [] @options, @proxy_options = [], [] + @global_options = [] end ## @@ -190,7 +192,7 @@ # collected by the #option_proc. def proxy_option_struct - proxy_options.each_with_object(Options.new) do |(option, value), options| + (global_options + 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 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 2020-01-21 19:34:25.000000000 +0100 +++ new/lib/commander/help_formatters/terminal.rb 2020-03-12 22:42:42.000000000 +0100 @@ -12,7 +12,11 @@ end def template(name) - ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal', "#{name}.erb")), nil, '-') + if RUBY_VERSION < '2.6' + ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal', "#{name}.erb")), nil, '-') + else + ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal', "#{name}.erb")), trim_mode: '-') + end end end end 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 2020-01-21 19:34:25.000000000 +0100 +++ new/lib/commander/help_formatters/terminal_compact.rb 2020-03-12 22:42:42.000000000 +0100 @@ -4,7 +4,11 @@ module HelpFormatter class TerminalCompact < Terminal def template(name) - ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal_compact', "#{name}.erb")), nil, '-') + if RUBY_VERSION < '2.6' + ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal_compact', "#{name}.erb")), nil, '-') + else + ERB.new(File.read(File.join(File.dirname(__FILE__), 'terminal_compact', "#{name}.erb")), trim_mode: '-') + end end end end 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 2020-01-21 19:34:25.000000000 +0100 +++ new/lib/commander/runner.rb 2020-03-12 22:42:42.000000000 +0100 @@ -246,6 +246,7 @@ # Returns array of valid command names found within _args_. def valid_command_names_from(*args) + remove_global_options options, args arg_string = args.delete_if { |value| value =~ /^-/ }.join ' ' commands.keys.find_all { |name| name if arg_string =~ /^#{name}\b/ } end @@ -329,25 +330,30 @@ def remove_global_options(options, args) options.each do |option| - switches = option[:switches].dup + switches = option[:switches] next if switches.empty? - - if (switch_has_arg = switches.any? { |s| s =~ /[ =]/ }) - switches.map! { |s| s[0, s.index('=') || s.index(' ') || s.length] } - end - + option_takes_argument = switches.any? { |s| s =~ /[ =]/ } switches = expand_optionally_negative_switches(switches) - past_switch, arg_removed = false, false - args.delete_if do |arg| - break if arg == '--' - if switches.any? { |s| s[0, arg.length] == arg } - arg_removed = !switch_has_arg - past_switch = true - elsif past_switch && !arg_removed && arg !~ /^-/ - arg_removed = true + option_argument_needs_removal = false + args.delete_if do |token| + break if token == '--' + + # Use just the portion of the token before the = when + # comparing switches. + index_of_equals = token.index('=') if option_takes_argument + token = token[0, index_of_equals] if index_of_equals + token_contains_option_argument = !index_of_equals.nil? + + if switches.any? { |s| s[0, token.length] == token } + option_argument_needs_removal = + option_takes_argument && !token_contains_option_argument + true + elsif option_argument_needs_removal && token !~ /^-/ + option_argument_needs_removal = false + true else - arg_removed = true + option_argument_needs_removal = false false end end @@ -395,7 +401,7 @@ def global_option_proc(switches, &block) lambda do |value| unless active_command.nil? - active_command.proxy_options << [Runner.switch_to_sym(switches.last), value] + active_command.global_options << [Runner.switch_to_sym(switches.last), value] end yield value if block && !value.nil? 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 2020-01-21 19:34:25.000000000 +0100 +++ new/lib/commander/version.rb 2020-03-12 22:42:42.000000000 +0100 @@ -1,3 +1,3 @@ module Commander - VERSION = '4.5.0'.freeze + VERSION = '4.5.2'.freeze end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2020-01-21 19:34:25.000000000 +0100 +++ new/metadata 2020-03-12 22:42:42.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: commander version: !ruby/object:Gem::Version - version: 4.5.0 + version: 4.5.2 platform: ruby authors: - TJ Holowaychuk @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2020-01-21 00:00:00.000000000 Z +date: 2020-03-12 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: highline @@ -140,7 +140,12 @@ homepage: https://github.com/commander-rb/commander licenses: - MIT -metadata: {} +metadata: + bug_tracker_uri: https://github.com/commander-rb/commander/issues + changelog_uri: https://github.com/commander-rb/commander/blob/master/History.rdoc + documentation_uri: https://www.rubydoc.info/gems/commander/4.5.2 + homepage_uri: https://github.com/commander-rb/commander + source_code_uri: https://github.com/commander-rb/commander/tree/v4.5.2 post_install_message: rdoc_options: [] require_paths: @@ -156,7 +161,7 @@ - !ruby/object:Gem::Version version: '0' requirements: [] -rubygems_version: 3.0.2 +rubygems_version: 3.0.6 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/command_spec.rb new/spec/command_spec.rb --- old/spec/command_spec.rb 2020-01-21 19:34:25.000000000 +0100 +++ new/spec/command_spec.rb 2020-03-12 22:42:42.000000000 +0100 @@ -164,6 +164,33 @@ end @command.run '--interval', '15' end + + describe 'given a global option' do + before do + @command.global_options << [:global_option, 'gvalue'] + end + + describe 'and no command specific arguments' do + it 'provides the global option to the command action' do + @command.when_called { |_, options| expect(options.global_option).to eq('gvalue') } + @command.run + end + end + + describe 'and a command specific option' do + it 'provides the global option to the command action' do + @command.when_called { |_, options| expect(options.global_option).to eq('gvalue') } + @command.run '--verbose' + end + end + + describe 'and a command specific argument' do + it 'provides the global option to the command action' do + @command.when_called { |_, options| expect(options.global_option).to eq('gvalue') } + @command.run 'argument' + end + end + end end 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 2020-01-21 19:34:25.000000000 +0100 +++ new/spec/runner_spec.rb 2020-03-12 22:42:42.000000000 +0100 @@ -100,6 +100,17 @@ expect(quiet).to be true end + it 'should be inherited by commands when provided before the command name' do + option = nil + new_command_runner '--global-option', 'option-value', 'command_name' do + global_option('--global-option=GLOBAL', 'A global option') + command :command_name do |c| + c.when_called { |_, options| option = options.global_option } + end + end.run! + expect(option).to eq('option-value') + end + it 'should be inherited by commands even when a block is present' do quiet = nil new_command_runner 'foo', '--quiet' do @@ -132,6 +143,57 @@ end.run! expect(quiet).to be false end + + it 'should allow command arguments before the global option' do + config = nil + args = nil + new_command_runner 'foo', '--config', 'config-value', 'arg1', 'arg2' do + global_option('-c', '--config CONFIG', String) + command :foo do |c| + c.when_called do |arguments, options| + options.default(config: 'default') + args = arguments + config = options.config + end + end + end.run! + expect(config).to eq('config-value') + expect(args).to eq(%w(arg1 arg2)) + end + + it 'should allow command arguments after the global option' do + config = nil + args = nil + new_command_runner 'foo', 'arg1', 'arg2', '--config', 'config-value' do + global_option('-c', '--config CONFIG', String) + command :foo do |c| + c.when_called do |arguments, options| + options.default(config: 'default') + args = arguments + config = options.config + end + end + end.run! + expect(config).to eq('config-value') + expect(args).to eq(%w(arg1 arg2)) + end + + it 'allows global options in the form option=value' do + config = nil + args = nil + new_command_runner 'test', 'arg1', '--config=config-value', 'arg2' do + global_option('-c', '--config CONFIG', String) + command :test do |c| + c.when_called do |arguments, options| + options.default(config: 'default') + args = arguments + config = options.config + end + end + end.run! + expect(config).to eq('config-value') + expect(args).to eq(%w[arg1 arg2]) + end end describe '#parse_global_options' do @@ -326,6 +388,20 @@ command_runner.remove_global_options options, args expect(args).to eq(%w(--versionCode something)) end + + it 'should remove specified switches value provided via equals' do + options = [{ switches: ['--global GLOBAL'] }] + args = ['--command', '--global=option-value', 'arg'] + command_runner.remove_global_options options, args + expect(args).to eq(['--command', 'arg']) + end + + it 'should not remove extra values after switches' do + options = [{ switches: ['--global GLOBAL'] }] + args = ['--global', '--command', 'arg'] + command_runner.remove_global_options options, args + expect(args).to eq(['--command', 'arg']) + end end describe '--trace' do @@ -334,7 +410,7 @@ new_command_runner 'foo' do command(:foo) { |c| c.when_called { fail 'cookies!' } } end.run! - end.to raise_error(SystemExit, /error: cookies!. Use --trace/) + end.to raise_error(TestSystemExit, /error: cookies!. Use --trace/) end it 'should display callstack when using this switch' do @@ -363,7 +439,7 @@ new_command_runner 'help', '--trace' do never_trace! end.run! - end.to raise_error(SystemExit, /invalid option: --trace/) + end.to raise_error(TestSystemExit, /invalid option: --trace/) end it 'should not prompt to use --trace switch on errors' do @@ -373,7 +449,7 @@ never_trace! command(:foo) { |c| c.when_called { fail 'cookies!' } } end.run! - rescue SystemExit => e + rescue TestSystemExit => e msg = e.message end expect(msg).to match(/error: cookies!/) @@ -430,7 +506,7 @@ it 'should output an invalid option message' do expect do run('test', '--invalid-option') - end.to raise_error(SystemExit, /invalid option: --invalid-option/) + end.to raise_error(TestSystemExit, /invalid option: --invalid-option/) end end @@ -438,7 +514,7 @@ it 'should output an invalid command message' do expect do run('foo') - end.to raise_error(SystemExit, /invalid command. Use --help for more information/) + end.to raise_error(TestSystemExit, /invalid command. Use --help for more information/) end end @@ -446,7 +522,7 @@ it 'should output an invalid command message' do expect do run('help', 'does_not_exist') - end.to raise_error(SystemExit, /invalid command. Use --help for more information/) + end.to raise_error(TestSystemExit, /invalid command. Use --help for more information/) end end @@ -454,7 +530,7 @@ it 'should output an invalid command message' do expect do run('--help', 'does_not_exist') - end.to raise_error(SystemExit, /invalid command. Use --help for more information/) + end.to raise_error(TestSystemExit, /invalid command. Use --help for more information/) end end @@ -462,7 +538,7 @@ it 'should output an invalid option message' do expect do run('--help', 'test', '--invalid-option') - end.to raise_error(SystemExit, /invalid option: --invalid-option/) + end.to raise_error(TestSystemExit, /invalid option: --invalid-option/) end end @@ -495,6 +571,13 @@ expect(command_runner.command_name_from_args).to eq('test') end + it 'should locate command when provided after a global argument with value' do + new_command_runner '--global-option', 'option-value', 'test' do + global_option('--global-option=GLOBAL', 'A global option') + end + expect(command_runner.command_name_from_args).to eq('test') + end + it 'should support multi-word commands' do new_command_runner '--help', '--arbitrary', 'some', 'long', 'command', 'foo' command('some long command') {} 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 2020-01-21 19:34:25.000000000 +0100 +++ new/spec/spec_helper.rb 2020-03-12 22:42:42.000000000 +0100 @@ -14,13 +14,22 @@ require 'commander/methods' # Mock terminal IO streams so we can spec against them - def mock_terminal @input = StringIO.new @output = StringIO.new HighLine.default_instance = HighLine.new(@input, @output) end +# Stub Kernel.abort +TestSystemExit = Class.new(RuntimeError) +module Commander + class Runner + def abort(message) + fail TestSystemExit, message + end + end +end + # Create test command for usage within several specs def create_test_command