fear 1.1.0 → 1.2.0
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 +4 -4
- data/.github/workflows/rubocop.yml +39 -0
- data/.github/workflows/spec.yml +42 -0
- data/.rubocop.yml +1 -1
- data/.simplecov +17 -0
- data/CHANGELOG.md +12 -3
- data/Gemfile +0 -2
- data/Gemfile.lock +80 -39
- data/README.md +158 -9
- data/Rakefile +27 -0
- data/examples/pattern_extracting.rb +1 -1
- data/examples/pattern_extracting_ruby2.7.rb +15 -0
- data/examples/pattern_matching_binary_tree_set.rb +3 -0
- data/examples/pattern_matching_number_in_words.rb +2 -0
- data/fear.gemspec +7 -8
- data/lib/dry/types/fear.rb +8 -0
- data/lib/dry/types/fear/option.rb +125 -0
- data/lib/fear.rb +9 -0
- data/lib/fear/awaitable.rb +2 -2
- data/lib/fear/either.rb +5 -0
- data/lib/fear/either_pattern_match.rb +3 -0
- data/lib/fear/extractor.rb +2 -0
- data/lib/fear/extractor/any_matcher.rb +1 -1
- data/lib/fear/extractor/array_splat_matcher.rb +1 -1
- data/lib/fear/extractor/empty_list_matcher.rb +1 -1
- data/lib/fear/extractor/matcher.rb +0 -3
- data/lib/fear/extractor/pattern.rb +1 -0
- data/lib/fear/extractor/value_matcher.rb +1 -1
- data/lib/fear/failure.rb +7 -0
- data/lib/fear/future.rb +12 -6
- data/lib/fear/future_api.rb +2 -2
- data/lib/fear/left.rb +1 -0
- data/lib/fear/none.rb +18 -0
- data/lib/fear/option.rb +22 -0
- data/lib/fear/option_pattern_match.rb +1 -0
- data/lib/fear/partial_function.rb +6 -0
- data/lib/fear/partial_function/empty.rb +2 -0
- data/lib/fear/pattern_matching_api.rb +1 -0
- data/lib/fear/right.rb +2 -0
- data/lib/fear/some.rb +28 -0
- data/lib/fear/struct.rb +13 -0
- data/lib/fear/success.rb +6 -0
- data/lib/fear/try_pattern_match.rb +3 -0
- data/lib/fear/utils.rb +13 -0
- data/lib/fear/version.rb +1 -1
- data/spec/dry/types/fear/option/constrained_spec.rb +22 -0
- data/spec/dry/types/fear/option/core_spec.rb +77 -0
- data/spec/dry/types/fear/option/default_spec.rb +21 -0
- data/spec/dry/types/fear/option/hash_spec.rb +58 -0
- data/spec/dry/types/fear/option/option_spec.rb +97 -0
- data/spec/fear/awaitable_spec.rb +17 -0
- data/spec/fear/either_pattern_matching_spec.rb +28 -0
- data/spec/fear/future_spec.rb +11 -2
- data/spec/fear/none_spec.rb +1 -1
- data/spec/fear/option_pattern_matching_spec.rb +34 -0
- data/spec/fear/option_spec.rb +128 -0
- data/spec/fear/partial_function_spec.rb +50 -0
- data/spec/fear/pattern_matching_api_spec.rb +31 -0
- data/spec/fear/try_pattern_matching_spec.rb +34 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/struct_pattern_matching_spec.rb +36 -0
- data/spec/struct_spec.rb +2 -2
- data/spec/support/dry_types.rb +6 -0
- metadata +110 -12
- data/.travis.yml +0 -17
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# CodeClimate::TestReporter.start
|
3
|
+
require "simplecov"
|
5
4
|
|
6
5
|
require "fear"
|
7
6
|
require File.expand_path("spec/fear/right_biased/right")
|
8
7
|
require File.expand_path("spec/fear/right_biased/left")
|
9
8
|
require "date"
|
9
|
+
require "fear/rspec"
|
10
10
|
|
11
11
|
RSpec.configure do |config|
|
12
|
+
unless RUBY_VERSION >= "2.7"
|
13
|
+
config.exclude_pattern = "**/*pattern_matching_spec.rb"
|
14
|
+
end
|
15
|
+
|
12
16
|
# rspec-expectations config goes here. You can use an alternate
|
13
17
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
14
18
|
# assertions if you prefer.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Fear::Struct do
|
4
|
+
describe "pattern matching" do
|
5
|
+
subject do
|
6
|
+
case struct
|
7
|
+
in Fear::Struct(a: 42)
|
8
|
+
"a = 42"
|
9
|
+
in Fear::Struct(a: 43, **rest)
|
10
|
+
"a = 43, #{rest}"
|
11
|
+
in Fear::Struct(a:)
|
12
|
+
"a = #{a}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:struct_class) { described_class.with_attributes(:a, :b) }
|
17
|
+
|
18
|
+
context "when match single value" do
|
19
|
+
let(:struct) { struct_class.new(b: 43, a: 42) }
|
20
|
+
|
21
|
+
it { is_expected.to eq("a = 42") }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when match single value and capture the rest" do
|
25
|
+
let(:struct) { struct_class.new(b: 42, a: 43) }
|
26
|
+
|
27
|
+
it { is_expected.to eq("a = 43, {:b=>42}") }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when capture a value" do
|
31
|
+
let(:struct) { struct_class.new(b: 45, a: 44) }
|
32
|
+
|
33
|
+
it { is_expected.to eq("a = 44") }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/struct_spec.rb
CHANGED
@@ -15,7 +15,7 @@ RSpec.describe Fear::Struct do
|
|
15
15
|
|
16
16
|
let(:struct_class) { described_class.with_attributes(:a, :b) }
|
17
17
|
|
18
|
-
it { is_expected.to raise_error(ArgumentError
|
18
|
+
it { is_expected.to raise_error(ArgumentError) }
|
19
19
|
end
|
20
20
|
|
21
21
|
context "extra argument" do
|
@@ -71,7 +71,7 @@ RSpec.describe Fear::Struct do
|
|
71
71
|
let(:struct_class) { described_class.with_attributes(:a, :b) }
|
72
72
|
|
73
73
|
context "same class and members" do
|
74
|
-
subject { struct_class.new(a: 42, b: 43) == struct_class.new(a: 42, b: 43) } # rubocop: disable Lint/
|
74
|
+
subject { struct_class.new(a: 42, b: 43) == struct_class.new(a: 42, b: 43) } # rubocop: disable Lint/BinaryOperatorWithIdenticalOperands
|
75
75
|
|
76
76
|
it { is_expected.to eq(true) }
|
77
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lru_redux
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '13.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '13.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rspec
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,28 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - '='
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.34.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
166
|
+
version: 1.34.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 1.0.0
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 1.0.0
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: ruby_coding_standard
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +206,62 @@ dependencies:
|
|
192
206
|
- - ">="
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: dry-types
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: fear-rspec
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: simplecov
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: simplecov-lcov
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
195
265
|
description: Ruby port of some Scala's monads.
|
196
266
|
email:
|
197
267
|
- abolshakov@spbtv.com
|
@@ -199,10 +269,12 @@ executables: []
|
|
199
269
|
extensions: []
|
200
270
|
extra_rdoc_files: []
|
201
271
|
files:
|
272
|
+
- ".github/workflows/rubocop.yml"
|
273
|
+
- ".github/workflows/spec.yml"
|
202
274
|
- ".gitignore"
|
203
275
|
- ".rspec"
|
204
276
|
- ".rubocop.yml"
|
205
|
-
- ".
|
277
|
+
- ".simplecov"
|
206
278
|
- ".yardopts"
|
207
279
|
- CHANGELOG.md
|
208
280
|
- Gemfile
|
@@ -223,9 +295,12 @@ files:
|
|
223
295
|
- benchmarks/pattern_matching_qo_vs_fear_pattern_extraction.txt
|
224
296
|
- benchmarks/pattern_matching_qo_vs_fear_try_execution.txt
|
225
297
|
- examples/pattern_extracting.rb
|
298
|
+
- examples/pattern_extracting_ruby2.7.rb
|
226
299
|
- examples/pattern_matching_binary_tree_set.rb
|
227
300
|
- examples/pattern_matching_number_in_words.rb
|
228
301
|
- fear.gemspec
|
302
|
+
- lib/dry/types/fear.rb
|
303
|
+
- lib/dry/types/fear/option.rb
|
229
304
|
- lib/fear.rb
|
230
305
|
- lib/fear/await.rb
|
231
306
|
- lib/fear/awaitable.rb
|
@@ -293,9 +368,16 @@ files:
|
|
293
368
|
- lib/fear/unit.rb
|
294
369
|
- lib/fear/utils.rb
|
295
370
|
- lib/fear/version.rb
|
371
|
+
- spec/dry/types/fear/option/constrained_spec.rb
|
372
|
+
- spec/dry/types/fear/option/core_spec.rb
|
373
|
+
- spec/dry/types/fear/option/default_spec.rb
|
374
|
+
- spec/dry/types/fear/option/hash_spec.rb
|
375
|
+
- spec/dry/types/fear/option/option_spec.rb
|
376
|
+
- spec/fear/awaitable_spec.rb
|
296
377
|
- spec/fear/done_spec.rb
|
297
378
|
- spec/fear/either/mixin_spec.rb
|
298
379
|
- spec/fear/either_pattern_match_spec.rb
|
380
|
+
- spec/fear/either_pattern_matching_spec.rb
|
299
381
|
- spec/fear/extractor/array_matcher_spec.rb
|
300
382
|
- spec/fear/extractor/extractor_matcher_spec.rb
|
301
383
|
- spec/fear/extractor/grammar_array_spec.rb
|
@@ -316,12 +398,15 @@ files:
|
|
316
398
|
- spec/fear/none_spec.rb
|
317
399
|
- spec/fear/option/mixin_spec.rb
|
318
400
|
- spec/fear/option_pattern_match_spec.rb
|
401
|
+
- spec/fear/option_pattern_matching_spec.rb
|
402
|
+
- spec/fear/option_spec.rb
|
319
403
|
- spec/fear/partial_function/empty_spec.rb
|
320
404
|
- spec/fear/partial_function_and_then_spec.rb
|
321
405
|
- spec/fear/partial_function_composition_spec.rb
|
322
406
|
- spec/fear/partial_function_or_else_spec.rb
|
323
407
|
- spec/fear/partial_function_spec.rb
|
324
408
|
- spec/fear/pattern_match_spec.rb
|
409
|
+
- spec/fear/pattern_matching_api_spec.rb
|
325
410
|
- spec/fear/promise_spec.rb
|
326
411
|
- spec/fear/right_biased/left.rb
|
327
412
|
- spec/fear/right_biased/right.rb
|
@@ -330,17 +415,17 @@ files:
|
|
330
415
|
- spec/fear/success_spec.rb
|
331
416
|
- spec/fear/try/mixin_spec.rb
|
332
417
|
- spec/fear/try_pattern_match_spec.rb
|
418
|
+
- spec/fear/try_pattern_matching_spec.rb
|
333
419
|
- spec/fear/utils_spec.rb
|
334
420
|
- spec/spec_helper.rb
|
421
|
+
- spec/struct_pattern_matching_spec.rb
|
335
422
|
- spec/struct_spec.rb
|
423
|
+
- spec/support/dry_types.rb
|
336
424
|
homepage: https://github.com/bolshakov/fear
|
337
425
|
licenses:
|
338
426
|
- MIT
|
339
427
|
metadata: {}
|
340
|
-
post_install_message:
|
341
|
-
Fear v0.11.0 introduces backwards-incompatible changes.
|
342
|
-
Please see https://github.com/bolshakov/fear/blob/master/CHANGELOG.md#0110 for details.
|
343
|
-
Successfully installed fear-1.1.0
|
428
|
+
post_install_message:
|
344
429
|
rdoc_options: []
|
345
430
|
require_paths:
|
346
431
|
- lib
|
@@ -355,14 +440,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
355
440
|
- !ruby/object:Gem::Version
|
356
441
|
version: '0'
|
357
442
|
requirements: []
|
358
|
-
rubygems_version: 3.
|
443
|
+
rubygems_version: 3.1.4
|
359
444
|
signing_key:
|
360
445
|
specification_version: 4
|
361
446
|
summary: "%q{Ruby port of some Scala's monads.}"
|
362
447
|
test_files:
|
448
|
+
- spec/dry/types/fear/option/constrained_spec.rb
|
449
|
+
- spec/dry/types/fear/option/core_spec.rb
|
450
|
+
- spec/dry/types/fear/option/default_spec.rb
|
451
|
+
- spec/dry/types/fear/option/hash_spec.rb
|
452
|
+
- spec/dry/types/fear/option/option_spec.rb
|
453
|
+
- spec/fear/awaitable_spec.rb
|
363
454
|
- spec/fear/done_spec.rb
|
364
455
|
- spec/fear/either/mixin_spec.rb
|
365
456
|
- spec/fear/either_pattern_match_spec.rb
|
457
|
+
- spec/fear/either_pattern_matching_spec.rb
|
366
458
|
- spec/fear/extractor/array_matcher_spec.rb
|
367
459
|
- spec/fear/extractor/extractor_matcher_spec.rb
|
368
460
|
- spec/fear/extractor/grammar_array_spec.rb
|
@@ -383,12 +475,15 @@ test_files:
|
|
383
475
|
- spec/fear/none_spec.rb
|
384
476
|
- spec/fear/option/mixin_spec.rb
|
385
477
|
- spec/fear/option_pattern_match_spec.rb
|
478
|
+
- spec/fear/option_pattern_matching_spec.rb
|
479
|
+
- spec/fear/option_spec.rb
|
386
480
|
- spec/fear/partial_function/empty_spec.rb
|
387
481
|
- spec/fear/partial_function_and_then_spec.rb
|
388
482
|
- spec/fear/partial_function_composition_spec.rb
|
389
483
|
- spec/fear/partial_function_or_else_spec.rb
|
390
484
|
- spec/fear/partial_function_spec.rb
|
391
485
|
- spec/fear/pattern_match_spec.rb
|
486
|
+
- spec/fear/pattern_matching_api_spec.rb
|
392
487
|
- spec/fear/promise_spec.rb
|
393
488
|
- spec/fear/right_biased/left.rb
|
394
489
|
- spec/fear/right_biased/right.rb
|
@@ -397,6 +492,9 @@ test_files:
|
|
397
492
|
- spec/fear/success_spec.rb
|
398
493
|
- spec/fear/try/mixin_spec.rb
|
399
494
|
- spec/fear/try_pattern_match_spec.rb
|
495
|
+
- spec/fear/try_pattern_matching_spec.rb
|
400
496
|
- spec/fear/utils_spec.rb
|
401
497
|
- spec/spec_helper.rb
|
498
|
+
- spec/struct_pattern_matching_spec.rb
|
402
499
|
- spec/struct_spec.rb
|
500
|
+
- spec/support/dry_types.rb
|
data/.travis.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
---
|
2
|
-
cache:
|
3
|
-
bundler: true
|
4
|
-
language: ruby
|
5
|
-
rvm:
|
6
|
-
- 2.4.6
|
7
|
-
- 2.5.5
|
8
|
-
- 2.6.3
|
9
|
-
before_install:
|
10
|
-
- rvm use @global
|
11
|
-
- gem uninstall bundler -x || true
|
12
|
-
- gem install bundler --force --version=2.0.1
|
13
|
-
- bundler --version
|
14
|
-
- bundle install
|
15
|
-
script:
|
16
|
-
- bundle exec rspec
|
17
|
-
- bundle exec rubocop --fail-level C
|