Module: Simplerubysteps
- Defined in:
- lib/simplerubysteps.rb,
lib/simplerubysteps/version.rb
Defined Under Namespace
Classes: Callback, Choice, ChoiceItem, State, StateMachine, Task
Constant Summary
collapse
- VERSION =
"0.0.5"
Instance Method Summary
collapse
Instance Method Details
#action(&action_block) ⇒ Object
219
220
221
|
# File 'lib/simplerubysteps.rb', line 219
def action(&action_block)
$tasks.last.action &action_block
end
|
#callback(name) ⇒ Object
209
210
211
212
213
214
215
216
217
|
# File 'lib/simplerubysteps.rb', line 209
def callback(name)
t = $sm.add Callback.new(name)
$tasks.last.next = t if $tasks.last
$tasks.push t
yield if block_given?
$tasks.pop
end
|
#choice(name) ⇒ Object
246
247
248
249
250
251
252
253
254
|
# File 'lib/simplerubysteps.rb', line 246
def choice(name)
t = $sm.add Choice.new(name)
$tasks.last.next = t if $tasks.last
$tasks.push t
yield if block_given?
$tasks.pop
end
|
#default ⇒ Object
269
270
271
272
273
|
# File 'lib/simplerubysteps.rb', line 269
def default
$tasks.push $tasks.last
yield if block_given?
$tasks.pop
end
|
#default_transition_to(state) ⇒ Object
240
241
242
243
244
|
# File 'lib/simplerubysteps.rb', line 240
def default_transition_to(state)
choice = $tasks.last.implicit_choice
choice.default = state
end
|
#function_name ⇒ Object
9
10
11
12
|
# File 'lib/simplerubysteps.rb', line 9
def function_name
return "unknown" unless $FUNCTION_ARN =~ /.+\:function\:(.+)/
$1
end
|
#kind(k) ⇒ Object
195
196
197
|
# File 'lib/simplerubysteps.rb', line 195
def kind(k)
$sm.kind = k
end
|
#string_matches(var, match) ⇒ Object
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/simplerubysteps.rb', line 256
def string_matches(var, match)
c = ChoiceItem.new({
:Variable => var,
:StringMatches => match,
})
$tasks.last.add c
$tasks.push c
yield if block_given?
$tasks.pop
end
|
#task(name) ⇒ Object
199
200
201
202
203
204
205
206
207
|
# File 'lib/simplerubysteps.rb', line 199
def task(name)
t = $sm.add Task.new(name)
$tasks.last.next = t if $tasks.last
$tasks.push t
yield if block_given?
$tasks.pop
end
|
#transition(state) ⇒ Object
223
224
225
|
# File 'lib/simplerubysteps.rb', line 223
def transition(state)
$tasks.last.next = state
end
|
#transition_to(state, &condition_block) ⇒ Object
227
228
229
230
231
232
233
234
235
236
237
238
|
# File 'lib/simplerubysteps.rb', line 227
def transition_to(state, &condition_block)
choice = $tasks.last.implicit_choice
c = ChoiceItem.new({
:Variable => "$.#{choice.name}_#{state}",
:StringMatches => "yes",
})
c.next = state
c.implicit_condition_block = condition_block
choice.add c
end
|