contracts 0.17.2 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5a8e7593b70e99ae8c0f56e6bf4484b884ecfbb740a418f27a78321ca856c9
4
- data.tar.gz: c62fb8724ebfe3aea0dc2ff4ae8f9af119192d84d57244076ae83d60a5d26c03
3
+ metadata.gz: 9a3e8688e39f57c226e61188412d8afcadc4b3836818b6287e774eb0c1c50e5a
4
+ data.tar.gz: fc13d092a656848c127f4f49dbb2a5cf60996c766a6309ed207ca6b556402f6d
5
5
  SHA512:
6
- metadata.gz: ea0815ee43b56200ab8465c112f5144989a0ac12c1a9e463ec7bc61ab14b1eeae5ef226ffed7961770b59d57fcfac3527445620cafaa55675337d289beedac4b
7
- data.tar.gz: 1895e5c8786d024696e05be452c749f1f830e538b348d30fc9deb165f92a3f87697659b5fef784a65e4eda5f4306ed3c38a7d8622ef72fd76bd5cd38e41f3b1f
6
+ metadata.gz: 386ecf5ae50df02c70b7adb1051b933866aea337213ae2103899b6a004fac17b3e453ea2efad63811e525acfc7372bc01ff4d553b8dbcb456d17f83beab3880c
7
+ data.tar.gz: ef5360cc907a2699d0f6aa4710b0b5d3fd75d89e58d766e8ef8f6a53a48702d271cf1779ac2a440fd1266aecbb369f126cff6bd503ecdad74728e47e6ad1f5dd
@@ -0,0 +1,22 @@
1
+ version: 2
2
+ updates:
3
+
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: monthly
8
+ time: "06:00"
9
+ timezone: Asia/Hong_Kong
10
+ open-pull-requests-limit: 10
11
+ labels:
12
+ - "dependencies"
13
+
14
+ - package-ecosystem: github-actions
15
+ directory: "/"
16
+ schedule:
17
+ interval: monthly
18
+ time: "06:00"
19
+ timezone: Asia/Hong_Kong
20
+ open-pull-requests-limit: 10
21
+ labels:
22
+ - "dependencies"
@@ -24,11 +24,11 @@ jobs:
24
24
  os:
25
25
  - ubuntu
26
26
  ruby:
27
- - "3.3"
27
+ - "3.4"
28
28
  runs-on: ${{ matrix.os }}-latest
29
29
  steps:
30
30
  - name: Checkout
31
- uses: actions/checkout@v4
31
+ uses: actions/checkout@v6
32
32
  - name: Setup Ruby
33
33
  uses: ruby/setup-ruby@v1
34
34
  with:
@@ -22,22 +22,30 @@ jobs:
22
22
  fail-fast: false
23
23
  matrix:
24
24
  os:
25
- - ubuntu
25
+ - ubuntu-latest
26
26
  ruby:
27
- - "3.3"
28
- - "3.2"
29
- - "3.1"
30
27
  - "3.0"
31
- test_command:
32
- - "bundle exec rspec && bundle exec cucumber"
33
- runs-on: ${{ matrix.os }}-latest
28
+ - "3.1"
29
+ - "3.2"
30
+ - "3.3"
31
+ - "3.4"
32
+ - "4.0"
33
+ allow_failures:
34
+ - false
35
+ include:
36
+ - os: ubuntu-latest
37
+ ruby: ruby-head
38
+ allow_failures: true
39
+ env:
40
+ ALLOW_FAILURES: "${{ matrix.allow_failures }}"
41
+ runs-on: ${{ matrix.os }}
34
42
  steps:
35
43
  - name: Checkout
36
- uses: actions/checkout@v4
44
+ uses: actions/checkout@v6
37
45
  - name: Setup Ruby
38
46
  uses: ruby/setup-ruby@v1
39
47
  with:
40
48
  ruby-version: ${{ matrix.ruby }}
41
49
  bundler-cache: true
42
50
  - name: Test
43
- run: ${{ matrix.test_command }}
51
+ run: "bundle exec rspec && bundle exec rake cucumber || $ALLOW_FAILURES"
data/.rubocop_todo.yml CHANGED
@@ -6,7 +6,7 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- require:
9
+ plugins:
10
10
  - rubocop-performance
11
11
 
