summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlle Jonsson <olle.jonsson@gmail.com>2020-01-07 09:22:32 +0100
committerGitHub <noreply@github.com>2020-01-07 09:22:32 +0100
commit0f5303030c23c9ff106adf413f5e2eb151254ed1 (patch)
tree85d6d56ad8553c64d970f06b2de96f91ad91089c
parentdcb711b8aaa1731bfcc4571f70a8b0f5de87d5da (diff)
parentca1f1cf7169c673ac0942996a1e810383cc6403e (diff)
downloadslop-0f5303030c23c9ff106adf413f5e2eb151254ed1.tar.gz
Merge pull request #248 from jylitalo/ruby_2.7.0
Tests on Ruby 2.7.0: avoid warnings; add 2.7.0 to CI
-rw-r--r--.travis.yml1
-rw-r--r--lib/slop/options.rb8
-rw-r--r--test/option_test.rb4
-rw-r--r--test/options_test.rb4
-rw-r--r--test/types_test.rb2
5 files changed, 10 insertions, 9 deletions
diff --git a/.travis.yml b/.travis.yml
index 38afabf..4573dc8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,6 +16,7 @@ rvm:
- 2.4.9
- 2.5.7
- 2.6.5
+ - 2.7.0
- jruby-9.2.9.0
- jruby-head
- ruby-head
diff --git a/lib/slop/options.rb b/lib/slop/options.rb
index 009964a..9a5f5cc 100644
--- a/lib/slop/options.rb
+++ b/lib/slop/options.rb
@@ -24,12 +24,12 @@ module Slop
# The String banner prefixed to the help string.
attr_accessor :banner
- def initialize(**config)
+ def initialize(**config, &block)
@options = []
@separators = []
@banner = config[:banner].is_a?(String) ? config[:banner] : config.fetch(:banner, "usage: #{$0} [options]")
@config = DEFAULT_CONFIG.merge(config)
- @parser = Parser.new(self, @config)
+ @parser = Parser.new(self, **@config)
yield self if block_given?
end
@@ -52,7 +52,7 @@ module Slop
desc = flags.pop unless flags.last.start_with?('-')
config = self.config.merge(config)
klass = Slop.string_to_option_class(config[:type].to_s)
- option = klass.new(flags, desc, config, &block)
+ option = klass.new(flags, desc, **config, &block)
add_option option
end
@@ -82,7 +82,7 @@ module Slop
def method_missing(name, *args, **config, &block)
if respond_to_missing?(name)
config[:type] = name
- on(*args, config, &block)
+ on(*args, **config, &block)
else
super
end
diff --git a/test/option_test.rb b/test/option_test.rb
index a8db657..4c23401 100644
--- a/test/option_test.rb
+++ b/test/option_test.rb
@@ -1,8 +1,8 @@
require 'test_helper'
describe Slop::Option do
- def option(*args)
- Slop::Option.new(*args)
+ def option(*args, **kwargs, &block)
+ Slop::Option.new(*args, **kwargs, &block)
end
describe "#flag" do
diff --git a/test/options_test.rb b/test/options_test.rb
index f816b74..2f83fc4 100644
--- a/test/options_test.rb
+++ b/test/options_test.rb
@@ -121,11 +121,11 @@ describe Slop::Options do
describe "custom banner" do
it "is prefixed with defined banner" do
- @options_config = Slop::Options.new({banner: "custom banner"})
+ @options_config = Slop::Options.new(**{banner: "custom banner"})
assert_match(/^custom banner/, @options_config.to_s)
end
it "banner is disabled" do
- @options_config = Slop::Options.new({banner: false})
+ @options_config = Slop::Options.new(**{banner: false})
assert_match("", @options_config.to_s)
end
end
diff --git a/test/types_test.rb b/test/types_test.rb
index f6b928e..ff1363c 100644
--- a/test/types_test.rb
+++ b/test/types_test.rb
@@ -39,7 +39,7 @@ describe Slop::IntegerOption do
it "returns the value as an integer" do
assert_equal 20, @result[:age]
- assert_equal -10, @result[:minus]
+ assert_equal (-10), @result[:minus]
assert_equal 30, @result[:plus]
end