waterfall 1.0.5 → 1.0.6

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: 152fb9437b8752b16fd77478ec2e12c0d9b6401f
4
- data.tar.gz: 5e6f25d4bd7c0e23c4a8cd16b921227ed5397a3a
3
+ metadata.gz: e52a3c6940723b7e9c59482c7e171194d3cea775
4
+ data.tar.gz: 6ea7ab247654ef7ded20428d387c160d8a9d4e95
5
5
  SHA512:
6
- metadata.gz: 597154dc366df15c6fe84f707c1206e82c624c77b57b818323e67347fd1d3e3f9f990b926d5c389060e2b75c1de71aa807ab7601b9735584cb8c138d40b26c6b
7
- data.tar.gz: 8004a1da08994b9e668113e348d5312503394d071be2f366fda20dda1650d7648aa19ecb1555a46beab22d6866bd23f1a9bdb10b29184b39bcafc79aad537aa7
6
+ metadata.gz: 89b68643618d10d2401c99780981e4e5dc684b90deed6c889c2bf7c237000ca8e530427d7b69229716dee7425559282d40946e0490e62bb3aa09f5e637dae788
7
+ data.tar.gz: 184a675a17e17452f99b163fb3761ad9b7abbbd4b83cc2164f46d6402de5556e2dc0786dccb4ecf2357b1df357c8b124a55f086a19724429f42c5e18daf6c823
data/README.md CHANGED
@@ -9,7 +9,7 @@ Chain ruby commands, and treat them like a flow, which provides a new approach t
9
9
 
10
10
  When logic is complicated, waterfalls show their true power and let you write intention revealing code. Above all they excel at chaining services.
11
11
 
