Hello community, here is the log from the commit of package rubygem-slop for openSUSE:Factory checked in at 2017-12-07 13:51:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-slop (Old) and /work/SRC/openSUSE:Factory/.rubygem-slop.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-slop" Thu Dec 7 13:51:18 2017 rev:21 rq:533900 version:4.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-slop/rubygem-slop.changes 2017-06-08 15:00:23.717106049 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-slop.new/rubygem-slop.changes 2017-12-07 13:51:22.570649523 +0100 @@ -1,0 +2,12 @@ +Wed Oct 11 06:18:38 UTC 2017 - [email protected] + +- updated to version 4.6.0 + see installed CHANGELOG.md + + v4.6.0 (2017-10-06) + ------------------- + + Features + * Add support for required options. #218 (William Woodruff) + +------------------------------------------------------------------- Old: ---- slop-4.5.0.gem New: ---- slop-4.6.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-slop.spec ++++++ --- /var/tmp/diff_new_pack.KNSdcN/_old 2017-12-07 13:51:25.786532402 +0100 +++ /var/tmp/diff_new_pack.KNSdcN/_new 2017-12-07 13:51:25.790532256 +0100 @@ -24,7 +24,7 @@ # Name: rubygem-slop -Version: 4.5.0 +Version: 4.6.0 Release: 0 %define mod_name slop %define mod_full_name %{mod_name}-%{version} @@ -33,7 +33,7 @@ BuildRequires: %{rubygem gem2rpm} BuildRequires: ruby-macros >= 5 Url: http://github.com/leejarvis/slop -Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source: https://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: Simple Lightweight Option Parsing License: MIT ++++++ slop-4.5.0.gem -> slop-4.6.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2017-05-22 21:29:25.000000000 +0200 +++ new/.travis.yml 2017-10-06 14:34:48.000000000 +0200 @@ -7,7 +7,7 @@ - 2.2 - 2.3.4 - 2.4.1 - - jruby-9.1.8.0 + - jruby-9.1.13.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 2017-05-22 21:29:25.000000000 +0200 +++ new/CHANGELOG.md 2017-10-06 14:34:48.000000000 +0200 @@ -1,6 +1,12 @@ Changelog ========= +v4.6.0 (2017-10-06) +------------------- + +Features + * Add support for required options. #218 (William Woodruff) + v4.5.0 (2017-05-22) ------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2017-05-22 21:29:25.000000000 +0200 +++ new/README.md 2017-10-06 14:34:48.000000000 +0200 @@ -20,6 +20,7 @@ opts = Slop.parse do |o| o.string '-h', '--host', 'a hostname' o.integer '--port', 'custom port', default: 80 + o.string '-l', '--login', required: true o.bool '-v', '--verbose', 'enable verbose mode' o.bool '-q', '--quiet', 'suppress output (quiet mode)' o.bool '-c', '--check-ssl-certificate', 'check SSL certificate for host' @@ -39,6 +40,12 @@ opts.to_hash #=> { host: "192.168.0.1", port: 80, verbose: true, quiet: false, check_ssl_certificate: true } ``` +Note that the block we've added to the `--version` flag will be executed +during parse time. Therefore these blocks should be reserved +for immediately reacting to the presence of a flag. If you want to +access other options or mutate values, check out the "Custom option types" +section below and implement the `#finish` method. + Option types ------------ @@ -191,6 +198,7 @@ * An option used without an argument when it expects one: `Slop::MissingArgument` * An option used that Slop doesn't know about: `Slop::UnknownOption` +* An option marked as `required` when not provided: `Slop::MissingRequiredOption` These errors inherit from `Slop::Error`, so you can rescue them all. Alternatively you can suppress these errors with the `suppress_errors` config 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 2017-05-22 21:29:25.000000000 +0200 +++ new/lib/slop/error.rb 2017-10-06 14:34:48.000000000 +0200 @@ -32,4 +32,9 @@ @flag = flag end end + + # Raised when a required option is *not* parsed. + # Suppress with the `suppress_errors` config option. + class MissingRequiredOption < Error + end end 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 2017-05-22 21:29:25.000000000 +0200 +++ new/lib/slop/option.rb 2017-10-06 14:34:48.000000000 +0200 @@ -4,6 +4,7 @@ help: true, tail: false, underscore_flags: true, + required: false, } # An Array of flags this option matches. @@ -101,6 +102,11 @@ config[:suppress_errors] end + # Returns true if an exception should be raised when this option isn't supplied. + def required? + config[:required] + end + # Returns all flags joined by a comma. Used by the help string. def flag flags.join(", ") 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 2017-05-22 21:29:25.000000000 +0200 +++ new/lib/slop/parser.rb 2017-10-06 14:34:48.000000000 +0200 @@ -80,6 +80,15 @@ @arguments += ignored_args + if !suppress_errors? + unused_options.each do |o| + if o.config[:required] + pretty_flags = o.flags.map { |f| "`#{f}'" }.join(", ") + raise MissingRequiredOption, "missing required option #{pretty_flags}" + end + end + end + Result.new(self).tap do |result| used_options.each { |o| o.finish(result) } end @@ -148,6 +157,7 @@ def partition(strings) if strings.include?("--") partition_idx = strings.index("--") + return [[], strings[1..-1]] if partition_idx.zero? [strings[0..partition_idx-1], strings[partition_idx+1..-1]] else [strings, []] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/slop.rb new/lib/slop.rb --- old/lib/slop.rb 2017-05-22 21:29:25.000000000 +0200 +++ new/lib/slop.rb 2017-10-06 14:34:48.000000000 +0200 @@ -6,7 +6,7 @@ require 'slop/error' module Slop - VERSION = '4.5.0' + VERSION = '4.6.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 2017-05-22 21:29:25.000000000 +0200 +++ new/metadata 2017-10-06 14:34:48.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: slop version: !ruby/object:Gem::Version - version: 4.5.0 + version: 4.6.0 platform: ruby authors: - Lee Jarvis autorequire: bindir: bin cert_chain: [] -date: 2017-05-22 00:00:00.000000000 Z +date: 2017-10-06 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.1 +rubygems_version: 2.6.13 signing_key: specification_version: 4 summary: Simple Lightweight Option Parsing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/error_test.rb new/test/error_test.rb --- old/test/error_test.rb 2017-05-22 21:29:25.000000000 +0200 +++ new/test/error_test.rb 2017-10-06 14:34:48.000000000 +0200 @@ -21,6 +21,12 @@ opts.string "-n", "--name" opts.parse %w(--name) end + + it "does not raise if '--' appears as the first argument" do + opts = Slop::Options.new + opts.string "-n", "--name" + opts.parse %w(-- --name) + end end describe Slop::UnknownOption do @@ -43,3 +49,17 @@ opts.parse %w(--foo) end end + +describe Slop::MissingRequiredOption do + it "raises when a required option is missing" do + opts = Slop::Options.new + opts.string "-n", "--name", required: true + assert_raises(Slop::MissingRequiredOption) { opts.parse [] } + end + + it "does not raise when errors are suppressed" do + opts = Slop::Options.new(suppress_errors: true) + opts.string "-n", "--name", required: true + opts.parse [] + end +end
