fear 0.11.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +18 -0
- data/.travis.yml +0 -3
- data/CHANGELOG.md +12 -1
- data/Gemfile +1 -0
- data/{gemfiles/dry_equalizer_0.2.1.gemfile.lock → Gemfile.lock} +21 -12
- data/README.md +594 -241
- data/Rakefile +166 -219
- data/benchmarks/README.md +1 -0
- data/benchmarks/dry_do_vs_fear_for.txt +11 -0
- data/benchmarks/dry_some_fmap_vs_fear_some_map.txt +11 -0
- data/benchmarks/factorial.txt +16 -0
- data/benchmarks/fear_gaurd_and1_vs_new.txt +13 -0
- data/benchmarks/fear_gaurd_and2_vs_and.txt +13 -0
- data/benchmarks/fear_gaurd_and3_vs_and_and.txt +13 -0
- data/benchmarks/fear_pattern_extracting_with_vs_without_cache.txt +11 -0
- data/benchmarks/fear_pattern_matching_construction_vs_execution.txt +13 -0
- data/benchmarks/pattern_matching_dry_vs_qo_vs_fear_try.txt +14 -0
- data/benchmarks/pattern_matching_qo_vs_fear_pattern_extraction.txt +11 -0
- data/benchmarks/pattern_matching_qo_vs_fear_try_execution.txt +11 -0
- data/examples/pattern_extracting.rb +15 -0
- data/examples/pattern_matching_binary_tree_set.rb +96 -0
- data/examples/pattern_matching_number_in_words.rb +54 -0
- data/fear.gemspec +4 -2
- data/lib/fear.rb +21 -4
- data/lib/fear/either.rb +77 -59
- data/lib/fear/either_api.rb +21 -0
- data/lib/fear/empty_partial_function.rb +1 -1
- data/lib/fear/extractor.rb +108 -0
- data/lib/fear/extractor/anonymous_array_splat_matcher.rb +8 -0
- data/lib/fear/extractor/any_matcher.rb +15 -0
- data/lib/fear/extractor/array_head_matcher.rb +34 -0
- data/lib/fear/extractor/array_matcher.rb +38 -0
- data/lib/fear/extractor/array_splat_matcher.rb +14 -0
- data/lib/fear/extractor/empty_list_matcher.rb +18 -0
- data/lib/fear/extractor/extractor_matcher.rb +42 -0
- data/lib/fear/extractor/grammar.rb +201 -0
- data/lib/fear/extractor/grammar.treetop +129 -0
- data/lib/fear/extractor/identifier_matcher.rb +16 -0
- data/lib/fear/extractor/matcher.rb +54 -0
- data/lib/fear/extractor/matcher/and.rb +36 -0
- data/lib/fear/extractor/named_array_splat_matcher.rb +15 -0
- data/lib/fear/extractor/pattern.rb +55 -0
- data/lib/fear/extractor/typed_identifier_matcher.rb +24 -0
- data/lib/fear/extractor/value_matcher.rb +17 -0
- data/lib/fear/extractor_api.rb +33 -0
- data/lib/fear/failure.rb +32 -10
- data/lib/fear/for.rb +14 -69
- data/lib/fear/for_api.rb +66 -0
- data/lib/fear/future.rb +414 -0
- data/lib/fear/future_api.rb +19 -0
- data/lib/fear/left.rb +8 -0
- data/lib/fear/none.rb +17 -8
- data/lib/fear/option.rb +55 -49
- data/lib/fear/option_api.rb +38 -0
- data/lib/fear/partial_function.rb +9 -12
- data/lib/fear/partial_function/empty.rb +1 -1
- data/lib/fear/partial_function/guard.rb +8 -20
- data/lib/fear/partial_function/lifted.rb +1 -0
- data/lib/fear/partial_function_class.rb +10 -0
- data/lib/fear/pattern_match.rb +10 -0
- data/lib/fear/pattern_matching_api.rb +35 -11
- data/lib/fear/promise.rb +87 -0
- data/lib/fear/right.rb +8 -0
- data/lib/fear/some.rb +22 -3
- data/lib/fear/success.rb +22 -1
- data/lib/fear/try.rb +82 -67
- data/lib/fear/try_api.rb +31 -0
- data/lib/fear/unit.rb +28 -0
- data/lib/fear/version.rb +1 -1
- data/spec/fear/done_spec.rb +3 -3
- data/spec/fear/either/mixin_spec.rb +15 -0
- data/spec/fear/either_pattern_match_spec.rb +10 -12
- data/spec/fear/extractor/array_matcher_spec.rb +228 -0
- data/spec/fear/extractor/extractor_matcher_spec.rb +151 -0
- data/spec/fear/extractor/grammar_array_spec.rb +23 -0
- data/spec/fear/extractor/identified_matcher_spec.rb +47 -0
- data/spec/fear/extractor/identifier_matcher_spec.rb +66 -0
- data/spec/fear/extractor/pattern_spec.rb +32 -0
- data/spec/fear/extractor/typed_identifier_matcher_spec.rb +62 -0
- data/spec/fear/extractor/value_matcher_number_spec.rb +77 -0
- data/spec/fear/extractor/value_matcher_string_spec.rb +86 -0
- data/spec/fear/extractor/value_matcher_symbol_spec.rb +69 -0
- data/spec/fear/extractor_api_spec.rb +113 -0
- data/spec/fear/extractor_spec.rb +59 -0
- data/spec/fear/failure_spec.rb +73 -13
- data/spec/fear/for_spec.rb +35 -35
- data/spec/fear/future_spec.rb +466 -0
- data/spec/fear/guard_spec.rb +4 -4
- data/spec/fear/left_spec.rb +40 -14
- data/spec/fear/none_spec.rb +28 -12
- data/spec/fear/option/mixin_spec.rb +37 -0
- data/spec/fear/option_pattern_match_spec.rb +7 -9
- data/spec/fear/partial_function_spec.rb +25 -3
- data/spec/fear/pattern_match_spec.rb +33 -1
- data/spec/fear/promise_spec.rb +94 -0
- data/spec/fear/right_spec.rb +37 -9
- data/spec/fear/some_spec.rb +32 -6
- data/spec/fear/success_spec.rb +32 -4
- data/spec/fear/try/mixin_spec.rb +17 -0
- data/spec/fear/try_pattern_match_spec.rb +8 -10
- data/spec/spec_helper.rb +1 -1
- metadata +115 -20
- data/Appraisals +0 -32
- data/gemfiles/dry_equalizer_0.1.0.gemfile +0 -8
- data/gemfiles/dry_equalizer_0.1.0.gemfile.lock +0 -82
- data/gemfiles/dry_equalizer_0.2.1.gemfile +0 -8
- data/lib/fear/done.rb +0 -22
- data/spec/fear/option_spec.rb +0 -15
data/Appraisals
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
ruby_versions = %w[2.4.5 2.5.3 2.6.1]
|
4
|
-
dry_equalizer_versions = %w[0.1.0 0.2.1]
|
5
|
-
|
6
|
-
dry_equalizer_versions.each do |version|
|
7
|
-
appraise "dry-equalizer-#{version}" do
|
8
|
-
gem 'dry-equalizer', version
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Dir.glob('gemfiles/*.gemfile').tap do |gemfiles|
|
13
|
-
travis = ::YAML.dump(
|
14
|
-
'cache' => {
|
15
|
-
'bundler' => true,
|
16
|
-
},
|
17
|
-
'language' => 'ruby',
|
18
|
-
'rvm' => ruby_versions,
|
19
|
-
'before_script' => [
|
20
|
-
'bundle install',
|
21
|
-
],
|
22
|
-
'script' => [
|
23
|
-
'bundle exec rspec',
|
24
|
-
'bundle exec rubocop --fail-level C',
|
25
|
-
],
|
26
|
-
'gemfile' => gemfiles,
|
27
|
-
)
|
28
|
-
|
29
|
-
::File.open('.travis.yml', 'w+') do |file|
|
30
|
-
file.write(travis)
|
31
|
-
end
|
32
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/baweaver/qo.git
|
3
|
-
revision: 8951ce899559118eb60321014b43cf4211730bd0
|
4
|
-
specs:
|
5
|
-
qo (0.99.0)
|
6
|
-
any (= 0.1.0)
|
7
|
-
|
8
|
-
PATH
|
9
|
-
remote: ..
|
10
|
-
specs:
|
11
|
-
fear (0.11.0)
|
12
|
-
dry-equalizer (<= 0.2.1)
|
13
|
-
|
14
|
-
GEM
|
15
|
-
remote: https://rubygems.org/
|
16
|
-
specs:
|
17
|
-
any (0.1.0)
|
18
|
-
appraisal (2.2.0)
|
19
|
-
bundler
|
20
|
-
rake
|
21
|
-
thor (>= 0.14.0)
|
22
|
-
ast (2.4.0)
|
23
|
-
benchmark-ips (2.7.2)
|
24
|
-
diff-lcs (1.3)
|
25
|
-
dry-equalizer (0.1.0)
|
26
|
-
dry-matcher (0.7.0)
|
27
|
-
jaro_winkler (1.5.2)
|
28
|
-
parallel (1.14.0)
|
29
|
-
parser (2.6.0.0)
|
30
|
-
ast (~> 2.4.0)
|
31
|
-
powerpack (0.1.2)
|
32
|
-
psych (3.1.0)
|
33
|
-
rainbow (3.0.0)
|
34
|
-
rake (10.5.0)
|
35
|
-
rspec (3.8.0)
|
36
|
-
rspec-core (~> 3.8.0)
|
37
|
-
rspec-expectations (~> 3.8.0)
|
38
|
-
rspec-mocks (~> 3.8.0)
|
39
|
-
rspec-core (3.8.0)
|
40
|
-
rspec-support (~> 3.8.0)
|
41
|
-
rspec-expectations (3.8.2)
|
42
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
-
rspec-support (~> 3.8.0)
|
44
|
-
rspec-mocks (3.8.0)
|
45
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.8.0)
|
47
|
-
rspec-support (3.8.0)
|
48
|
-
rubocop (0.65.0)
|
49
|
-
jaro_winkler (~> 1.5.1)
|
50
|
-
parallel (~> 1.10)
|
51
|
-
parser (>= 2.5, != 2.5.1.1)
|
52
|
-
powerpack (~> 0.1)
|
53
|
-
psych (>= 3.1.0)
|
54
|
-
rainbow (>= 2.2.2, < 4.0)
|
55
|
-
ruby-progressbar (~> 1.7)
|
56
|
-
unicode-display_width (~> 1.4.0)
|
57
|
-
rubocop-rspec (1.32.0)
|
58
|
-
rubocop (>= 0.60.0)
|
59
|
-
ruby-progressbar (1.10.0)
|
60
|
-
thor (0.20.3)
|
61
|
-
unicode-display_width (1.4.1)
|
62
|
-
yard (0.9.18)
|
63
|
-
|
64
|
-
PLATFORMS
|
65
|
-
ruby
|
66
|
-
|
67
|
-
DEPENDENCIES
|
68
|
-
appraisal
|
69
|
-
benchmark-ips
|
70
|
-
bundler
|
71
|
-
dry-equalizer (= 0.1.0)
|
72
|
-
dry-matcher
|
73
|
-
fear!
|
74
|
-
qo!
|
75
|
-
rake (~> 10.0)
|
76
|
-
rspec (~> 3.1)
|
77
|
-
rubocop (= 0.65.0)
|
78
|
-
rubocop-rspec (= 1.32.0)
|
79
|
-
yard
|
80
|
-
|
81
|
-
BUNDLED WITH
|
82
|
-
1.16.2
|
data/lib/fear/done.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Fear
|
2
|
-
# Typically used to signal completion but there is no actual value completed.
|
3
|
-
#
|
4
|
-
# @example
|
5
|
-
# if user.valid?
|
6
|
-
# Right(Done)
|
7
|
-
# else
|
8
|
-
# Left(user.errors)
|
9
|
-
# end
|
10
|
-
#
|
11
|
-
Done = Object.new.tap do |done|
|
12
|
-
# @return [String]
|
13
|
-
def done.to_s
|
14
|
-
'Done'
|
15
|
-
end
|
16
|
-
|
17
|
-
# @return [String]
|
18
|
-
def done.inspect
|
19
|
-
'Done'
|
20
|
-
end
|
21
|
-
end.freeze
|
22
|
-
end
|
data/spec/fear/option_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
RSpec.describe Fear::Option do
|
2
|
-
include Fear::Option::Mixin
|
3
|
-
|
4
|
-
describe '#Option()' do
|
5
|
-
context 'value is nil' do
|
6
|
-
subject { Option(nil) }
|
7
|
-
it { is_expected.to eq(None()) }
|
8
|
-
end
|
9
|
-
|
10
|
-
context 'value is not nil' do
|
11
|
-
subject { Option(42) }
|
12
|
-
it { is_expected.to eq(Some(42)) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|