Hello community,
here is the log from the commit of package rubygem-slop for openSUSE:Factory checked in at 2019-08-06 15:10:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-slop (Old)
and /work/SRC/openSUSE:Factory/.rubygem-slop.new.4126 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-slop"
Tue Aug 6 15:10:43 2019 rev:24 rq:717323 version:4.7.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-slop/rubygem-slop.changes 2018-07-18 22:52:29.063250498 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-slop.new.4126/rubygem-slop.changes 2019-08-06 15:10:44.547764418 +0200
@@ -1,0 +2,15 @@
+Fri Jul 19 09:37:55 UTC 2019 - Stephan Kulow
+
+- updated to version 4.7.0
+ see installed CHANGELOG.md
+
+ v4.7.0 (2019-06-29)
+ -------------------
+
+ Features:
+ * Add `Slop::Result#fetch`. It returns the value of given option, or raises an error if given option is not present. [#232](https://github.com/leejarvis/slop/pull/232) ([Giovanni Benussi](https://github.com/giovannibenussi))
+ * Adding a separator without passing any arguments now creates a separator with the empty string. [#238](https://github.com/leejarvis/slop/pull/238) ([Teemu Matilainen](https://github.com/tmatilai))
+ Bug fixes
+ * Ensure non-string option types have their flags consumed properly [#241] (Sutou Kouhei)
+
+-------------------------------------------------------------------
Old:
----
slop-4.6.2.gem
New:
----
slop-4.7.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-slop.spec ++++++
--- /var/tmp/diff_new_pack.dBARlo/_old 2019-08-06 15:10:45.199764116 +0200
+++ /var/tmp/diff_new_pack.dBARlo/_new 2019-08-06 15:10:45.199764116 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-slop
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 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
@@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@@ -24,7 +24,7 @@
#
Name: rubygem-slop
-Version: 4.6.2
+Version: 4.7.0
Release: 0
%define mod_name slop
%define mod_full_name %{mod_name}-%{version}
++++++ slop-4.6.2.gem -> slop-4.7.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml 2018-03-12 15:16:07.000000000 +0100
+++ new/.travis.yml 2019-06-29 16:39:12.000000000 +0200
@@ -1,13 +1,22 @@
cache: bundler
before_install:
- - gem install bundler
+ - |
+ export RVM_CURRENT=`rvm current|cut -c6-8`
+ if [ "${RVM_CURRENT}" = "2.0" ] || \
+ [ "${RVM_CURRENT}" = "2.1" ] || \
+ [ "${RVM_CURRENT}" = "2.2" ]; then
+ gem install bundler -v '< 2'
+ fi
+
rvm:
- 2.0.0
- 2.1
- 2.2
- 2.3.4
- 2.4.1
- - jruby-9.1.13.0
+ - 2.5.3
+ - 2.6.0
+ - jruby-9.2.5.0
- jruby-head
- ruby-head
notifications:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2018-03-12 15:16:07.000000000 +0100
+++ new/CHANGELOG.md 2019-06-29 16:39:12.000000000 +0200
@@ -1,31 +1,42 @@
Changelog
=========
+v4.7.0 (2019-06-29)
+-------------------
+
+Features:
+ * Add `Slop::Result#fetch`. It returns the value of given option, or raises an error if given option is not present. [#232](https://github.com/leejarvis/slop/pull/232) ([Giovanni Benussi](https://github.com/giovannibenussi))
+ * Adding a separator without passing any arguments now creates a separator with the empty string. [#238](https://github.com/leejarvis/slop/pull/238) ([Teemu Matilainen](https://github.com/tmatilai))
+Bug fixes
+ * Ensure non-string option types have their flags consumed properly [#241] (Sutou Kouhei)
+
+
v4.6.2 (2018-03-12)
+-------------------
Bug fixes/Enhancements
- * Fix equals character (=) being parsed incorrectly in some cases. #226
+ * Fix equals character (=) being parsed incorrectly in some cases. [#226](https://github.com/leejarvis/slop/issues/226)
v4.6.1 (2017-11-20)
-------------------
Bug fixes/Enhancements
- * Fix separator so it doesn't mutate user data. #223 (Marc-André Lafortune)
+ * Fix separator so it doesn't mutate user data. [#223](https://github.com/leejarvis/slop/issues/223) (Marc-André Lafortune)
* Add additional tests for `Options#separator` and fix issue where
- the last separator was ignored. #222
+ the last separator was ignored. [#222](https://github.com/leejarvis/slop/issues/222)
v4.6.0 (2017-10-06)
-------------------
Features
- * Add support for required options. #218 (William Woodruff)
+ * Add support for required options. [#218](https://github.com/leejarvis/slop/issues/218) (William Woodruff)
v4.5.0 (2017-05-22)
-------------------
Features:
* Added config option to avoid translating flags-with-dashes into
- underscores. #206 (@lbriais)
+ underscores. [#206](https://github.com/leejarvis/slop/issues/206) (@lbriais)
v4.4.3 (2017-05-02)
-------------------
@@ -37,73 +48,73 @@
-------------------
Bug fixes:
- * Fix support for parsing -x5 or -nfoo. #199
- * Fix removing arguments after `--`. #194
+ * Fix support for parsing -x5 or -nfoo. [#199](https://github.com/leejarvis/slop/issues/199)
+ * Fix removing arguments after `--`. [#194](https://github.com/leejarvis/slop/issues/194)
v4.4.1 (2016-08-21)
-------------------
Bug fixes:
- * Handle bad constant names in `Slop.option_defined?`. #198
+ * Handle bad constant names in `Slop.option_defined?`. [#198](https://github.com/leejarvis/slop/issues/198)
(Ellen Marie Dash)
v4.4.0 (2016-08-15)
-------------------
Features
- * Support parsing arguments prefixed with dashes. #192 (Andrew Clemons)
+ * Support parsing arguments prefixed with dashes. [#192](https://github.com/leejarvis/slop/issues/192) (Andrew Clemons)
Bug fixes:
- * Retain sort order inside tail sort. #193 (Caio Chassot)
+ * Retain sort order inside tail sort. [#193](https://github.com/leejarvis/slop/issues/193) (Caio Chassot)
v4.3.0 (2016-03-19)
-------------------
Features
- * Allow disabling array delimiter. #189 (Mike Pastore)
- * Allow passing custom banner as config. #191 (Philip Rees)
+ * Allow disabling array delimiter. [#189](https://github.com/leejarvis/slop/issues/189) (Mike Pastore)
+ * Allow passing custom banner as config. [#191](https://github.com/leejarvis/slop/issues/191) (Philip Rees)
v4.2.1 (2015-11-25)
-------------------
Features:
- * Better handling of option names with multiple words. #169 (Tim Rogers)
+ * Better handling of option names with multiple words. [#169](https://github.com/leejarvis/slop/issues/169) (Tim Rogers)
Minor enhancements:
- * add ARGF notes to Arguments (README). #173 (Rick Hull)
+ * add ARGF notes to Arguments (README). [#173](https://github.com/leejarvis/slop/issues/173) (Rick Hull)
Bug fixes:
- * Fix arguments removed with option arguments. #182 (Naoki Mizuno)
+ * Fix arguments removed with option arguments. [#182](https://github.com/leejarvis/slop/issues/182) (Naoki Mizuno)
* Fix bug where true is passed to BoolOption block regardless
- of --no- prefix. #184 (Ben Brady)
- * only raise MissingArgument if not `default_value`. #163 (Ben Brady)
+ of --no- prefix. [#184](https://github.com/leejarvis/slop/issues/184) (Ben Brady)
+ * only raise MissingArgument if not `default_value`. [#163](https://github.com/leejarvis/slop/issues/163) (Ben Brady)
v4.2.0 (2015-04-18)
-------------------
Features:
- * Support for Regexp option type #167 (Laurent Arnoud)
+ * Support for Regexp option type [#167](https://github.com/leejarvis/slop/issues/167) (Laurent Arnoud)
* Support prefixed `--no-` for explicitly setting boolean options
- to `false` #168
- * Better handling of flags with multiple words #169 (Tim Rogers)
+ to `false` [#168](https://github.com/leejarvis/slop/issues/168)
+ * Better handling of flags with multiple words [#169](https://github.com/leejarvis/slop/issues/169) (Tim Rogers)
v4.1.0 (2015-04-18)
-------------------
Features:
- * Support for FloatOption #156 (Rick Hull)
+ * Support for FloatOption [#156](https://github.com/leejarvis/slop/issues/156) (Rick Hull)
* Support for `limit` config to ArrayOption.
* Support for `tail` config to add options to the bottom of
the help text.
- * Add explicit setter (#[]=) to Result class. #162
+ * Add explicit setter (#[]=) to Result class. [#162](https://github.com/leejarvis/slop/issues/162)
* Implement flag gettings for UnknownOption and MissingArgument
- error classes. #165 (sigurdsvela)
+ error classes. [#165](https://github.com/leejarvis/slop/issues/165) (sigurdsvela)
Minor enhancements:
* Reset parser every time `parse` is called.
Bug fixes:
- * Remove "--" from unprocessed arguments #157 (David Rodríguez).
+ * Remove "--" from unprocessed arguments [#157](https://github.com/leejarvis/slop/issues/157) (David Rodríguez).
v4.0.0 (2014-12-27)
-------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2018-03-12 15:16:07.000000000 +0100
+++ new/README.md 2019-06-29 16:39:12.000000000 +0200
@@ -276,16 +276,14 @@
--------
As of version 4, Slop does not have built in support for git-style subcommands.
-You can use version 3 of Slop (see `v3` branch). I also expect there to be some
-external libraries released soon that wrap around Slop to provide support for
-this feature. I'll update this document when that happens.
+You can use version 3 of Slop (see `v3` branch).
Upgrading from version 3
------------------------
-Slop v4 is completely non-backwards compatible. The code has been rewritten
-from the ground up. If you're already using version 3 you *have* to update
-your code to use version 4. Here's an overview of the more fundamental changes:
+Slop v4 is not backwards compatible. The code has been completely rewritten.
+If you're already using version 3 you *have* to update your code to use version 4.
+Here's an overview of the large changes:
#### No more `instance_eval`
@@ -327,22 +325,22 @@
#### No more trailing `=`
-Instead, the "does this option expect an argument" question is answered by
+Instead, the "does this option expect an argument?" question is answered by
the option type (i.e `on` and `bool` options do not expect arguments, all
-others do. They handle type conversion, too.
+others do). They handle type conversion, too.
#### Hyphens are required
This was a hard decision to make, but you must provide prefixed hyphens when
-declaring your flags. This makes the underlying code much nicer and much less
-ambiguous, which leads to less error prone code. It also means you can easily
-support single hyphen prefix for a long flag, i.e `-hostname` which you
-could not do before. It also provides a hidden feature, which is infinity flag
-aliases: `o.string '-f', '-x', '--foo', '--bar', 'this is insane'`
+declaring your flags. This improves the implementation nicer and makes things
+much less ambiguous, which leads to less error prone code. It also means you
+can easily support single hyphen prefix for a long flag, i.e `-hostname` which
+you could not do before. It also means you can provide infinite flag aliases:
+`o.string '-f', '-x', '--foo', '--bar', 'this is insane'`
#### Strict is now on by default
-v3 had a `strict` option. v4 has no such option, and to suppress errors you can
+v3 had a `strict` option. v4 has no such option. To suppress errors you can
instead provide the `suppress_errors: true` option to Slop.
#### No more parse!
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/error.rb new/lib/slop/error.rb
--- old/lib/slop/error.rb 2018-03-12 15:16:07.000000000 +0100
+++ new/lib/slop/error.rb 2019-06-29 16:39:12.000000000 +0200
@@ -22,8 +22,9 @@
end
end
- # Raised when an unknown option is parsed. Suppress
- # with the `suppress_errors` config option.
+ # Raised when an unknown option is parsed or when trying to fetch an
+ # unexisting option via `Slop::Result#fetch`.
+ # Suppress with the `suppress_errors` config option.
class UnknownOption < Error
attr_reader :flag
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 2018-03-12 15:16:07.000000000 +0100
+++ new/lib/slop/options.rb 2019-06-29 16:39:12.000000000 +0200
@@ -59,7 +59,7 @@
# Add a separator between options. Used when displaying
# the help text.
- def separator(string)
+ def separator(string = "")
if separators[options.size]
separators[-1] += "\n#{string}"
else
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 2018-03-12 15:16:07.000000000 +0100
+++ new/lib/slop/parser.rb 2019-06-29 16:39:12.000000000 +0200
@@ -64,7 +64,7 @@
if opt.expects_argument?
# if we consumed the argument, remove the next pair
- if orig_arg == opt.value.to_s
+ if consume_next_argument?(orig_flag)
pairs.delete_at(idx + 1)
end
@@ -106,6 +106,13 @@
private
+ def consume_next_argument?(flag)
+ return false if flag.include?("=")
+ return true if flag.start_with?("--")
+ return true if /\A-[a-zA-Z]\z/ === flag
+ false
+ end
+
# We've found an option, process and return it
def process(option, arg)
option.ensure_call(arg)
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 2018-03-12 15:16:07.000000000 +0100
+++ new/lib/slop/result.rb 2019-06-29 16:39:12.000000000 +0200
@@ -14,12 +14,23 @@
@options = parser.options
end
- # Returns an options value, nil if the option does not exist.
+ # Returns an option's value, nil if the option does not exist.
def [](flag)
(o = option(flag)) && o.value
end
alias get []
+ # Returns an option's value, raises UnknownOption if the option does not exist.
+ def fetch(flag)
+ o = option(flag)
+ if o.nil?
+ cleaned_key = clean_key(flag)
+ raise UnknownOption.new("option not found: '#{cleaned_key}'", "#{cleaned_key}")
+ else
+ o.value
+ end
+ end
+
# Set the value for an option. Raises an ArgumentError if the option
# does not exist.
def []=(flag, value)
@@ -33,13 +44,8 @@
# Returns an Option if it exists. Ignores any prefixed hyphens.
def option(flag)
- 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) }
+ o.flags.any? { |f| clean_key(f) == clean_key(flag) }
end
end
@@ -90,5 +96,13 @@
def to_s(**opts)
options.to_s(**opts)
end
+
+ private
+
+ def clean_key(key)
+ key = key.to_s.sub(/\A--?/, '')
+ key = key.tr '-', '_' if parser.config[:underscore_flags]
+ key.to_sym
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop.rb new/lib/slop.rb
--- old/lib/slop.rb 2018-03-12 15:16:07.000000000 +0100
+++ new/lib/slop.rb 2019-06-29 16:39:12.000000000 +0200
@@ -6,7 +6,7 @@
require 'slop/error'
module Slop
- VERSION = '4.6.2'
+ VERSION = '4.7.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 2018-03-12 15:16:07.000000000 +0100
+++ new/metadata 2019-06-29 16:39:12.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: slop
version: !ruby/object:Gem::Version
- version: 4.6.2
+ version: 4.7.0
platform: ruby
authors:
- Lee Jarvis
autorequire:
bindir: bin
cert_chain: []
-date: 2018-03-12 00:00:00.000000000 Z
+date: 2019-06-29 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rake
@@ -87,7 +87,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.5.2
+rubygems_version: 2.7.6
signing_key:
specification_version: 4
summary: Simple Lightweight Option Parsing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/options_test.rb new/test/options_test.rb
--- old/test/options_test.rb 2018-03-12 15:16:07.000000000 +0100
+++ new/test/options_test.rb 2019-06-29 16:39:12.000000000 +0200
@@ -64,6 +64,12 @@
@options.separator("foo".freeze)
@options.separator("bar".freeze)
end
+
+ it "defaults to empty string" do
+ @options.separator
+
+ assert_equal [""], @options.separators
+ end
end
describe "#method_missing" do
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 2018-03-12 15:16:07.000000000 +0100
+++ new/test/parser_test.rb 2019-06-29 16:39:12.000000000 +0200
@@ -35,6 +35,12 @@
assert_equal "--sometext", @result[:text]
end
+ it "parses regexp arg with leading -" do
+ @options.regexp "--pattern"
+ @result.parser.parse %w(--pattern -x)
+ assert_equal(/-x/, @result[:pattern])
+ end
+
it "parses negative integer" do
@options.integer "-p", "--port"
@result.parser.parse %w(--name=bob --port -123)
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 2018-03-12 15:16:07.000000000 +0100
+++ new/test/result_test.rb 2019-06-29 16:39:12.000000000 +0200
@@ -62,6 +62,31 @@
end
end
+ describe "#fetch" do
+ it "returns an options value" do
+ assert_equal "lee", @result.fetch("--name")
+ end
+
+ it "raises Slop::UnknownOption when an option does not exists" do
+ e = assert_raises(Slop::UnknownOption) { @result.fetch("--unexisting") }
+ assert_equal "option not found: 'unexisting'", e.message
+ end
+
+ it "returns the default value of an option when a value is not provided" do
+ @options.string("--foo", default: "bar")
+ @result.parser.parse %w(--foo)
+
+ assert_equal 'bar', @result.fetch('foo')
+ end
+
+ it "returns nil when an option is not provided and it does not have a default value" do
+ @options.string("--hello")
+ @result.parser.parse %w()
+
+ assert_nil @result.fetch('hello')
+ end
+ end
+
describe "#[]=" do
it "sets an options value" do
assert_equal "lee", @result["name"]