Hello community, here is the log from the commit of package rubygem-slop for openSUSE:Factory checked in at 2017-06-08 15:00:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-slop (Old) and /work/SRC/openSUSE:Factory/.rubygem-slop.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-slop" Thu Jun 8 15:00:22 2017 rev:20 rq:497679 version:4.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-slop/rubygem-slop.changes 2016-10-10 16:22:38.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-slop.new/rubygem-slop.changes 2017-06-08 15:00:23.717106049 +0200 @@ -1,0 +2,26 @@ +Tue May 23 10:22:40 UTC 2017 - [email protected] + +- updated to version 4.5.0 + see installed CHANGELOG.md + + v4.5.0 (2017-05-22) + ------------------- + + Features: + * Added config option to avoid translating flags-with-dashes into + underscores. #206 (@lbriais) + + v4.4.3 (2017-05-02) + ------------------- + + Bug fixes: + * Ruby 2.0.0 support broken in v4.4.2 + + v4.4.2 (2017-04-29) + ------------------- + + Bug fixes: + * Fix support for parsing -x5 or -nfoo. #199 + * Fix removing arguments after `--`. #194 + +------------------------------------------------------------------- Old: ---- slop-4.4.1.gem New: ---- slop-4.5.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-slop.spec ++++++ --- /var/tmp/diff_new_pack.a4bVGT/_old 2017-06-08 15:00:25.392869546 +0200 +++ /var/tmp/diff_new_pack.a4bVGT/_new 2017-06-08 15:00:25.396868981 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-slop # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-slop -Version: 4.4.1 +Version: 4.5.0 Release: 0 %define mod_name slop %define mod_full_name %{mod_name}-%{version} ++++++ slop-4.4.1.gem -> slop-4.5.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2016-08-21 15:52:42.000000000 +0200 +++ new/.travis.yml 2017-05-22 21:29:25.000000000 +0200 @@ -1,18 +1,15 @@ cache: bundler before_install: - - gem update bundler + - gem install bundler rvm: - 2.0.0 - 2.1 - 2.2 - - 2.3.0 - - rbx-2 + - 2.3.4 + - 2.4.1 + - jruby-9.1.8.0 - jruby-head - ruby-head -matrix: - allow_failures: - - rvm: ruby-head - - rvm: jruby-head notifications: email: on_success: change diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-08-21 15:52:42.000000000 +0200 +++ new/CHANGELOG.md 2017-05-22 21:29:25.000000000 +0200 @@ -1,6 +1,26 @@ Changelog ========= +v4.5.0 (2017-05-22) +------------------- + +Features: + * Added config option to avoid translating flags-with-dashes into + underscores. #206 (@lbriais) + +v4.4.3 (2017-05-02) +------------------- + +Bug fixes: + * Ruby 2.0.0 support broken in v4.4.2 + +v4.4.2 (2017-04-29) +------------------- + +Bug fixes: + * Fix support for parsing -x5 or -nfoo. #199 + * Fix removing arguments after `--`. #194 + v4.4.1 (2016-08-21) ------------------- Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop/option.rb new/lib/slop/option.rb --- old/lib/slop/option.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/lib/slop/option.rb 2017-05-22 21:29:25.000000000 +0200 @@ -3,6 +3,7 @@ DEFAULT_CONFIG = { help: true, tail: false, + underscore_flags: true, } # An Array of flags this option matches. @@ -107,7 +108,14 @@ # Returns the last key as a symbol. Used in Options.to_hash. def key - (config[:key] || flags.last.sub(/\A--?/, '')).tr("-", "_").to_sym + key = config[:key] || flags.last.sub(/\A--?/, '') + key = key.tr '-', '_' if underscore_flags? + key.to_sym + end + + # Returns true if this option should be displayed with dashes transformed into underscores. + def underscore_flags? + config[:underscore_flags] end # Returns true if this option should be displayed in help text. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop/options.rb new/lib/slop/options.rb --- old/lib/slop/options.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/lib/slop/options.rb 2017-05-22 21:29:25.000000000 +0200 @@ -3,9 +3,10 @@ include Enumerable DEFAULT_CONFIG = { - suppress_errors: false, - type: "null", - banner: true, + suppress_errors: false, + type: "null", + banner: true, + underscore_flags: true, } # The Array of Option instances we've created. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop/parser.rb new/lib/slop/parser.rb --- old/lib/slop/parser.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/lib/slop/parser.rb 2017-05-22 21:29:25.000000000 +0200 @@ -36,6 +36,9 @@ def parse(strings) reset # reset before every parse + # ignore everything after "--" + strings, ignored_args = partition(strings) + pairs = strings.each_cons(2).to_a # this ensures we still support the last string being a flag, # otherwise it'll only be used as an argument. @@ -47,12 +50,6 @@ flag, arg = pair break if !flag - # ignore everything after '--', flag or not - if flag == '--' - arguments.delete(flag) - break - end - # support `foo=bar` orig_flag = flag.dup orig_arg = arg @@ -81,6 +78,8 @@ end end + @arguments += ignored_args + Result.new(self).tap do |result| used_options.each { |o| o.finish(result) } end @@ -111,13 +110,7 @@ elsif flag.start_with?("--no-") && option = matching_option(flag.sub("no-", "")) process(option, false) elsif flag =~ /\A-[^-]{2,}/ - # try and process as a set of grouped short flags. drop(1) removes - # the prefixed -, then we add them back to each flag separately. - flags = flag.split("").drop(1).map { |f| "-#{f}" } - last = flags.pop - - flags.each { |f| try_process(f, nil) } - try_process(last, arg) # send the argument to the last flag + try_process_smashed_arg(flag) || try_process_grouped_flags(flag, arg) else if flag.start_with?("-") && !suppress_errors? raise UnknownOption.new("unknown option `#{flag}'", "#{flag}") @@ -125,6 +118,25 @@ end end + # try and process a flag with a "smashed" argument, e.g. + # -nFoo or -i5 + def try_process_smashed_arg(flag) + option = matching_option(flag[0, 2]) + if option && option.expects_argument? + process(option, flag[2..-1]) + end + end + + # try and process as a set of grouped short flags. drop(1) removes + # the prefixed -, then we add them back to each flag separately. + def try_process_grouped_flags(flag, arg) + flags = flag.split("").drop(1).map { |f| "-#{f}" } + last = flags.pop + + flags.each { |f| try_process(f, nil) } + try_process(last, arg) # send the argument to the last flag + end + def suppress_errors? config[:suppress_errors] end @@ -132,5 +144,14 @@ def matching_option(flag) options.find { |o| o.flags.include?(flag) } end + + def partition(strings) + if strings.include?("--") + partition_idx = strings.index("--") + [strings[0..partition_idx-1], strings[partition_idx+1..-1]] + else + [strings, []] + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop/result.rb new/lib/slop/result.rb --- old/lib/slop/result.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/lib/slop/result.rb 2017-05-22 21:29:25.000000000 +0200 @@ -33,7 +33,11 @@ # Returns an Option if it exists. Ignores any prefixed hyphens. def option(flag) - cleaned = -> (f) { f.to_s.sub(/\A--?/, '').tr('_', '-') } + cleaned = -> (f) do + key = f.to_s.sub(/\A--?/, '') + key = key.tr '-', '_' if parser.config[:underscore_flags] + key.to_sym + end options.find do |o| o.flags.any? { |f| cleaned.(f) == cleaned.(flag) } end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop.rb new/lib/slop.rb --- old/lib/slop.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/lib/slop.rb 2017-05-22 21:29:25.000000000 +0200 @@ -6,7 +6,7 @@ require 'slop/error' module Slop - VERSION = '4.4.1' + VERSION = '4.5.0' # Parse an array of options (defaults to ARGV). Accepts an # optional hash of configuration options and block. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-08-21 15:52:42.000000000 +0200 +++ new/metadata 2017-05-22 21:29:25.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: slop version: !ruby/object:Gem::Version - version: 4.4.1 + version: 4.5.0 platform: ruby authors: - Lee Jarvis autorequire: bindir: bin cert_chain: [] -date: 2016-08-21 00:00:00.000000000 Z +date: 2017-05-22 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -100,4 +100,3 @@ - test/slop_test.rb - test/test_helper.rb - test/types_test.rb -has_rdoc: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/option_test.rb new/test/option_test.rb --- old/test/option_test.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/test/option_test.rb 2017-05-22 21:29:25.000000000 +0200 @@ -21,6 +21,10 @@ assert_equal :foo_bar, option(%w(-f --foo-bar), nil).key end + it "when specified, it won't convert dashes to underscores to make multi-word options symbol-friendly" do + assert_equal :'foo-bar', option(%w(-f --foo-bar), nil, underscore_flags: false).key + end + it "can be overridden" do assert_equal :bar, option(%w(-f --foo), nil, key: "bar").key end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/parser_test.rb new/test/parser_test.rb --- old/test/parser_test.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/test/parser_test.rb 2017-05-22 21:29:25.000000000 +0200 @@ -11,8 +11,9 @@ end it "ignores everything after --" do - @parser.parse %w(-v -- --name lee) + @parser.parse %w(-v -- -v --name lee) assert_equal [@verbose], @parser.used_options + assert_equal ["-v", "--name", "lee"], @parser.arguments end it "parses flag=argument" do @@ -66,6 +67,19 @@ end end + describe "short flags with arguments" do + before do + @options.integer "-i" + @options.string "-s" + end + + it "parses the argument" do + @result.parser.parse %w(-i5 -sfoo) + assert_equal 5, @result[:i] + assert_equal "foo", @result[:s] + end + end + describe "#used_options" do it "returns all options that were parsed" do assert_equal [@verbose, @name], @parser.used_options diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/result_test.rb new/test/result_test.rb --- old/test/result_test.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/test/result_test.rb 2017-05-22 21:29:25.000000000 +0200 @@ -97,7 +97,7 @@ end it "returns nil if nothing is found" do - assert_equal nil, @result.option("foo") + assert_nil @result.option("foo") end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/slop_test.rb new/test/slop_test.rb --- old/test/slop_test.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/test/slop_test.rb 2017-05-22 21:29:25.000000000 +0200 @@ -7,7 +7,7 @@ end it "returns false if the option is not defined" do - assert_equal false, Slop.option_defined?("Foo") + assert_equal false, Slop.option_defined?("FooBar") end it "returns true if the option is defined" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/types_test.rb new/test/types_test.rb --- old/test/types_test.rb 2016-08-21 15:52:42.000000000 +0200 +++ new/test/types_test.rb 2017-05-22 21:29:25.000000000 +0200 @@ -41,7 +41,7 @@ it "returns nil for non-numbers by default" do @result.parser.parse %w(--age hello) - assert_equal nil, @result[:age] + assert_nil @result[:age] end end @@ -59,7 +59,7 @@ it "returns nil for non-numbers by default" do @result.parser.parse %w(--apr hello) - assert_equal nil, @result[:apr] + assert_nil @result[:apr] end end
