steppy 0.5.4 → 0.6.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
  SHA256:
3
- metadata.gz: f2969c8372d3a0376c291cc217e47c45c9cea6fabafd28ccc13556546aaab279
4
- data.tar.gz: 8c9338e9ebce22988467f05e4a2f28b14452fc68adecca428890411f3f3cd48b
3
+ metadata.gz: 8a3e69bd0bf6da2bc6ad68601777f7aaf6c350afabf6f899db8dcb244ea9ebcf
4
+ data.tar.gz: c2e3b695f6f791c3c90c523c357915071fe0a5cff19151d10ca4bed3b795e3b0
5
5
  SHA512:
6
- metadata.gz: 80899b0790ae1222e0cad723139f8ea684bc19eee4968d82e1a1a72c9a80a0d81aef9473722e2cc07932bec1da9bf4c4514e35dbbacfaeecd760efee88377960
7
- data.tar.gz: 2596206005472684f1797fab86859a00267f97b097064a25396683c48801ed2053c40ebdc8ef0368ab3c64d05c77b9529a90c986bd559f5ac6daf17bfdd8a678
6
+ metadata.gz: c694feb7e483edbee03a84d936f5d64295911c318232ec31ea6f7ba9b58068d199cec2df97e1f9f14284387dd01c0e0c56b20f18e7c61d63ddfcac668110dbb0
7
+ data.tar.gz: 4865f642107ed0cfd33d1c5ac2200cdeef40adc71407e73f9cd349f33994c556fcc65f44556faa66b7000a7c3a199496bfed05297087b05bb305fa97692854e3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- steppy (0.5.4)
4
+ steppy (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -16,7 +16,12 @@ module Steppy
16
16
  if !defined? step
17
17
  def step(method, **args, &block)
18
18
  args[:prefix] ||= :step
19
- steppy_add step_method: method, step_args: args, step_block: block
19
+
20
+ steppy_add(
21
+ step_method: method,
22
+ step_args: args,
23
+ step_block: block,
24
+ )
20
25
  end
21
26
  end
22
27
 
@@ -26,6 +31,15 @@ module Steppy
26
31
  end
27
32
  end
28
33
 
34
+ if !defined? step_unless
35
+ def step_unless(condition, &block)
36
+ steppy_add(
37
+ step_if: -> { !steppy_run_block(condition) },
38
+ step_block: block,
39
+ )
40
+ end
41
+ end
42
+
29
43
  if !defined? step_set
30
44
  def step_set(*sets)
31
45
  steppy_cache[:sets] = *sets
@@ -91,16 +105,24 @@ module Steppy
91
105
  end
92
106
  end
93
107
 
94
- def steppy_run_steps(steps)
95
- if !steps
96
- return
97
- end
108
+ def steppy_run_step(step)
109
+ step_method = step[:step_method]
98
110
 
99
- steps.each do |step|
100
- @steppy[:result] = step.key?(:step_if) ? steppy_if_block(step) : steppy_step(step)
111
+ if step.key?(:step_if)
112
+ steppy_if_block(step)
113
+ elsif step_method.is_a? Proc
114
+ steppy_run_block(step_method)
115
+ else
116
+ steppy_step(step)
101
117
  end
102
118
  end
103
119
 
120
+ def steppy_run_steps(steps)
121
+ return if !steps
122
+
123
+ steps.each { |step| @steppy[:result] = steppy_run_step(step) }
124
+ end
125
+
104
126
  def steppy_step(step_method:, step_args:, step_block:)
105
127
  if steppy_if(step_args[:if]) || @steppy_prefix != step_args[:prefix]
106
128
  return
@@ -109,15 +131,15 @@ module Steppy
109
131
  method_name = "#{@steppy_prefix}_#{step_method}"
110
132
 
111
133
  result = if step_block
112
- steppy_run_block(step_block, steppy_attributes)
134
+ steppy_run_block(step_block)
113
135
  else
114
- steppy_run_method(method_name, steppy_attributes)
136
+ steppy_run_method(method_name)
115
137
  end
116
138
 
117
139
  steppy_set(step_args[:set], result)
118
140
  end
119
141
 
120
- def steppy_run_method(method_name, steppy_attributes)
142
+ def steppy_run_method(method_name)
121
143
  if method(method_name).arity > 0
122
144
  public_send(method_name, steppy_attributes)
123
145
  else
@@ -125,10 +147,11 @@ module Steppy
125
147
  end
126
148
  end
127
149
 
128
- def steppy_run_block(step_block, steppy_attributes)
150
+ def steppy_run_block(step_block)
129
151
  if step_block.arity > 0
130
152
  instance_exec(steppy_attributes, &step_block)
131
- else instance_exec(&step_block)
153
+ else
154
+ instance_exec(&step_block)
132
155
  end
133
156
  end
134
157
 
@@ -9,8 +9,6 @@ class SteppyError < StandardError
9
9
  if step
10
10
  @step = step
11
11
  message = step.to_json
12
- else
13
- message = 'Steppy Failed!'
14
12
  end
15
13
 
16
14
  super(message)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Steppy
4
- VERSION = '0.5.4'
4
+ VERSION = '0.6.0'
5
5
  end
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: 0.5.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler