waterfall 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27aca92eae9decca2d3a32be3293985de0b219e1
4
- data.tar.gz: d9e95c5a4a7aa9438f06bd67337bd5a87e7c8dd8
3
+ metadata.gz: cd6e3cd5ae2df5e4e6121b46e1ad127a9613b39b
4
+ data.tar.gz: bd9634100ae693fd84e1a6ed7b2c362395be627b
5
5
  SHA512:
6
- metadata.gz: e178dab7e10f42a2215c17cd991d3af286a07908bd2e4c3d4f8f3b8769ee576a8c9e455af3a57c037a866bd3693aecf940894ef601f4684f3b4bbfeb15873f73
7
- data.tar.gz: eac428e1c45e83e652451bf37fa972bbe03db7ad90c61c47a8597d7b512852d33c48d5010531fc78b52b006a9dc8bee71dd5d5b80f8931c7e9138f18addbd2de
6
+ metadata.gz: 89668b9efe963d440bb839827984a73e2b14ef3f3d1eeb4879a40c80ebf33465cde450685e392a0168b77686024413ff0257e1dcd10e0304ca3fe4c0dea5f90e
7
+ data.tar.gz: a425c2ced04535bca474ebff300070664172735bb120a22cea2d4e29b7f8d758042b9a702101d1bc232a373b558fbaa6f4da00b64e57b7b19490142b3b5f2f12
@@ -1,10 +1,17 @@
1
1
  language: ruby
2
+ env:
3
+ global:
4
+ - CC_TEST_REPORTER_ID=06ba7b4d95c2d056ef2b66c86e9d69f24dceee54354c1ab2ce1397f8f309b0a4
2
5
  rvm:
3
- - 2.0.0
4
- - 2.1.0
5
- - 2.2.0
6
- - 2.3.0
7
- script: bundle exec rspec spec
8
- addons:
9
- code_climate:
10
- repo_token: 06ba7b4d95c2d056ef2b66c86e9d69f24dceee54354c1ab2ce1397f8f309b0a4
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
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in waterfall.gemspec
4
- gemspec
5
-
6
- gem "codeclimate-test-reporter", group: :test, require: nil
4
+ gemspec
@@ -1,17 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waterfall (1.1.0)
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.2.5)
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.2.0)
24
- rspec-core (~> 3.2.0)
25
- rspec-expectations (~> 3.2.0)
26
- rspec-mocks (~> 3.2.0)
27
- rspec-core (3.2.3)
28
- rspec-support (~> 3.2.0)
29
- rspec-expectations (3.2.1)
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.2.0)
32
- rspec-mocks (3.2.1)
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.2.0)
35
- rspec-support (3.2.2)
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.3)
48
- codeclimate-test-reporter
38
+ bundler (~> 1.14)
49
39
  pry (> 0.10)
50
40
  pry-nav
51
41
  rake
52
- rspec (= 3.2)
42
+ rspec (= 3.6)
53
43
  waterfall!
54
44
 
55
45
  BUNDLED WITH
@@ -1,3 +1,7 @@
1
+ ===1.2.0
2
+ - Removed `undam`.
3
+ - Introduced `reverse_flow`
4
+
1
5
  ===1.1.0
2
6
  - Removed `chain_wf`.
3
7
  - Introduced `halt_chain`
@@ -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 { @error_pool = obj }
46
- end
47
-
48
- def undam
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({})
@@ -24,6 +24,8 @@ module Waterfall
24
24
  @root.update_outflow(k, child_waterfall.outflow[v])
25
25
  end
26
26
 
27
+ @root.send :_add_executed_flow, child_waterfall
28
+
27
29
  if child_waterfall.dammed?
28
30
  @root.dam child_waterfall.error_pool
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module Waterfall
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -5,9 +5,6 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
 
8
- require "codeclimate-test-reporter"
9
- CodeClimate::TestReporter.start
10
-
11
8
  require File.expand_path('../../lib/waterfall', __FILE__)
12
9
  require 'pry'
13
10
 
@@ -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
@@ -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.3"
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.2"
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.1.0
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-08-21 00:00:00.000000000 Z
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.3'
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.3'
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.2'
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.2'
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: