From 88fd1d841615e59c873d7da64d050d3a251634dd Mon Sep 17 00:00:00 2001
From: PikachuEXE <pikachuexe@gmail.com>
Date: Wed, 5 Oct 2022 10:27:41 +0800
Subject: [PATCH] * Update all references to Fixnum to Integer
Origin: https://github.com/egonSchiele/contracts.ruby/commit/88fd1d841615e59c873d7da64d050d3a251634dd.patch

Deprecated in ruby 2.4 and removed in ruby3.2
---
 .rubocop.yml                       |  2 +-
 TUTORIAL.md                        | 28 ++++++++++++++--------------
 lib/contracts/builtin_contracts.rb |  6 +++---
 spec/builtin_contracts_spec.rb     |  2 +-
 spec/fixtures/fixtures.rb          | 18 +++++++++---------
 5 files changed, 28 insertions(+), 28 deletions(-)

--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -64,7 +64,7 @@
 Layout/LineLength:
   Enabled: false
 
-# triggered by Contract ({ :name => String, :age => Fixnum }) => nil
+# triggered by Contract ({ :name => String, :age => Integer }) => nil
 Lint/ParenthesesAsGroupedExpression:
   Enabled: false
 
--- a/TUTORIAL.md
+++ b/TUTORIAL.md
@@ -80,8 +80,8 @@
 
 * 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 @@
   * [`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 @@
 
 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 @@
 ### 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 @@
 
 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 @@
 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 @@
 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 @@
   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
--- a/lib/contracts/builtin_contracts.rb
+++ b/lib/contracts/builtin_contracts.rb
@@ -95,7 +95,7 @@
 
     # Takes a variable number of contracts.
     # The contract passes if any of the contracts pass.
-    # Example: <tt>Or[Fixnum, Float]</tt>
+    # Example: <tt>Or[Integer, Float]</tt>
     class Or < CallableClass
       def initialize(*vals)
         super()
@@ -120,7 +120,7 @@
 
     # Takes a variable number of contracts.
     # The contract passes if exactly one of those contracts pass.
-    # Example: <tt>Xor[Fixnum, Float]</tt>
+    # Example: <tt>Xor[Integer, Float]</tt>
     class Xor < CallableClass
       def initialize(*vals)
         super()
@@ -146,7 +146,7 @@
 
     # Takes a variable number of contracts.
     # The contract passes if all contracts pass.
-    # Example: <tt>And[Fixnum, Float]</tt>
+    # Example: <tt>And[Integer, Float]</tt>
     class And < CallableClass
       def initialize(*vals)
         super()
--- a/spec/builtin_contracts_spec.rb
+++ b/spec/builtin_contracts_spec.rb
@@ -30,7 +30,7 @@
   end
 
   describe "Num:" do
-    it "should pass for Fixnums" do
+    it "should pass for Integers" do
       passes { @o.double(2) }
     end
 
--- a/spec/fixtures/fixtures.rb
+++ b/spec/fixtures/fixtures.rb
@@ -100,11 +100,11 @@
     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 @@
   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 @@
     @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 @@
       body + "!"
     end
 
-    Contract Fixnum, String => String
+    Contract Integer, String => String
     def on_response(status, body)
       "error #{status}: #{body}"
     end
