Hello community, here is the log from the commit of package rubygem-commander for openSUSE:Factory checked in at 2016-03-07 13:27:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2016-03-01 09:42:38.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-commander.new/rubygem-commander.changes 2016-03-07 13:29:19.000000000 +0100 @@ -1,0 +2,22 @@ +Wed Mar 2 05:30:16 UTC 2016 - [email protected] + +- updated to version 4.4.0 + see installed History.rdoc + + === 4.4.0 / 2016-02-19 + + * Add modular style template initialization. (@lebogan) + * Allow option names that start with a global option name. + * Fix handling of negatable global flags. (@mfurtak) + +------------------------------------------------------------------- +Wed Feb 10 05:29:02 UTC 2016 - [email protected] + +- updated to version 4.3.8 + see installed History.rdoc + + === 4.3.8 / 2016-02-09 + + * Fix regression for deprecation warnings. + +------------------------------------------------------------------- Old: ---- commander-4.3.7.gem New: ---- commander-4.4.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-commander.spec ++++++ --- /var/tmp/diff_new_pack.98v12D/_old 2016-03-07 13:29:20.000000000 +0100 +++ /var/tmp/diff_new_pack.98v12D/_new 2016-03-07 13:29:20.000000000 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-commander -Version: 4.3.7 +Version: 4.4.0 Release: 0 %define mod_name commander %define mod_full_name %{mod_name}-%{version} ++++++ commander-4.3.7.gem -> commander-4.4.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.rubocop_todo.yml new/.rubocop_todo.yml --- old/.rubocop_todo.yml 2016-01-27 01:55:01.000000000 +0100 +++ new/.rubocop_todo.yml 2016-02-19 22:39:21.000000000 +0100 @@ -20,7 +20,7 @@ # Offense count: 1 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 230 + Enabled: false # Offense count: 4 Metrics/CyclomaticComplexity: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.rdoc new/History.rdoc --- old/History.rdoc 2016-01-27 01:55:01.000000000 +0100 +++ new/History.rdoc 2016-02-19 22:39:21.000000000 +0100 @@ -1,3 +1,13 @@ +=== 4.4.0 / 2016-02-19 + +* Add modular style template initialization. (@lebogan) +* Allow option names that start with a global option name. +* Fix handling of negatable global flags. (@mfurtak) + +=== 4.3.8 / 2016-02-09 + +* Fix regression for deprecation warnings. + === 4.3.7 / 2016-01-26 * Fix regression in help formatter introduced in 4.3.6. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-01-27 01:55:01.000000000 +0100 +++ new/README.md 2016-02-19 22:39:21.000000000 +0100 @@ -37,6 +37,10 @@ $ commander init yourfile.rb +To generate a quick modular style template for a commander app, run: + + $ commander init --modular yourfile.rb + ## Example For more option examples view the `Commander::Command#option` method. Also diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bin/commander new/bin/commander --- old/bin/commander 2016-01-27 01:55:01.000000000 +0100 +++ new/bin/commander 2016-02-19 22:39:21.000000000 +0100 @@ -8,30 +8,78 @@ program :description, 'Commander utility program.' command :init do |c| - c.syntax = 'commander init <file>' + c.syntax = 'commander init [option] <file>' c.summary = 'Initialize a commander template' c.description = 'Initialize an empty <file> with a commander template, allowing very quick creation of commander executables.' - c.example 'Create a new file with a commander template.', 'commander init bin/my_executable' - c.action do |args, _options| + c.example 'Create a new classic style template file.', 'commander init bin/my_executable' + c.example 'Create a new modular style template file.', 'commander init --modular bin/my_executable' + c.option '-m', '--modular', 'Initialize a modular style template' + c.action do |args, options| file = args.shift || abort('file argument required.') name = ask 'Machine name of program: ' description = ask 'Describe your program: ' commands = ask_for_array 'List the commands you wish to create: ' begin - File.open(file, 'w') do |f| - f.write <<-"...".gsub!(/^ {10}/, '') + if options.modular + File.open(file, 'w') do |f| + f.write <<-"...".gsub!(/^ {10}/, '') + #!/usr/bin/env ruby + + require 'rubygems' + require 'commander' + + class MyApplication + include Commander::Methods + # include whatever modules you need + + def run + program :name, '#{name}' + program :version, '0.0.1' + program :description, '#{description}' + + ... + commands.each do |command| + f.write <<-"...".gsub!(/^ {12}/, '') + command :#{command} do |c| + c.syntax = '#{name} #{command} [options]' + c.summary = '' + c.description = '' + c.example 'description', 'command example' + c.option '--some-switch', 'Some switch that does something' + c.action do |args, options| + # Do something or c.when_called #{name.capitalize}::Commands::#{command.capitalize} + end + end + + ... + end + f.write <<-"...".gsub!(/^ {12}/, '') + run! + end + end + + MyApplication.new.run if $0 == __FILE__ + ... + end + + File.chmod(0755, file) + say "Initialized modular template in #{file}" + else + File.open(file, 'w') do |f| + f.write <<-"...".gsub!(/^ {10}/, '') #!/usr/bin/env ruby require 'rubygems' require 'commander/import' + program :name, '#{name}' program :version, '0.0.1' program :description, '#{description}' - ... - commands.each do |command| - f.write <<-"...".gsub!(/^ {12}/, '') + ... + commands.each do |command| + f.write <<-"...".gsub!(/^ {12}/, '') command :#{command} do |c| c.syntax = '#{name} #{command} [options]' c.summary = '' @@ -43,11 +91,12 @@ end end - ... + ... + end end + File.chmod 0755, file + say "Initialized template in #{file}" end - File.chmod 0755, file - say "Initialized template in #{file}" rescue => e abort e end Files old/checksums.yaml.gz and new/checksums.yaml.gz differ 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 2016-01-27 01:55:01.000000000 +0100 +++ new/lib/commander/runner.rb 2016-02-19 22:39:21.000000000 +0100 @@ -335,9 +335,11 @@ switches.map! { |s| s[0, s.index('=') || s.index(' ') || s.length] } end + switches = expand_optionally_negative_switches(switches) + past_switch, arg_removed = false, false args.delete_if do |arg| - if switches.any? { |s| arg[0, s.length] == s } + if switches.any? { |s| s[0, arg.length] == arg } arg_removed = !switch_has_arg past_switch = true elsif past_switch && !arg_removed && arg !~ /^-/ @@ -349,6 +351,20 @@ end end end + + # expand switches of the style '--[no-]blah' into both their + # '--blah' and '--no-blah' variants, so that they can be + # properly detected and removed + def expand_optionally_negative_switches(switches) + switches.reduce([]) do |memo, val| + if val =~ /\[no-\]/ + memo << val.gsub(/\[no-\]/, '') + memo << val.gsub(/\[no-\]/, 'no-') + else + memo << val + end + end + end ## # Parse global command options. 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 2016-01-27 01:55:01.000000000 +0100 +++ new/lib/commander/user_interaction.rb 2016-02-19 22:39:21.000000000 +0100 @@ -329,8 +329,8 @@ [Float, Integer, String, Symbol, Regexp, Array, File, Pathname] + # All Classes that respond to #parse Object.constants.map do |const| - # const_get(:TimeoutError) issues a deprecation warning on ruby 2.3.0 - Object.const_get(const) unless const == :TimeoutError + # Ignore constants that trigger deprecation warnings + Object.const_get(const) unless [:Config, :TimeoutError].include?(const) end.select do |const| const.class == Class && const.respond_to?(:parse) 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 2016-01-27 01:55:01.000000000 +0100 +++ new/lib/commander/version.rb 2016-02-19 22:39:21.000000000 +0100 @@ -1,3 +1,3 @@ module Commander - VERSION = '4.3.7' + VERSION = '4.4.0' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-01-27 01:55:01.000000000 +0100 +++ new/metadata 2016-02-19 22:39:21.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: commander version: !ruby/object:Gem::Version - version: 4.3.7 + version: 4.4.0 platform: ruby authors: - TJ Holowaychuk @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-01-27 00:00:00.000000000 Z +date: 2016-02-19 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: highline 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 2016-01-27 01:55:01.000000000 +0100 +++ new/spec/runner_spec.rb 2016-02-19 22:39:21.000000000 +0100 @@ -110,6 +110,28 @@ end.run! expect(quiet).to be true end + + it 'should be inherited by commands when the positive form of a [no-] option' do + quiet = nil + new_command_runner 'foo', '--quiet' do + global_option('--[no-]quiet', 'Suppress output') {} + command :foo do |c| + c.when_called { |_, options| quiet = options.quiet } + end + end.run! + expect(quiet).to be true + end + + it 'should be inherited by commands when the negative form of a [no-] option' do + quiet = nil + new_command_runner 'foo', '--no-quiet' do + global_option('--[no-]quiet', 'Suppress output') {} + command :foo do |c| + c.when_called { |_, options| quiet = options.quiet } + end + end.run! + expect(quiet).to be false + end end describe '#parse_global_options' do @@ -270,6 +292,40 @@ command_runner.remove_global_options options, args expect(args).to eq(%w(alpha beta)) end + + it 'should remove a switch that is the positive form of the [no-] option' do + options, args = [], [] + options << { switches: ['-g', '--[no-]good'] } + options << { switches: ['-y', '--yes ARG'] } + options << { switches: ['-a', '--alternative=ARG'] } + args << '--good' << 'alpha' + args << '--yes' << 'deleted' + args << '-a' << 'deleted' + args << 'beta' + command_runner.remove_global_options options, args + expect(args).to eq(%w(alpha beta)) + end + + it 'should remove a switch that is the negative form of the [no-] option' do + options, args = [], [] + options << { switches: ['-g', '--[no-]good'] } + options << { switches: ['-y', '--yes ARG'] } + options << { switches: ['-a', '--alternative=ARG'] } + args << '--no-good' << 'alpha' + args << '--yes' << 'deleted' + args << '-a' << 'deleted' + args << 'beta' + command_runner.remove_global_options options, args + expect(args).to eq(%w(alpha beta)) + end + + it 'should not remove options that start with a global option name' do + options, args = [], [] + options << { switches: ['-v', '--version'] } + args << '--versionCode' << 'something' + command_runner.remove_global_options options, args + expect(args).to eq(%w(--versionCode something)) + end end describe '--trace' do
