waterfall 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/.travis.yml +15 -8
- data/Gemfile +1 -3
- data/Gemfile.lock +15 -25
- data/changelog.md +4 -0
- data/lib/waterfall.rb +23 -6
- data/lib/waterfall/predicates/chain.rb +2 -0
- data/lib/waterfall/version.rb +1 -1
- data/spec/spec_helper.rb +0 -3
- data/spec/wf_object_spec.rb +53 -6
- data/waterfall.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd6e3cd5ae2df5e4e6121b46e1ad127a9613b39b
|
4
|
+
data.tar.gz: bd9634100ae693fd84e1a6ed7b2c362395be627b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89668b9efe963d440bb839827984a73e2b14ef3f3d1eeb4879a40c80ebf33465cde450685e392a0168b77686024413ff0257e1dcd10e0304ca3fe4c0dea5f90e
|
7
|
+
data.tar.gz: a425c2ced04535bca474ebff300070664172735bb120a22cea2d4e29b7f8d758042b9a702101d1bc232a373b558fbaa6f4da00b64e57b7b19490142b3b5f2f12
|
data/.travis.yml
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
language: ruby
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- CC_TEST_REPORTER_ID=06ba7b4d95c2d056ef2b66c86e9d69f24dceee54354c1ab2ce1397f8f309b0a4
|
2
5
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
- 2.1.10
|
7
|
+
- 2.2.8
|
8
|
+
- 2.3.5
|
9
|
+
- 2.4.2
|
10
|
+
before_script:
|
11
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
12
|
+
- chmod +x ./cc-test-reporter
|
13
|
+
- ./cc-test-reporter before-build
|
14
|
+
script:
|
15
|
+
- bundle exec rspec
|
16
|
+
after_script:
|
17
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waterfall (1.
|
4
|
+
waterfall (1.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
codeclimate-test-reporter (0.4.7)
|
10
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
11
9
|
coderay (1.1.0)
|
12
|
-
diff-lcs (1.
|
13
|
-
docile (1.1.5)
|
14
|
-
json (1.8.2)
|
10
|
+
diff-lcs (1.3)
|
15
11
|
method_source (0.8.2)
|
16
12
|
pry (0.10.1)
|
17
13
|
coderay (~> 1.1.0)
|
@@ -20,36 +16,30 @@ GEM
|
|
20
16
|
pry-nav (0.2.4)
|
21
17
|
pry (>= 0.9.10, < 0.11.0)
|
22
18
|
rake (10.3.2)
|
23
|
-
rspec (3.
|
24
|
-
rspec-core (~> 3.
|
25
|
-
rspec-expectations (~> 3.
|
26
|
-
rspec-mocks (~> 3.
|
27
|
-
rspec-core (3.
|
28
|
-
rspec-support (~> 3.
|
29
|
-
rspec-expectations (3.
|
19
|
+
rspec (3.6.0)
|
20
|
+
rspec-core (~> 3.6.0)
|
21
|
+
rspec-expectations (~> 3.6.0)
|
22
|
+
rspec-mocks (~> 3.6.0)
|
23
|
+
rspec-core (3.6.0)
|
24
|
+
rspec-support (~> 3.6.0)
|
25
|
+
rspec-expectations (3.6.0)
|
30
26
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-mocks (3.
|
27
|
+
rspec-support (~> 3.6.0)
|
28
|
+
rspec-mocks (3.6.0)
|
33
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-support (3.
|
36
|
-
simplecov (0.10.0)
|
37
|
-
docile (~> 1.1.0)
|
38
|
-
json (~> 1.8)
|
39
|
-
simplecov-html (~> 0.10.0)
|
40
|
-
simplecov-html (0.10.0)
|
30
|
+
rspec-support (~> 3.6.0)
|
31
|
+
rspec-support (3.6.0)
|
41
32
|
slop (3.6.0)
|
42
33
|
|
43
34
|
PLATFORMS
|
44
35
|
ruby
|
45
36
|
|
46
37
|
DEPENDENCIES
|
47
|
-
bundler (~> 1.
|
48
|
-
codeclimate-test-reporter
|
38
|
+
bundler (~> 1.14)
|
49
39
|
pry (> 0.10)
|
50
40
|
pry-nav
|
51
41
|
rake
|
52
|
-
rspec (= 3.
|
42
|
+
rspec (= 3.6)
|
53
43
|
waterfall!
|
54
44
|
|
55
45
|
BUNDLED WITH
|
data/changelog.md
CHANGED
data/lib/waterfall.rb
CHANGED
@@ -42,12 +42,10 @@ module Waterfall
|
|
42
42
|
|
43
43
|
def dam(obj)
|
44
44
|
raise IncorrectDamArgumentError.new("You cant dam with a falsy object") unless obj
|
45
|
-
_wf_run
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@error_pool = nil
|
50
|
-
self
|
45
|
+
_wf_run do
|
46
|
+
@error_pool = obj
|
47
|
+
_reverse_flows(true)
|
48
|
+
end
|
51
49
|
end
|
52
50
|
|
53
51
|
def halt_chain(&block)
|
@@ -71,6 +69,25 @@ module Waterfall
|
|
71
69
|
self
|
72
70
|
end
|
73
71
|
|
72
|
+
def reverse_flow
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
|
77
|
+
def _reverse_flows(skip_self)
|
78
|
+
return if @flow_reversed
|
79
|
+
@flow_reversed = true
|
80
|
+
reverse_flow unless skip_self
|
81
|
+
(@_executed_flows || []).reverse_each do |f|
|
82
|
+
f.send :_reverse_flows, false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def _add_executed_flow(flow)
|
87
|
+
@_executed_flows ||= []
|
88
|
+
@_executed_flows.push(flow)
|
89
|
+
end
|
90
|
+
|
74
91
|
def _wf_run
|
75
92
|
@has_flown = true
|
76
93
|
@outflow ||= OpenStruct.new({})
|
data/lib/waterfall/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/wf_object_spec.rb
CHANGED
@@ -54,12 +54,6 @@ describe Flow do
|
|
54
54
|
expect { wf.dam(nil) }.to raise_error(Waterfall::IncorrectDamArgumentError)
|
55
55
|
end
|
56
56
|
|
57
|
-
it 'can be undammed' do
|
58
|
-
wf.dam('error').undam
|
59
|
-
expect(wf.dammed?).to be false
|
60
|
-
expect(wf.error_pool).to eq nil
|
61
|
-
end
|
62
|
-
|
63
57
|
it 'can be dammed conditionnaly (falsy)' do
|
64
58
|
wf.when_falsy { false }.dam { 'error' }
|
65
59
|
expect(wf.dammed?).to be true
|
@@ -121,6 +115,59 @@ describe Flow do
|
|
121
115
|
it "returns what the block returns" do
|
122
116
|
expect(wf.halt_chain { "return value" }).to eq "return value"
|
123
117
|
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'reverse_flow' do
|
121
|
+
let(:parent_flow) { Flow.new }
|
122
|
+
let(:sub_flow1) { Flow.new }
|
123
|
+
let(:sub_flow2) { Flow.new }
|
124
|
+
let(:sub_flow3) { Flow.new }
|
125
|
+
let(:sub_sub_flow1) { Flow.new }
|
126
|
+
let(:sub_sub_flow2) { Flow.new }
|
127
|
+
let(:sub_sub_flow3) { Flow.new }
|
128
|
+
let(:sub_sub_sub_flow1) { Flow.new }
|
129
|
+
|
130
|
+
def action
|
131
|
+
parent_flow
|
132
|
+
.chain { sub_flow1 }
|
133
|
+
.chain do
|
134
|
+
sub_flow2
|
135
|
+
.chain do
|
136
|
+
sub_sub_flow1.chain { sub_sub_sub_flow1 }
|
137
|
+
end
|
138
|
+
.chain { sub_sub_flow2 }
|
139
|
+
.when_truthy { true }.dam { 'errr' }
|
140
|
+
.chain { sub_sub_flow3 }
|
141
|
+
end
|
142
|
+
.chain { sub_flow3 }
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'does not trigger reverse_flow on initial dammed flow' do
|
146
|
+
expect(sub_flow2).to_not receive(:reverse_flow)
|
147
|
+
|
148
|
+
action
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'does not trigger reverse_flow on parent_flow' do
|
152
|
+
expect(parent_flow).to_not receive(:reverse_flow)
|
153
|
+
|
154
|
+
action
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'is called on all executed sub flows' do
|
158
|
+
expect(sub_sub_flow2).to receive(:reverse_flow).once.ordered
|
159
|
+
expect(sub_sub_flow1).to receive(:reverse_flow).once.ordered
|
160
|
+
expect(sub_sub_sub_flow1).to receive(:reverse_flow).once.ordered
|
161
|
+
expect(sub_flow1).to receive(:reverse_flow).once.ordered
|
124
162
|
|
163
|
+
action
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'is not called on non executed sub flows' do
|
167
|
+
expect(sub_sub_flow3).to_not receive(:reverse_flow)
|
168
|
+
expect(sub_flow3).to_not receive(:reverse_flow)
|
169
|
+
|
170
|
+
action
|
171
|
+
end
|
125
172
|
end
|
126
173
|
end
|
data/waterfall.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
22
22
|
spec.add_development_dependency "pry", '>0.10'
|
23
23
|
spec.add_development_dependency "pry-nav"
|
24
24
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec", "3.
|
25
|
+
spec.add_development_dependency "rspec", "3.6"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waterfall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Roth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.14'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.6'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.6'
|
83
83
|
description: A slice of functional programming to chain ruby services and blocks.
|
84
84
|
Make them flow!
|
85
85
|
email:
|