diff --git a/contracts-0.16.0.gem b/contracts-0.16.0.gem deleted file mode 100644 index 8a633f113bd120223d91c3ff447e0800fe9977f8..0000000000000000000000000000000000000000 Binary files a/contracts-0.16.0.gem and /dev/null differ diff --git a/contracts-0.17.gem b/contracts-0.17.gem new file mode 100644 index 0000000000000000000000000000000000000000..d7ed5a42f24a32a23111399a822163d1e978cdcb Binary files /dev/null and b/contracts-0.17.gem differ diff --git a/rubygem-contracts-0.16.0-0001-Don-t-use-exceptions-for-control-flow.patch b/rubygem-contracts-0.16.0-0001-Don-t-use-exceptions-for-control-flow.patch deleted file mode 100644 index 5a06144bd13519b1c86e0497e7bf8f6cea7eba90..0000000000000000000000000000000000000000 --- a/rubygem-contracts-0.16.0-0001-Don-t-use-exceptions-for-control-flow.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 726e28c473b8d4453b4485922a2c52e9511bfc42 Mon Sep 17 00:00:00 2001 -From: Chris Seaton -Date: Fri, 10 Nov 2017 17:20:38 +0000 -Subject: [PATCH 1/5] Don't use exceptions for control flow - ---- - lib/contracts/call_with.rb | 22 +++++++++++++-------- - lib/contracts/method_handler.rb | 34 +++++++++++++-------------------- - 2 files changed, 27 insertions(+), 29 deletions(-) - -diff --git a/lib/contracts/call_with.rb b/lib/contracts/call_with.rb -index c8a8b62..2735d1e 100644 ---- a/lib/contracts/call_with.rb -+++ b/lib/contracts/call_with.rb -@@ -1,6 +1,10 @@ - module Contracts - module CallWith - def call_with(this, *args, &blk) -+ call_with_inner(false, this, *args, &blk) -+ end -+ -+ def call_with_inner(returns, this, *args, &blk) - args << blk if blk - - # Explicitly append blk=nil if nil != Proc contract violation anticipated -@@ -16,14 +20,16 @@ module Contracts - validator = @args_validators[i] - - unless validator && validator[arg] -- return unless Contract.failure_callback(:arg => arg, -- :contract => contract, -- :class => klass, -- :method => method, -- :contracts => self, -- :arg_pos => i+1, -- :total_args => args.size, -- :return_value => false) -+ data = {:arg => arg, -+ :contract => contract, -+ :class => klass, -+ :method => method, -+ :contracts => self, -+ :arg_pos => i+1, -+ :total_args => args.size, -+ :return_value => false} -+ return ParamContractError.new("as return value", data) if returns -+ return unless Contract.failure_callback(data) - end - - if contract.is_a?(Contracts::Func) && blk && !nil_block_appended -diff --git a/lib/contracts/method_handler.rb b/lib/contracts/method_handler.rb -index ee16b6b..fe301cd 100644 ---- a/lib/contracts/method_handler.rb -+++ b/lib/contracts/method_handler.rb -@@ -125,31 +125,23 @@ module Contracts - # function. Otherwise we return the result. - # If we run out of functions, we raise the last error, but - # convert it to_contract_error. -- success = false -- i = 0 -- result = nil -+ - expected_error = decorated_methods[0].failure_exception -+ last_error = nil - -- until success -- decorated_method = decorated_methods[i] -- i += 1 -- begin -- success = true -- result = decorated_method.call_with(self, *args, &blk) -- rescue expected_error => error -- success = false -- unless decorated_methods[i] -- begin -- ::Contract.failure_callback(error.data, false) -- rescue expected_error => final_error -- raise final_error.to_contract_error -- end -- end -- end -+ decorated_methods.each do |decorated_method| -+ result = decorated_method.call_with_inner(true, self, *args, &blk) -+ return result unless result.is_a?(ParamContractError) -+ last_error = result - end - -- # Return the result of successfully called method -- result -+ begin -+ if ::Contract.failure_callback(last_error.data, false) -+ decorated_methods.last.call_with_inner(false, self, *args, &blk) -+ end -+ rescue expected_error => final_error -+ raise final_error.to_contract_error -+ end - end - end - --- -2.29.2 - diff --git a/rubygem-contracts-0.16.0-0002-Update-spec-to-specify-error-class-to-suppress-RSpec.patch b/rubygem-contracts-0.16.0-0002-Update-spec-to-specify-error-class-to-suppress-RSpec.patch deleted file mode 100644 index c336695e57c5c8e8e5cfb55103681b7ad87e2c27..0000000000000000000000000000000000000000 --- a/rubygem-contracts-0.16.0-0002-Update-spec-to-specify-error-class-to-suppress-RSpec.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 85c6a4e471f2013079dc5a63c1a6bb84bee9351b Mon Sep 17 00:00:00 2001 -From: PikachuEXE -Date: Mon, 25 Jan 2021 17:26:45 +0800 -Subject: [PATCH 2/5] * Update spec to specify error class to suppress RSpec - warning - ---- - spec/contracts_spec.rb | 6 +++--- - spec/methods_spec.rb | 8 ++++---- - 2 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/spec/contracts_spec.rb b/spec/contracts_spec.rb -index d37c40e..72c8603 100644 ---- a/spec/contracts_spec.rb -+++ b/spec/contracts_spec.rb -@@ -7,7 +7,7 @@ RSpec.describe "Contracts:" do - it "should fail for insufficient arguments" do - expect do - @o.hello -- end.to raise_error -+ end.to raise_error ArgumentError - end - - it "should fail for insufficient contracts" do -@@ -32,7 +32,7 @@ RSpec.describe "Contracts:" do - 1 - end - end -- end.to raise_error -+ end.to raise_error NameError - end - end - -@@ -696,7 +696,7 @@ RSpec.describe "Contracts:" do - it "should apply the contract to an inherited method" do - c = Child.new - expect { c.double(2) }.to_not raise_error -- expect { c.double("asd") }.to raise_error -+ expect { c.double("asd") }.to raise_error ParamContractError - end - end - -diff --git a/spec/methods_spec.rb b/spec/methods_spec.rb -index 334fb4e..d1b5d47 100644 ---- a/spec/methods_spec.rb -+++ b/spec/methods_spec.rb -@@ -36,19 +36,19 @@ RSpec.describe "Contracts:" do - end - - it "should enforce return value inside block with no other parameter" do -- expect { obj.foo(&:to_s) }.to raise_error -+ expect { obj.foo(&:to_s) }.to raise_error ReturnContractError - end - - it "should enforce return value inside block with other parameter" do -- expect { obj.foo2(2) { |x| x.to_s } }.to raise_error -+ expect { obj.foo2(2) { |x| x.to_s } }.to raise_error ReturnContractError - end - - it "should enforce return value inside lambda with no other parameter" do -- expect { obj.bar lambda { |x| x.to_s } }.to raise_error -+ expect { obj.bar lambda { |x| x.to_s } }.to raise_error ReturnContractError - end - - it "should enforce return value inside lambda with other parameter" do -- expect { obj.bar2(2, lambda { |x| x.to_s }) }.to raise_error -+ expect { obj.bar2(2, lambda { |x| x.to_s }) }.to raise_error ReturnContractError - end - end - end --- -2.29.2 - diff --git a/rubygem-contracts-0.16.0-0003-Fix-misspellings-in-comments.patch b/rubygem-contracts-0.16.0-0003-Fix-misspellings-in-comments.patch deleted file mode 100644 index 8ac5b36df483a515de509b83144144a178a36877..0000000000000000000000000000000000000000 --- a/rubygem-contracts-0.16.0-0003-Fix-misspellings-in-comments.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 989ee11906bb2061b2618bd1d8f128162e143a79 Mon Sep 17 00:00:00 2001 -From: Olle Jonsson -Date: Sun, 24 Sep 2017 19:08:58 +0200 -Subject: [PATCH 3/5] Fix misspellings in comments - - - found using find . | misspellings -f - ---- - lib/contracts/call_with.rb | 2 +- - spec/ruby_version_specific/contracts_spec_2.1.rb | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/contracts/call_with.rb b/lib/contracts/call_with.rb -index 2735d1e..c9336a1 100644 ---- a/lib/contracts/call_with.rb -+++ b/lib/contracts/call_with.rb -@@ -80,7 +80,7 @@ module Contracts - # proc, block, lambda, etc - method.call(*args, &blk) - else -- # original method name referrence -+ # original method name reference - added_block = blk ? lambda { |*params| blk.call(*params) } : nil - method.send_to(this, *args, &added_block) - end -diff --git a/spec/ruby_version_specific/contracts_spec_2.1.rb b/spec/ruby_version_specific/contracts_spec_2.1.rb -index 168cfd0..36b6ede 100644 ---- a/spec/ruby_version_specific/contracts_spec_2.1.rb -+++ b/spec/ruby_version_specific/contracts_spec_2.1.rb -@@ -51,7 +51,7 @@ RSpec.describe "Contracts:" do - end.to raise_error(ContractError) - end - -- it "should fail when passed nil to an optional argument which contract shouldnt accept nil" do -+ it "should fail when passed nil to an optional argument which contract shouldn't accept nil" do - expect do - @o.complicated("a", true, :b, :c, 2.0, e: (1..5), f: nil, g: :d) do |x| - x --- -2.29.2 - diff --git a/rubygem-contracts-0.16.0-0004-Wrapping-blocks-only-when-there-is-a-Func-check.-bug.patch b/rubygem-contracts-0.16.0-0004-Wrapping-blocks-only-when-there-is-a-Func-check.-bug.patch deleted file mode 100644 index 04b1d628459d2a8535d9b4ef1639c0048cafe527..0000000000000000000000000000000000000000 --- a/rubygem-contracts-0.16.0-0004-Wrapping-blocks-only-when-there-is-a-Func-check.-bug.patch +++ /dev/null @@ -1,30 +0,0 @@ -From ab30dab081c4e004812eab00a36c70e5b8e4e29b Mon Sep 17 00:00:00 2001 -From: md-work <> -Date: Thu, 14 Dec 2017 11:37:18 +0100 -Subject: [PATCH 4/5] Wrapping &blocks only when there is a Func check. (bug - 278) - ---- - lib/contracts/call_with.rb | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/lib/contracts/call_with.rb b/lib/contracts/call_with.rb -index c9336a1..9252c79 100644 ---- a/lib/contracts/call_with.rb -+++ b/lib/contracts/call_with.rb -@@ -81,8 +81,10 @@ module Contracts - method.call(*args, &blk) - else - # original method name reference -- added_block = blk ? lambda { |*params| blk.call(*params) } : nil -- method.send_to(this, *args, &added_block) -+ # Don't reassign blk, else Travis CI shows "stack level too deep". -+ target_blk = blk -+ target_blk = lambda { |*params| blk.call(*params) } if blk && blk.is_a?(Contract) -+ method.send_to(this, *args, &target_blk) - end - - unless @ret_validator[result] --- -2.29.2 - diff --git a/rubygem-contracts-0.16.0-0005-Update-implementation-spec-to-be-3.0-compatible.patch b/rubygem-contracts-0.16.0-0005-Update-implementation-spec-to-be-3.0-compatible.patch deleted file mode 100644 index 7d79dac55a5ddbe311fa71257d6ae8cf728a6e46..0000000000000000000000000000000000000000 --- a/rubygem-contracts-0.16.0-0005-Update-implementation-spec-to-be-3.0-compatible.patch +++ /dev/null @@ -1,387 +0,0 @@ -From 62ad3fb999287f1495273d4ef41ff6abc28fd278 Mon Sep 17 00:00:00 2001 -From: PikachuEXE -Date: Tue, 26 Jan 2021 17:37:59 +0800 -Subject: [PATCH 5/5] * Update implementation & spec to be 3.0 compatible - -Mainly around the breaking behaviour change about keyword arguments ---- - lib/contracts.rb | 14 ++++----- - lib/contracts/call_with.rb | 31 ++++++++++--------- - lib/contracts/invariants.rb | 10 +++--- - lib/contracts/method_handler.rb | 6 ++-- - lib/contracts/method_reference.rb | 4 +-- - spec/builtin_contracts_spec.rb | 20 +++++------- - spec/contracts_spec.rb | 21 +++++++------ - spec/fixtures/fixtures.rb | 9 ++---- - spec/override_validators_spec.rb | 6 ++-- - .../contracts_spec_2.0.rb | 4 +-- - spec/validators_spec.rb | 2 +- - 11 files changed, 63 insertions(+), 64 deletions(-) - -diff --git a/lib/contracts.rb b/lib/contracts.rb -index baf2acf..f5ae75d 100644 ---- a/lib/contracts.rb -+++ b/lib/contracts.rb -@@ -93,9 +93,9 @@ class Contract < Contracts::Decorator - last_contract = args_contracts.last - penultimate_contract = args_contracts[-2] - @has_options_contract = if @has_proc_contract -- penultimate_contract.is_a?(Hash) || penultimate_contract.is_a?(Contracts::Builtin::KeywordArgs) -+ penultimate_contract.is_a?(Contracts::Builtin::KeywordArgs) - else -- last_contract.is_a?(Hash) || last_contract.is_a?(Contracts::Builtin::KeywordArgs) -+ last_contract.is_a?(Contracts::Builtin::KeywordArgs) - end - # === - -@@ -214,12 +214,12 @@ class Contract < Contracts::Decorator - - # Same thing for when we have named params but didn't pass any in. - # returns true if it appended nil -- def maybe_append_options! args, blk -+ def maybe_append_options! args, kargs, blk - return false unless @has_options_contract -- if @has_proc_contract && (args_contracts[-2].is_a?(Hash) || args_contracts[-2].is_a?(Contracts::Builtin::KeywordArgs)) && !args[-2].is_a?(Hash) -- args.insert(-2, {}) -- elsif (args_contracts[-1].is_a?(Hash) || args_contracts[-1].is_a?(Contracts::Builtin::KeywordArgs)) && !args[-1].is_a?(Hash) -- args << {} -+ if @has_proc_contract && args_contracts[-2].is_a?(Contracts::Builtin::KeywordArgs) -+ args.insert(-2, kargs) -+ elsif args_contracts[-1].is_a?(Contracts::Builtin::KeywordArgs) -+ args << kargs - end - true - end -diff --git a/lib/contracts/call_with.rb b/lib/contracts/call_with.rb -index 9252c79..224b357 100644 ---- a/lib/contracts/call_with.rb -+++ b/lib/contracts/call_with.rb -@@ -1,17 +1,17 @@ - module Contracts - module CallWith -- def call_with(this, *args, &blk) -- call_with_inner(false, this, *args, &blk) -+ def call_with(this, *args, **kargs, &blk) -+ call_with_inner(false, this, *args, **kargs, &blk) - end - -- def call_with_inner(returns, this, *args, &blk) -+ def call_with_inner(returns, this, *args, **kargs, &blk) - args << blk if blk - - # Explicitly append blk=nil if nil != Proc contract violation anticipated - nil_block_appended = maybe_append_block!(args, blk) - - # Explicitly append options={} if Hash contract is present -- maybe_append_options!(args, blk) -+ kargs_appended = maybe_append_options!(args, kargs, blk) - - # Loop forward validating the arguments up to the splat (if there is one) - (@args_contract_index || args.size).times do |i| -@@ -57,14 +57,16 @@ module Contracts - validator = @args_validators[args_contracts.size - 1 - j] - - unless validator && validator[arg] -- return unless Contract.failure_callback(:arg => arg, -- :contract => contract, -- :class => klass, -- :method => method, -- :contracts => self, -- :arg_pos => i-1, -- :total_args => args.size, -- :return_value => false) -+ return unless Contract.failure_callback({ -+ :arg => arg, -+ :contract => contract, -+ :class => klass, -+ :method => method, -+ :contracts => self, -+ :arg_pos => i - 1, -+ :total_args => args.size, -+ :return_value => false, -+ }) - end - - if contract.is_a?(Contracts::Func) -@@ -76,15 +78,16 @@ module Contracts - # If we put the block into args for validating, restore the args - # OR if we added a fake nil at the end because a block wasn't passed in. - args.slice!(-1) if blk || nil_block_appended -+ args.slice!(-1) if kargs_appended - result = if method.respond_to?(:call) - # proc, block, lambda, etc -- method.call(*args, &blk) -+ method.call(*args, **kargs, &blk) - else - # original method name reference - # Don't reassign blk, else Travis CI shows "stack level too deep". - target_blk = blk - target_blk = lambda { |*params| blk.call(*params) } if blk && blk.is_a?(Contract) -- method.send_to(this, *args, &target_blk) -+ method.send_to(this, *args, **kargs, &target_blk) - end - - unless @ret_validator[result] -diff --git a/lib/contracts/invariants.rb b/lib/contracts/invariants.rb -index 56d2d82..215cb89 100644 ---- a/lib/contracts/invariants.rb -+++ b/lib/contracts/invariants.rb -@@ -46,10 +46,12 @@ module Contracts - def check_on(target, method) - return if target.instance_eval(&@condition) - -- self.class.failure_callback(:expected => expected, -- :actual => false, -- :target => target, -- :method => method) -+ self.class.failure_callback({ -+ :expected => expected, -+ :actual => false, -+ :target => target, -+ :method => method, -+ }) - end - - def self.failure_callback(data) -diff --git a/lib/contracts/method_handler.rb b/lib/contracts/method_handler.rb -index fe301cd..714e4e1 100644 ---- a/lib/contracts/method_handler.rb -+++ b/lib/contracts/method_handler.rb -@@ -107,7 +107,7 @@ module Contracts - current_engine = engine - - # We are gonna redefine original method here -- method_reference.make_definition(target) do |*args, &blk| -+ method_reference.make_definition(target) do |*args, **kargs, &blk| - engine = current_engine.nearest_decorated_ancestor - - # If we weren't able to find any ancestor that has decorated methods -@@ -130,14 +130,14 @@ module Contracts - last_error = nil - - decorated_methods.each do |decorated_method| -- result = decorated_method.call_with_inner(true, self, *args, &blk) -+ result = decorated_method.call_with_inner(true, self, *args, **kargs, &blk) - return result unless result.is_a?(ParamContractError) - last_error = result - end - - begin - if ::Contract.failure_callback(last_error.data, false) -- decorated_methods.last.call_with_inner(false, self, *args, &blk) -+ decorated_methods.last.call_with_inner(false, self, *args, **kargs, &blk) - end - rescue expected_error => final_error - raise final_error.to_contract_error -diff --git a/lib/contracts/method_reference.rb b/lib/contracts/method_reference.rb -index 0bc68f8..0c0c03f 100644 ---- a/lib/contracts/method_reference.rb -+++ b/lib/contracts/method_reference.rb -@@ -39,8 +39,8 @@ module Contracts - - # Calls original method on specified `this` argument with - # specified arguments `args` and block `&blk`. -- def send_to(this, *args, &blk) -- this.send(aliased_name, *args, &blk) -+ def send_to(this, *args, **kargs, &blk) -+ this.send(aliased_name, *args, **kargs, &blk) - end - - private -diff --git a/spec/builtin_contracts_spec.rb b/spec/builtin_contracts_spec.rb -index 00cf495..a9f7257 100644 ---- a/spec/builtin_contracts_spec.rb -+++ b/spec/builtin_contracts_spec.rb -@@ -376,10 +376,6 @@ RSpec.describe "Contracts:" do - fails { @o.hash_keywordargs(:hash => nil) } - fails { @o.hash_keywordargs(:hash => 1) } - end -- -- it "should pass if a method is overloaded with non-KeywordArgs" do -- passes { @o.person_keywordargs("name", 10) } -- end - end - - describe "Optional:" do -@@ -405,15 +401,15 @@ RSpec.describe "Contracts:" do - end - - context "given a fulfilled contract" do -- it { expect(@o.gives_max_value(:panda => 1, :bamboo => 2)).to eq(2) } -- it { expect(@o.pretty_gives_max_value(:panda => 1, :bamboo => 2)).to eq(2) } -+ it { expect(@o.gives_max_value({ :panda => 1, :bamboo => 2 })).to eq(2) } -+ it { expect(@o.pretty_gives_max_value({ :panda => 1, :bamboo => 2 })).to eq(2) } - end - - context "given an unfulfilled contract" do -- it { fails { @o.gives_max_value(:panda => "1", :bamboo => "2") } } -+ it { fails { @o.gives_max_value({ :panda => "1", :bamboo => "2" }) } } - it { fails { @o.gives_max_value(nil) } } - it { fails { @o.gives_max_value(1) } } -- it { fails { @o.pretty_gives_max_value(:panda => "1", :bamboo => "2") } } -+ it { fails { @o.pretty_gives_max_value({ :panda => "1", :bamboo => "2" }) } } - end - - describe "#to_s" do -@@ -430,25 +426,25 @@ RSpec.describe "Contracts:" do - describe "StrictHash:" do - context "when given an exact correct input" do - it "does not raise an error" do -- passes { @o.strict_person(:name => "calvin", :age => 10) } -+ passes { @o.strict_person({ :name => "calvin", :age => 10 }) } - end - end - - context "when given an input with correct keys but wrong types" do - it "raises an error" do -- fails { @o.strict_person(:name => "calvin", :age => "10") } -+ fails { @o.strict_person({ :name => "calvin", :age => "10" }) } - end - end - - context "when given an input with missing keys" do - it "raises an error" do -- fails { @o.strict_person(:name => "calvin") } -+ fails { @o.strict_person({ :name => "calvin" }) } - end - end - - context "when given an input with extra keys" do - it "raises an error" do -- fails { @o.strict_person(:name => "calvin", :age => 10, :soft => true) } -+ fails { @o.strict_person({ :name => "calvin", :age => 10, :soft => true }) } - end - end - -diff --git a/spec/contracts_spec.rb b/spec/contracts_spec.rb -index 72c8603..5586415 100644 ---- a/spec/contracts_spec.rb -+++ b/spec/contracts_spec.rb -@@ -349,19 +349,19 @@ RSpec.describe "Contracts:" do - - describe "Hashes" do - it "should pass for exact correct input" do -- expect { @o.person(:name => "calvin", :age => 10) }.to_not raise_error -+ expect { @o.person({ :name => "calvin", :age => 10 }) }.to_not raise_error - end - - it "should pass even if some keys don't have contracts" do -- expect { @o.person(:name => "calvin", :age => 10, :foo => "bar") }.to_not raise_error -+ expect { @o.person({ :name => "calvin", :age => 10, :foo => "bar" }) }.to_not raise_error - end - - it "should fail if a key with a contract on it isn't provided" do -- expect { @o.person(:name => "calvin") }.to raise_error(ContractError) -+ expect { @o.person({ :name => "calvin" }) }.to raise_error(ContractError) - end - - it "should fail for incorrect input" do -- expect { @o.person(:name => 50, :age => 10) }.to raise_error(ContractError) -+ expect { @o.person({ :name => 50, :age => 10 }) }.to raise_error(ContractError) - end - end - -@@ -612,16 +612,19 @@ RSpec.describe "Contracts:" do - - it "should contain to_s representation within a Hash contract" do - expect do -- @o.hash_complex_contracts(:rigged => "bad") -+ @o.hash_complex_contracts({ :rigged => "bad" }) - end.to raise_error(ContractError, not_s(delim "TrueClass or FalseClass")) - end - - it "should contain to_s representation within a nested Hash contract" do - expect do -- @o.nested_hash_complex_contracts(:rigged => true, -- :contents => { -- :kind => 0, -- :total => 42 }) -+ @o.nested_hash_complex_contracts({ -+ :rigged => true, -+ :contents => { -+ :kind => 0, -+ :total => 42, -+ }, -+ }) - end.to raise_error(ContractError, not_s(delim "String or Symbol")) - end - -diff --git a/spec/fixtures/fixtures.rb b/spec/fixtures/fixtures.rb -index b6d2bea..c42722e 100644 ---- a/spec/fixtures/fixtures.rb -+++ b/spec/fixtures/fixtures.rb -@@ -120,16 +120,11 @@ class GenericExample - end - - Contract C::KeywordArgs[:name => String, :age => Fixnum] => nil -- def person_keywordargs(data) -- end -- -- # Testing overloaded method -- Contract String, Fixnum => nil -- def person_keywordargs(name, age) -+ def person_keywordargs(name: "name", age: 10) - end - - Contract C::KeywordArgs[:hash => C::HashOf[Symbol, C::Num]] => nil -- def hash_keywordargs(data) -+ def hash_keywordargs(hash:) - end - - Contract (/foo/) => nil -diff --git a/spec/override_validators_spec.rb b/spec/override_validators_spec.rb -index 293c84c..25af373 100644 ---- a/spec/override_validators_spec.rb -+++ b/spec/override_validators_spec.rb -@@ -30,15 +30,15 @@ RSpec.describe Contract do - obj = klass.new - - expect do -- obj.something(:a => 35, :b => "hello") -+ obj.something({ :a => 35, :b => "hello" }) - end.to raise_error(ContractError) - - expect do -- obj.something( -+ obj.something({ - :a => 35, - :b => "hello", - :it_is_a_hash => true -- ) -+ }) - end.not_to raise_error - end - -diff --git a/spec/ruby_version_specific/contracts_spec_2.0.rb b/spec/ruby_version_specific/contracts_spec_2.0.rb -index 78c5e69..c2b3d69 100644 ---- a/spec/ruby_version_specific/contracts_spec_2.0.rb -+++ b/spec/ruby_version_specific/contracts_spec_2.0.rb -@@ -1,10 +1,10 @@ - class GenericExample -- Contract C::Args[String], { repeat: C::Maybe[C::Num] } => C::ArrayOf[String] -+ Contract C::Args[String], C::KeywordArgs[ repeat: C::Maybe[C::Num] ] => C::ArrayOf[String] - def splat_then_optional_named(*vals, repeat: 2) - vals.map { |v| v * repeat } - end - -- Contract ({foo: C::Nat}) => nil -+ Contract C::KeywordArgs[ foo: C::Nat ] => nil - def nat_test_with_kwarg(foo: 10) - end - -diff --git a/spec/validators_spec.rb b/spec/validators_spec.rb -index 588580e..22dc2a9 100644 ---- a/spec/validators_spec.rb -+++ b/spec/validators_spec.rb -@@ -34,7 +34,7 @@ RSpec.describe "Contract validators" do - - describe "within a hash" do - it "should pass for a matching string" do -- expect { o.hash_containing_foo(:host => "foo.example.org") }.to_not raise_error -+ expect { o.hash_containing_foo({ :host => "foo.example.org" }) }.to_not raise_error - end - end - --- -2.29.2 - diff --git a/rubygem-contracts-0.16.0-0006-Remove-deprecated-const-fixnum.patch b/rubygem-contracts-0.16.0-0006-Remove-deprecated-const-fixnum.patch deleted file mode 100644 index f0c8498c66323156d1982b177a81d184efa70081..0000000000000000000000000000000000000000 --- a/rubygem-contracts-0.16.0-0006-Remove-deprecated-const-fixnum.patch +++ /dev/null @@ -1,193 +0,0 @@ -From cbbebf804919e5ce675588adf854f6d7cdcf327a Mon Sep 17 00:00:00 2001 -From: wang--ge -Date: Wed, 2 Aug 2023 10:41:57 +0800 -Subject: [PATCH] remove deprecated const fixnum - ---- - TUTORIAL.md | 28 ++++++++++++++-------------- - spec/fixtures/fixtures.rb | 18 +++++++++--------- - 2 files changed, 23 insertions(+), 23 deletions(-) - -diff --git a/TUTORIAL.md b/TUTORIAL.md -index c74ce06..3dc68af 100644 ---- a/TUTORIAL.md -+++ b/TUTORIAL.md -@@ -80,8 +80,8 @@ contracts.ruby comes with a lot of built-in contracts, including the following: - - * Logical combinations - * [`Maybe`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Maybe) – specifies that a value _may be_ nil, e.g. `Maybe[String]` (equivalent to `Or[String,nil]`) -- * [`Or`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Or) – passes if any of the given contracts pass, e.g. `Or[Fixnum, Float]` -- * [`Xor`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Xor) – passes if exactly one of the given contracts pass, e.g. `Xor[Fixnum, Float]` -+ * [`Or`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Or) – passes if any of the given contracts pass, e.g. `Or[Integer, Float]` -+ * [`Xor`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Xor) – passes if exactly one of the given contracts pass, e.g. `Xor[Integer, Float]` - * [`And`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/And) – passes if all contracts pass, e.g. `And[Nat, -> (n) { n.even? }]` - * [`Not`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Not) – passes if all contracts fail for the given argument, e.g. `Not[nil]` - -@@ -89,7 +89,7 @@ contracts.ruby comes with a lot of built-in contracts, including the following: - * [`ArrayOf`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/ArrayOf) – checks that the argument is an array, and all elements pass the given contract, e.g. `ArrayOf[Num]` - * [`SetOf`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/SetOf) – checks that the argument is a set, and all elements pass the given contract, e.g. `SetOf[Num]` - * [`HashOf`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/HashOf) – checks that the argument is a hash, and all keys and values pass the given contract, e.g. `HashOf[Symbol => String]` or `HashOf[Symbol,String]` -- * [`StrictHash`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/StrictHash) – checks that the argument is a hash, and every key passed is present in the given contract, e.g. `StrictHash[{ :description => String, :number => Fixnum }]` -+ * [`StrictHash`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/StrictHash) – checks that the argument is a hash, and every key passed is present in the given contract, e.g. `StrictHash[{ :description => String, :number => Integer }]` - * [`RangeOf`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/RangeOf) – checks that the argument is a range whose elements (#first and #last) pass the given contract, e.g. `RangeOf[Date]` - * [`Enum`](http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Enum) – checks that the argument is part of a given collection of objects, e.g. `Enum[:a, :b, :c]` - -@@ -152,7 +152,7 @@ end - - You always need to specify a contract for the return value. In this example, `hello` doesn't return anything, so the contract is `nil`. Now you know that you can use a constant like `nil` as the end of a contract. Valid values for a contract are: - --- the name of a class (like `String` or `Fixnum`) -+- the name of a class (like `String` or `Integer`) - - a constant (like `nil` or `1`) - - a `Proc` that takes a value and returns true or false to indicate whether the contract passed or not - - a class that responds to the `valid?` class method (more on this later) -@@ -161,32 +161,32 @@ You always need to specify a contract for the return value. In this example, `he - ### A Double Function - - ```ruby --Contract C::Or[Fixnum, Float] => C::Or[Fixnum, Float] -+Contract C::Or[Integer, Float] => C::Or[Integer, Float] - def double(x) - 2 * x - end - ``` - - Sometimes you want to be able to choose between a few contracts. `Or` takes a variable number of contracts and checks the argument against all of them. If it passes for any of the contracts, then the `Or` contract passes. --This introduces some new syntax. One of the valid values for a contract is an instance of a class that responds to the `valid?` method. This is what `Or[Fixnum, Float]` is. The longer way to write it would have been: -+This introduces some new syntax. One of the valid values for a contract is an instance of a class that responds to the `valid?` method. This is what `Or[Integer, Float]` is. The longer way to write it would have been: - - ```ruby --Contract C::Or.new(Fixnum, Float) => C::Or.new(Fixnum, Float) -+Contract C::Or.new(Integer, Float) => C::Or.new(Integer, Float) - ``` - - All the built-in contracts have overridden the square brackets (`[]`) to give the same functionality. So you could write - - ```ruby --Contract C::Or[Fixnum, Float] => C::Or[Fixnum, Float] -+Contract C::Or[Integer, Float] => C::Or[Integer, Float] - ``` - - or - - ```ruby --Contract C::Or.new(Fixnum, Float) => C::Or.new(Fixnum, Float) -+Contract C::Or.new(Integer, Float) => C::Or.new(Integer, Float) - ``` - --whichever you prefer. They both mean the same thing here: make a new instance of `Or` with `Fixnum` and `Float`. Use that instance to validate the argument. -+whichever you prefer. They both mean the same thing here: make a new instance of `Or` with `Integer` and `Float`. Use that instance to validate the argument. - - ### A Product Function - -@@ -455,7 +455,7 @@ Now you can use `Person` wherever you would have used `Or[Hash, nil]`. Your code - - Contracts are very easy to define. To re-iterate, there are 5 kinds of contracts: - --- the name of a class (like `String` or `Fixnum`) -+- the name of a class (like `String` or `Integer`) - - a constant (like `nil` or `1`) - - a `Proc` that takes a value and returns true or false to indicate whether the contract passed or not - - a class that responds to the `valid?` class method (more on this later) -@@ -511,7 +511,7 @@ The `Or` contract takes a sequence of contracts, and passes if any of them pass. - This class inherits from `CallableClass`, which allows us to use `[]` when using the class: - - ```ruby --Contract C::Or[Fixnum, Float] => C::Num -+Contract C::Or[Integer, Float] => C::Num - def double(x) - 2 * x - end -@@ -520,7 +520,7 @@ end - Without `CallableClass`, we would have to use `.new` instead: - - ```ruby --Contract C::Or.new(Fixnum, Float) => C::Num -+Contract C::Or.new(Integer, Float) => C::Num - def double(x) - # etc - ``` -@@ -723,7 +723,7 @@ class MyBirthday < Struct.new(:day, :month) - invariant(:day) { 1 <= day && day <= 31 } - invariant(:month) { 1 <= month && month <= 12 } - -- Contract C::None => Fixnum -+ Contract C::None => Integer - def silly_next_day! - self.day += 1 - end -diff --git a/spec/fixtures/fixtures.rb b/spec/fixtures/fixtures.rb -index 55638c2..bf2042a 100644 ---- a/spec/fixtures/fixtures.rb -+++ b/spec/fixtures/fixtures.rb -@@ -100,11 +100,11 @@ class GenericExample - end - end - -- Contract ({ :name => String, :age => Fixnum }) => nil -+ Contract ({ :name => String, :age => Integer }) => nil - def person(data) - end - -- Contract C::StrictHash[{ :name => String, :age => Fixnum }] => nil -+ Contract C::StrictHash[{ :name => String, :age => Integer }] => nil - def strict_person(data) - end - -@@ -119,7 +119,7 @@ class GenericExample - def nested_hash_complex_contracts(data) - end - -- Contract C::KeywordArgs[:name => String, :age => Fixnum] => nil -+ Contract C::KeywordArgs[:name => String, :age => Integer] => nil - def person_keywordargs(name: "name", age: 10) - end - -@@ -529,30 +529,30 @@ class MyBirthday - @month = month - end - -- Contract C::None => Fixnum -+ Contract C::None => Integer - def silly_next_day! - self.day += 1 - end - -- Contract C::None => Fixnum -+ Contract C::None => Integer - def silly_next_month! - self.month += 1 - end - -- Contract C::None => Fixnum -+ Contract C::None => Integer - def clever_next_day! - return clever_next_month! if day == 31 - self.day += 1 - end - -- Contract C::None => Fixnum -+ Contract C::None => Integer - def clever_next_month! - return next_year! if month == 12 - self.month += 1 - self.day = 1 - end - -- Contract C::None => Fixnum -+ Contract C::None => Integer - def next_year! - self.month = 1 - self.day = 1 -@@ -610,7 +610,7 @@ with_enabled_no_contracts do - body + "!" - end - -- Contract Fixnum, String => String -+ Contract Integer, String => String - def on_response(status, body) - "error #{status}: #{body}" - end --- -2.33.0 - diff --git a/rubygem-contracts.spec b/rubygem-contracts.spec index a03616bab68424fc2ea487b54f75216b7761fdbe..d8eb353126c8f5f0b52853edf2fe8f9771526a64 100644 --- a/rubygem-contracts.spec +++ b/rubygem-contracts.spec @@ -1,17 +1,11 @@ %global gem_name contracts Name: rubygem-%{gem_name} -Version: 0.16.0 -Release: 4 +Version: 0.17 +Release: 1 Summary: Contracts for Ruby License: BSD-2-Clause URL: http://egonschiele.github.io/contracts.ruby/ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem -Patch1: rubygem-contracts-0.16.0-0001-Don-t-use-exceptions-for-control-flow.patch -Patch2: rubygem-contracts-0.16.0-0002-Update-spec-to-specify-error-class-to-suppress-RSpec.patch -Patch3: rubygem-contracts-0.16.0-0003-Fix-misspellings-in-comments.patch -Patch4: rubygem-contracts-0.16.0-0004-Wrapping-blocks-only-when-there-is-a-Func-check.-bug.patch -Patch5: rubygem-contracts-0.16.0-0005-Update-implementation-spec-to-be-3.0-compatible.patch -Patch6: rubygem-contracts-0.16.0-0006-Remove-deprecated-const-fixnum.patch BuildRequires: ruby(release) rubygems-devel ruby rubygem(rspec) >= 3 BuildArch: noarch %description @@ -27,18 +21,13 @@ BuildArch: noarch Documentation for %{name}. %prep -gem unpack %{SOURCE0} -%setup -q -D -T -n %{gem_name}-%{version} - -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 - +%setup -q -n %{gem_name}-%{version} gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec +# Ruby3.2 removes Fixnum +# https://github.com/egonSchiele/contracts.ruby/issues/300 +sed -i spec/fixtures/fixtures.rb -e 's|Fixnum|Integer|' + %build gem build %{gem_name}.gemspec %gem_install @@ -80,6 +69,9 @@ popd %{gem_instdir}/benchmarks/ %changelog +* Mon Nov 13 2023 wangkai <13474090681@163.com> - 0.17-1 +- Update to 0.17 + * Wed Aug 02 2023 Ge Wang - 0.16.0-4 - Remove deprecated const fixnum due to ruby updated