Projects
openEuler:Mainline
rubygem-contracts
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 10
View file
_service:tar_scm:rubygem-contracts.spec
Changed
@@ -1,7 +1,7 @@ %global gem_name contracts Name: rubygem-%{gem_name} Version: 0.16.0 -Release: 3 +Release: 4 Summary: Contracts for Ruby License: BSD-2-Clause URL: http://egonschiele.github.io/contracts.ruby/ @@ -11,6 +11,7 @@ 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 @@ -34,6 +35,7 @@ %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec @@ -78,6 +80,9 @@ %{gem_instdir}/benchmarks/ %changelog +* Wed Aug 02 2023 Ge Wang <wang__ge@126.com> - 0.16.0-4 +- Remove deprecated const fixnum due to ruby updated + * Tue May 10 2022 yaoxin <yaoxin30@h-partners.com> - 0.16.0-3 - License compliance rectification
View file
_service:tar_scm:rubygem-contracts-0.16.0-0006-Remove-deprecated-const-fixnum.patch
Added
@@ -0,0 +1,193 @@ +From cbbebf804919e5ce675588adf854f6d7cdcf327a Mon Sep 17 00:00:00 2001 +From: wang--ge <wang__ge@126.com> +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. `MaybeString` (equivalent to `OrString,nil`) +- * `Or`(http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Or) – passes if any of the given contracts pass, e.g. `OrFixnum, Float` +- * `Xor`(http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Xor) – passes if exactly one of the given contracts pass, e.g. `XorFixnum, Float` ++ * `Or`(http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Or) – passes if any of the given contracts pass, e.g. `OrInteger, Float` ++ * `Xor`(http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Xor) – passes if exactly one of the given contracts pass, e.g. `XorInteger, Float` + * `And`(http://www.rubydoc.info/gems/contracts/Contracts/Builtin/And) – passes if all contracts pass, e.g. `AndNat, -> (n) { n.even? }` + * `Not`(http://www.rubydoc.info/gems/contracts/Contracts/Builtin/Not) – passes if all contracts fail for the given argument, e.g. `Notnil` + +@@ -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. `ArrayOfNum` + * `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. `SetOfNum` + * `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. `HashOfSymbol => String` or `HashOfSymbol,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. `RangeOfDate` + * `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::OrFixnum, Float => C::OrFixnum, Float ++Contract C::OrInteger, Float => C::OrInteger, 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 `OrFixnum, 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 `OrInteger, 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::OrFixnum, Float => C::OrFixnum, Float ++Contract C::OrInteger, Float => C::OrInteger, 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 `OrHash, 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::OrFixnum, Float => C::Num ++Contract C::OrInteger, 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 +
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2