diff --git a/.gitignore b/.gitignore index c90b28c..e54d50f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /contracts-0.14.0.gem /contracts-0.15.0.gem /contracts-0.16.0.gem +/contracts-0.16.1.gem 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 5a06144..0000000 --- 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 c336695..0000000 --- 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 8ac5b36..0000000 --- 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 04b1d62..0000000 --- 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.spec b/rubygem-contracts.spec index 405a2af..9188736 100644 --- a/rubygem-contracts.spec +++ b/rubygem-contracts.spec @@ -1,18 +1,14 @@ %global gem_name contracts Name: rubygem-%{gem_name} -Version: 0.16.0 -Release: 11%{?dist} +Version: 0.16.1 +Release: 1%{?dist} Summary: Contracts for Ruby License: BSD URL: http://egonschiele.github.io/contracts.ruby/ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem # Upstream patches -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 # Ruby 3.0 Trial Upstream patches # https://github.com/egonSchiele/contracts.ruby/issues/294 # https://github.com/egonSchiele/contracts.ruby/pull/295 @@ -38,21 +34,15 @@ BuildArch: noarch Documentation for %{name}. %prep -gem unpack %{SOURCE0} -%setup -q -D -T -n %{gem_name}-%{version} +%setup -q -n %{gem_name}-%{version} +mv ../%{gem_name}-%{version}.gemspec . -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 %if 0%{?fedora} >= 34 || 0%{?rhel} >= 9 %patch5 -p1 %endif -gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec - %build -gem build %{gem_name}.gemspec +gem build %{gem_name}-%{version}.gemspec %gem_install %install @@ -95,6 +85,9 @@ popd %{gem_instdir}/benchmarks/ %changelog +* Sat May 1 2021 Mamoru TASAKA - 0.16.1-1 +- 0.16.1 + * Sun Feb 28 2021 Mamoru TASAKA - 0.16.0-11 - Add conditional for eln diff --git a/sources b/sources index b389fbb..636bed1 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (contracts-0.16.0.gem) = 27d757c3a6d25920ada1b24842a5ed8521bc8902b1840b6060c94dc17e5eecb91501439eb764fa2fec97dedc6591d2c2978630f56d4b38e7b607e9fccfb60ad7 +SHA512 (contracts-0.16.1.gem) = bc182431de9efbc6d23603c68a64eddcd3f27ea1ac8c2c9ff00840cf38d2f58ba595304127e6b43e504d3aa387559a5c1429b671dadac175d3a4ad2c02edbf6a