12
- General presentation blog post there: [Chain services objects like a boss](https://medium.com/p/chain-service-objects-like-a-boss-35d0b83606ab).
12
+ General presentation blog post there: [Chain services objects like a boss](https://medium.com/p/chain-service-objects-like-a-boss-35d0b83606ab) and upcoming book: [the Unhappy path](https://leanpub.com/the-unhappy-path)
13
13
 
14
14
  #### Overview
15
15
 
@@ -43,11 +43,11 @@ end
43
43
  and call / chain:
44
44
 
45
45
  ```ruby
46
- Wf.new
47
- .chain(user1: :user) { FetchUser.new(1) }
48
- .chain(user2: :user) { FetchUser.new(2) }
49
- .chain {|outflow| puts(outflow.user1, outflow.user2) } # report success
50
- .on_dam {|error| puts(error) } # report error
46
+ Flow.new
47
+ .chain(user1: :user) { FetchUser.new(1) }
48
+ .chain(user2: :user) { FetchUser.new(2) }
49
+ .chain {|outflow| puts(outflow.user1, outflow.user2) } # report success
50
+ .on_dam {|error| puts(error) } # report error
51
51
  ```
52
52
 
53
53
  Which works like:
@@ -77,28 +77,30 @@ Wiki contains many details, please check appropriate pages:
77
77
  - [Wf Object](https://github.com/apneadiving/waterfall/wiki/Wf-object)
78
78
  - [Testing](https://github.com/apneadiving/waterfall/wiki/Testing)
79
79
 
80
+ ### Koans (!)
81
+ You can try and exercise your understanding of Waterfall using the [Koans here](https://github.com/apneadiving/waterfall_koans)
80
82
 
81
83
  ## Illustration of chaining
82
84
  Doing
83
85
  ```ruby
84
- Wf.new
85
- .chain(foo: :bar) { Wf.new.chain(:bar){ 1 } }
86
+ Flow.new
87
+ .chain(foo: :bar) { Flow.new.chain(:bar){ 1 } }
86
88
  ```
87
89
 
88
90
  is the same as doing:
89
91
 
90
92
  ```ruby
91
- Wf.new
92
- .chain do |outflow, parent_waterfall|
93
- unless parent_waterfall.dammed?
94
- child = Wf.new.chain(:bar){ 1 }
95
- if child.dammed?
96
- parent_waterfall.dam(child.error_pool)
97
- else
98
- parent_waterfall.ouflow.foo = child.outflow.bar
99
- end
100
- end
101
- end
93
+ Flow.new
94
+ .chain do |outflow, parent_waterfall|
95
+ unless parent_waterfall.dammed?
96
+ child = Wf.new.chain(:bar){ 1 }
97
+ if child.dammed?
98
+ parent_waterfall.dam(child.error_pool)
99
+ else
100
+ parent_waterfall.ouflow.foo = child.outflow.bar
101
+ end
102
+ end
103
+ end
102
104
  ```
103
105
 
104
106
  Hopefully you better get the chaining power this way.
@@ -117,13 +119,13 @@ end
117
119
  You may have noticed that I usually write:
118
120
 
119
121
  ```ruby
120
- Wf.new
121
- .chain { MyWaterfall.new }
122
+ Flow.new
123
+ .chain { MyWaterfall.new }
122
124
  ```
123
125
  instead of
124
126
  ```ruby
125
- Wf.new
126
- .chain { MyWaterfall.new.call }
127
+ Flow.new
128
+ .chain { MyWaterfall.new.call }
127
129
  ```
128
130
  Both are the same: if a block returns a waterfall which was not executed, it will execute it (hence the `call` convention)
129
131
 
@@ -207,7 +209,7 @@ class AuthenticateUser
207
209
  attr_reader :user
208
210
 
209
211
  def initialize(email, password)
210
- @email, @password = email, @password
212
+ @email, @password = email, password
211
213
  end
212
214
 
213
215
  def call
@@ -1,6 +1,18 @@
1
- ===1.0.3
1
+ ===1.0.6
2
+ Alias Wf with Flow
3
+
4
+ === 1.0.5
5
+ - naming: changed flowing to has_flown to clarify its not related to damming
6
+ - spec change
7
+
8
+ === 1.0.4
9
+ - add clearer error messages
10
+ - deprecate chain_wf
11
+ - prevent from damming falsy values
12
+
13
+ === 1.0.3
2
14
  - Small refactors
3
15
  - if waterfall 1 calls waterfall 2 and waterfall2 is dammed, now waterfall1 is able to get values from waterfall2's outflow
4
16
 
5
- ===1.0.2
6
- Initial release
17
+ === 1.0.2
18
+ Initial release
@@ -86,3 +86,5 @@ class Wf
86
86
  _wf_run {}
87
87
  end
88
88
  end
89
+
90
+ Flow = Wf
@@ -1,3 +1,3 @@
1
1
  module Waterfall
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -24,7 +24,7 @@ describe 'Chaining services' do
24
24
  end
25
25
  end
26
26
 
27
- let(:wf) { Wf.new }
27
+ let(:wf) { Flow.new }
28
28
  let(:listener) { spy 'listener', is_waterfall?: false }
29
29
 
30
30
  it 'you dont need to call child waterfalls, just pass the instance' do
@@ -1,7 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Wf do
4
- let(:wf) { Wf.new }
3
+ describe Flow do
4
+ let(:wf) { Flow.new }
5
+
6
+ it 'is aliased' do
7
+ expect(Flow).to eq Wf
8
+ end
5
9
 
6
10
  it 'is a waterfall' do
7
11
  expect(wf.is_waterfall?).to be true
@@ -91,11 +95,11 @@ describe Wf do
91
95
  end
92
96
 
93
97
  it 'raises if chain waterfall without hash mapping' do
94
- expect { wf.chain(:foo) { Wf.new } }.to raise_error(Waterfall::IncorrectChainingArgumentError, Waterfall::Chain::MAPPING_ERROR_MESSAGE)
98
+ expect { wf.chain(:foo) { Flow.new } }.to raise_error(Waterfall::IncorrectChainingArgumentError, Waterfall::Chain::MAPPING_ERROR_MESSAGE)
95
99
  end
96
100
 
97
101
  it 'warns against chain_wf' do
98
102
  expect(wf).to receive :warn
99
- wf.chain_wf { Wf.new }
103
+ wf.chain_wf { Flow.new }
100
104
  end
101
105
  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.0.5
4
+ version: 1.0.6
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-02-13 00:00:00.000000000 Z
11
+ date: 2017-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler