steppy 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/steppy/class_methods.rb +19 -9
- data/lib/steppy/instance_methods.rb +12 -4
- data/lib/steppy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06bbbf8061978cb442a6dbd96a98c07bf4c856866674b7bd8719b76f3593ccef
|
4
|
+
data.tar.gz: 64c95196b0f8217622cf027d25b036987dbf0f82b86da162f94043bf36235aeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db545b9c0870ada505a73f5b4420e534f702ebfc4f950c158e64f7bf55d32b51e526fcef3c428dda9e7d2818998431bb7d0fd7fd6c7ba1898d355bd9e8b8461c
|
7
|
+
data.tar.gz: d8505d24ce6978a85043fa27a4ba2149ac86be5061819aff27377cb067a9cfb6edc2388a35c7015092603e4b4b0ff784c990807a729829137e8d3922b1627fcd
|
data/Gemfile.lock
CHANGED
data/lib/steppy/class_methods.rb
CHANGED
@@ -12,7 +12,7 @@ module Steppy
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def step(method = nil, args = {}, &block)
|
15
|
-
|
15
|
+
steps_cache.push(
|
16
16
|
Steppy.parse_step(method: method, args: args, block: block)
|
17
17
|
)
|
18
18
|
self
|
@@ -21,12 +21,12 @@ module Steppy
|
|
21
21
|
alias step_return step
|
22
22
|
|
23
23
|
def step_if(condition, &block)
|
24
|
-
|
24
|
+
steps_cache.push(condition: condition, block: block)
|
25
25
|
self
|
26
26
|
end
|
27
27
|
|
28
28
|
def step_unless(condition, &block)
|
29
|
-
|
29
|
+
steps_cache.push(condition: -> { !steppy_run_condition(condition) }, block: block)
|
30
30
|
self
|
31
31
|
end
|
32
32
|
|
@@ -38,14 +38,14 @@ module Steppy
|
|
38
38
|
def step_if_else(condition_block, step_steps, args = {})
|
39
39
|
if_step, else_step = step_steps
|
40
40
|
|
41
|
-
|
41
|
+
steps_cache.push Steppy.parse_step(
|
42
42
|
method: if_step,
|
43
43
|
args: {
|
44
44
|
if: condition_block,
|
45
45
|
}.merge(args)
|
46
46
|
)
|
47
47
|
|
48
|
-
|
48
|
+
steps_cache.push Steppy.parse_step(
|
49
49
|
method: else_step,
|
50
50
|
args: {
|
51
51
|
unless: condition_block,
|
@@ -57,17 +57,25 @@ module Steppy
|
|
57
57
|
step_add_callback(:after, block, key)
|
58
58
|
end
|
59
59
|
|
60
|
+
def step_after_all(&block)
|
61
|
+
step_add_callback(:after, block, :all)
|
62
|
+
end
|
63
|
+
|
60
64
|
def step_before(key = nil, &block)
|
61
65
|
step_add_callback(:before, block, key)
|
62
66
|
end
|
63
67
|
|
68
|
+
def step_before_all(&block)
|
69
|
+
step_add_callback(:before, block, :all)
|
70
|
+
end
|
71
|
+
|
64
72
|
def step_add_callback(type, block, key)
|
65
|
-
callback_key = key ? key.to_sym : :
|
73
|
+
callback_key = key ? key.to_sym : :each
|
66
74
|
callbacks = step_callbacks[type][callback_key] ||= []
|
67
75
|
callbacks.push(block)
|
68
76
|
end
|
69
77
|
|
70
|
-
def
|
78
|
+
def steps_cache
|
71
79
|
steppy_cache[:steps]
|
72
80
|
end
|
73
81
|
|
@@ -82,10 +90,12 @@ module Steppy
|
|
82
90
|
rescues: [],
|
83
91
|
callbacks: {
|
84
92
|
before: {
|
85
|
-
|
93
|
+
all: [],
|
94
|
+
each: [],
|
86
95
|
},
|
87
96
|
after: {
|
88
|
-
|
97
|
+
all: [],
|
98
|
+
each: [],
|
89
99
|
},
|
90
100
|
}
|
91
101
|
)
|
@@ -8,11 +8,17 @@ module Steppy
|
|
8
8
|
def steppy(attributes = {}, cache = {})
|
9
9
|
steppy_initialize_cache({ attributes: attributes, prefix: :step }.merge(cache))
|
10
10
|
|
11
|
-
|
11
|
+
step_run_callbacks(:before, :all, attributes)
|
12
|
+
|
13
|
+
result = if steppy_cache.key?(:block)
|
12
14
|
instance_exec(&steppy_cache[:block])
|
13
15
|
else
|
14
16
|
steppy_run(steppy_cache)
|
15
17
|
end
|
18
|
+
|
19
|
+
step_run_callbacks(:after, :all, attributes)
|
20
|
+
|
21
|
+
result
|
16
22
|
rescue StandardError => exception
|
17
23
|
steppy_rescue exception, steppy_cache[:rescues]
|
18
24
|
end
|
@@ -135,12 +141,14 @@ module Steppy
|
|
135
141
|
result
|
136
142
|
end
|
137
143
|
|
138
|
-
def step_run_callbacks(type, method, result, args)
|
144
|
+
def step_run_callbacks(type, method, result, args = result)
|
139
145
|
callbacks = step_callbacks[type]
|
140
146
|
method_callbacks = callbacks[method] || []
|
141
147
|
|
142
|
-
|
143
|
-
|
148
|
+
if method != :all
|
149
|
+
callbacks[:each].each do |callback|
|
150
|
+
instance_exec(result, args, &callback)
|
151
|
+
end
|
144
152
|
end
|
145
153
|
|
146
154
|
method_callbacks.each do |callback|
|
data/lib/steppy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steppy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|