12
12
  # Offense count: 2
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,12 @@
1
+ ## [v0.17.3]
2
+ - Relax `required_ruby_version` to support Ruby 4.0
3
+ - Bump cucumber, rubocop, actions/checkout
4
+
5
+ ## [v0.17.2] - 2024-10-06
6
+
7
+ [v0.17.2]: https://github.com/egonSchiele/contracts.ruby/compare/v0.17.1...v0.17.2
8
+
9
+ - Bugfix: Fix pattern matching - [PikachuEXE](https://github.com/PikachuEXE) [#308](https://github.com/egonSchiele/contracts.ruby/pull/308)
1
10
 
2
11
  ## [v0.17.1] - 2024-10-06
3
12
 
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gemspec
6
6
 
7
7
  group :test do
8
8
  gem "aruba"
9
- gem "cucumber", "~> 1.3.20"
9
+ gem "cucumber", ">= 9.2.1"
10
10
  gem "rspec"
11
11
 
12
12
  gem "rubocop", ">= 1.0.0"
data/Rakefile CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  task :default => [:spec]
4
4
 
5
+ task :cucumber do
6
+ if RUBY_VERSION >= "3.4"
7
+ sh "cucumber --tags 'not @before_ruby_3_3'"
8
+ else
9
+ sh "cucumber --tags 'not @after_ruby_3_4'"
10
+ end
11
+ end
12
+
5
13
  task :add_tag do
6
14
  `git tag -a v#{Contracts::VERSION} -m 'v#{Contracts::VERSION}'`
7
15
  end
data/contracts.gemspec CHANGED
@@ -12,5 +12,5 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
  s.homepage = "https://github.com/egonSchiele/contracts.ruby"
14
14
  s.license = "BSD-2-Clause"
15
- s.required_ruby_version = [">= 3.0", "< 4"]
15
+ s.required_ruby_version = [">= 3.0", "< 5"]
16
16
  end
@@ -1,4 +1,5 @@
1
- Feature: Pretty printing Contract violations
1
+ @before_ruby_3_3
2
+ Feature: Pretty printing Contract violations (Ruby 3.3-)
2
3
 
3
4
  Scenario: Big array argument being passed to big array method parameter
4
5
  Given a file named "example.rb" with:
@@ -0,0 +1,242 @@
1
+ @after_ruby_3_4
2
+ Feature: Pretty printing Contract violations (Ruby 3.4+)
3
+
4
+ Scenario: Big array argument being passed to big array method parameter
5
+ Given a file named "example.rb" with:
6
+ """ruby
7
+ require "contracts"
8
+ C = Contracts
9
+
10
+ class Example
11
+ include Contracts::Core
12
+
13
+ class << self
14
+ Contract [
15
+ C::Or[String, Symbol],
16
+ C::Or[String, Symbol],
17
+ C::Or[String, Symbol],
18
+ C::Or[String, Symbol],
19
+ C::Or[String, Symbol],
20
+ C::Or[String, Symbol],
21
+ C::Or[String, Symbol]
22
+ ] => nil
23
+ def run(data)
24
+ nil
25
+ end
26
+ end
27
+ end
28
+
29
+ puts Example.run([
30
+ ["foo", "foo"],
31
+ ["foo", "foo"],
32
+ ["foo", "foo"],
33
+ ["foo", "foo"],
34
+ ["foo", "foo"],
35
+ ["foo", "foo"],
36
+ ["foo", "foo"],
37
+ ["foo", "foo"],
38
+ ["foo", "foo"]
39
+ ])
40
+ """
41
+ When I run `ruby example.rb`
42
+ Then the output should contain:
43
+ """
44
+ : Contract violation for argument 1 of 1: (ParamContractError)
45
+ Expected: [(String or Symbol),
46
+ (String or Symbol),
47
+ (String or Symbol),
48
+ (String or Symbol),
49
+ (String or Symbol),
50
+ (String or Symbol),
51
+ (String or Symbol)],
52
+ Actual: [["foo", "foo"],
53
+ ["foo", "foo"],
54
+ ["foo", "foo"],
55
+ ["foo", "foo"],
56
+ ["foo", "foo"],
57
+ ["foo", "foo"],
58
+ ["foo", "foo"],
59
+ ["foo", "foo"],
60
+ ["foo", "foo"]]
61
+ Value guarded in: Example::run
62
+ With Contract: Array => NilClass
63
+ At: example.rb:17
64
+ """
65
+
66
+ Scenario: Big array value being returned from method expecting different big array type
67
+ Given a file named "example.rb" with:
68
+ """ruby
69
+ require "contracts"
70
+ C = Contracts
71
+
72
+ class Example
73
+ include Contracts::Core
74
+
75
+ class << self
76
+ Contract C::None => [
77
+ C::Or[String, Symbol],
78
+ C::Or[String, Symbol],
79
+ C::Or[String, Symbol],
80
+ C::Or[String, Symbol],
81
+ C::Or[String, Symbol],
82
+ C::Or[String, Symbol],
83
+ C::Or[String, Symbol]
84
+ ]
85
+ def run
86
+ [
87
+ ["foo", "foo"],
88
+ ["foo", "foo"],
89
+ ["foo", "foo"],
90
+ ["foo", "foo"],
91
+ ["foo", "foo"],
92
+ ["foo", "foo"],
93
+ ["foo", "foo"],
94
+ ["foo", "foo"],
95
+ ["foo", "foo"]
96
+ ]
97
+ end
98
+ end
99
+ end
100
+
101
+ puts Example.run
102
+ """
103
+ When I run `ruby example.rb`
104
+ Then the output should contain:
105
+ """
106
+ : Contract violation for return value: (ReturnContractError)
107
+ Expected: [(String or Symbol),
108
+ (String or Symbol),
109
+ (String or Symbol),
110
+ (String or Symbol),
111
+ (String or Symbol),
112
+ (String or Symbol),
113
+ (String or Symbol)],
114
+ Actual: [["foo", "foo"],
115
+ ["foo", "foo"],
116
+ ["foo", "foo"],
117
+ ["foo", "foo"],
118
+ ["foo", "foo"],
119
+ ["foo", "foo"],
120
+ ["foo", "foo"],
121
+ ["foo", "foo"],
122
+ ["foo", "foo"]]
123
+ Value guarded in: Example::run
124
+ With Contract: None => Array
125
+ At: example.rb:17
126
+ """
127
+
128
+ Scenario: Big hash argument being passed to big hash method parameter
129
+ Given a file named "example.rb" with:
130
+ """ruby
131
+ require "contracts"
132
+ C = Contracts
133
+
134
+ class Example
135
+ include Contracts::Core
136
+
137
+ class << self
138
+ Contract ({
139
+ a: C::Or[String, Symbol],
140
+ b: C::Or[String, Symbol],
141
+ c: C::Or[String, Symbol],
142
+ d: C::Or[String, Symbol],
143
+ e: C::Or[String, Symbol],
144
+ f: C::Or[String, Symbol],
145
+ g: C::Or[String, Symbol]
146
+ }) => nil
147
+ def run(data)
148
+ nil
149
+ end
150
+ end
151
+ end
152
+
153
+ puts Example.run({
154
+ a: ["foo", "foo"],
155
+ b: ["foo", "foo"],
156
+ c: ["foo", "foo"],
157
+ d: ["foo", "foo"],
158
+ e: ["foo", "foo"],
159
+ f: ["foo", "foo"],
160
+ g: ["foo", "foo"]
161
+ })
162
+ """
163
+ When I run `ruby example.rb`
164
+ Then the output should contain:
165
+ """
166
+ : Contract violation for argument 1 of 1: (ParamContractError)
167
+ Expected: {a: (String or Symbol),
168
+ b: (String or Symbol),
169
+ c: (String or Symbol),
170
+ d: (String or Symbol),
171
+ e: (String or Symbol),
172
+ f: (String or Symbol),
173
+ g: (String or Symbol)},
174
+ Actual: {a: ["foo", "foo"],
175
+ b: ["foo", "foo"],
176
+ c: ["foo", "foo"],
177
+ d: ["foo", "foo"],
178
+ e: ["foo", "foo"],
179
+ f: ["foo", "foo"],
180
+ g: ["foo", "foo"]}
181
+ Value guarded in: Example::run
182
+ With Contract: Hash => NilClass
183
+ At: example.rb:17
184
+ """
185
+
186
+ Scenario: Big hash value being returned from method expecting different big hash type
187
+ Given a file named "example.rb" with:
188
+ """ruby
189
+ require "contracts"
190
+ C = Contracts
191
+
192
+ class Example
193
+ include Contracts::Core
194
+
195
+ class << self
196
+ Contract C::None => ({
197
+ a: C::Or[String, Symbol],
198
+ b: C::Or[String, Symbol],
199
+ c: C::Or[String, Symbol],
200
+ d: C::Or[String, Symbol],
201
+ e: C::Or[String, Symbol],
202
+ f: C::Or[String, Symbol],
203
+ g: C::Or[String, Symbol]
204
+ })
205
+ def run
206
+ {
207
+ a: ["foo", "foo"],
208
+ b: ["foo", "foo"],
209
+ c: ["foo", "foo"],
210
+ d: ["foo", "foo"],
211
+ e: ["foo", "foo"],
212
+ f: ["foo", "foo"],
213
+ g: ["foo", "foo"]
214
+ }
215
+ end
216
+ end
217
+ end
218
+
219
+ puts Example.run
220
+ """
221
+ When I run `ruby example.rb`
222
+ Then the output should contain:
223
+ """
224
+ : Contract violation for return value: (ReturnContractError)
225
+ Expected: {a: (String or Symbol),
226
+ b: (String or Symbol),
227
+ c: (String or Symbol),
228
+ d: (String or Symbol),
229
+ e: (String or Symbol),
230
+ f: (String or Symbol),
231
+ g: (String or Symbol)},
232
+ Actual: {a: ["foo", "foo"],
233
+ b: ["foo", "foo"],
234
+ c: ["foo", "foo"],
235
+ d: ["foo", "foo"],
236
+ e: ["foo", "foo"],
237
+ f: ["foo", "foo"],
238
+ g: ["foo", "foo"]}
239
+ Value guarded in: Example::run
240
+ With Contract: None => Hash
241
+ At: example.rb:17
242
+ """
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Lint/RedundantRequireStatement
4
3
  # If removed, spec/module_spec fails
5
4
  require "pp"
6
- # rubocop:enable Lint/RedundantRequireStatement
7
5
 
8
6
  module Contracts
9
7
  # A namespace for classes related to formatting.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Contracts
4
- VERSION = "0.17.2"
4
+ VERSION = "0.17.3"
5
5
  end
@@ -56,7 +56,11 @@ RSpec.describe "Contracts:" do
56
56
  @o.complicated("a", true, :b, :c, 2.0, e: (1..5), f: nil, g: :d) do |x|
57
57
  x
58
58
  end
59
- end.to raise_error(ContractError, /Expected: \(KeywordArgs\[{:e=>Range, :f=>Optional\[Num\], :g=>Symbol}\]\)/)
59
+ end.to raise_error(
60
+ ContractError,
61
+ # 3.3- vs 3.4+ error message format
62
+ /(Expected: \(KeywordArgs\[{:e=>Range, :f=>Optional\[Num\], :g=>Symbol}\]\)|Expected: \(KeywordArgs\[{e: Range, f: Optional\[Num\], g: Symbol}\]\))/,
63
+ )
60
64
  end
61
65
  end
62
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contracts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.2
4
+ version: 0.17.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditya Bhargava
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-15 00:00:00.000000000 Z
11
+ date: 2025-12-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This library provides contracts for Ruby. Contracts let you clearly express
14
14
  how your code behaves, and free you from writing tons of boilerplate, defensive
@@ -18,6 +18,7 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".github/dependabot.yml"
21
22
  - ".github/workflows/code_style_checks.yaml"
22
23
  - ".github/workflows/tests.yaml"
23
24
  - ".gitignore"
@@ -42,7 +43,8 @@ files:
42
43
  - features/README.md
43
44
  - features/advanced/pattern_matching.feature
44
45
  - features/basics/functype.feature
45
- - features/basics/pretty-print.feature
46
+ - features/basics/pretty-print_@before_ruby_3_3.feature
47
+ - features/basics/pretty-print_after_ruby_3_4.feature
46
48
  - features/basics/simple_example.feature
47
49
  - features/builtin_contracts/README.md
48
50
  - features/builtin_contracts/and.feature
@@ -113,7 +115,7 @@ homepage: https://github.com/egonSchiele/contracts.ruby
113
115
  licenses:
114
116
  - BSD-2-Clause
115
117
  metadata: {}
116
- post_install_message:
118
+ post_install_message:
117
119
  rdoc_options: []
118
120
  require_paths:
119
121
  - lib
@@ -124,15 +126,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
126
  version: '3.0'
125
127
  - - "<"
126
128
  - !ruby/object:Gem::Version
127
- version: '4'
129
+ version: '5'
128
130
  required_rubygems_version: !ruby/object:Gem::Requirement
129
131
  requirements:
130
132
  - - ">="
131
133
  - !ruby/object:Gem::Version
132
134
  version: '0'
133
135
  requirements: []
134
- rubygems_version: 3.4.10
135
- signing_key:
136
+ rubygems_version: 3.0.3.1
137
+ signing_key:
136
138
  specification_version: 4
137
139
  summary: Contracts for Ruby.
138
140
  test_files: []