Not really a parser, more an AST builder.
pdef = Ruote.define :name => 'take_out_garbage' do
sequence do
take_out_regular_garbage
take_out_glass
take_out_paper
end
end
engine.launch(pdef)
Performs ‘dollar substitution’ on a piece of text with as input a flow expression and a workitem (fields and variables).
Returns true if the string seems to correpond to a URI
TODO : wouldn‘t it be better to simply use URI.parse() ?
h = { ‘a’ => { ‘b’ => [ 1, 3, 4 ] } }
p Ruote.lookup(h, ‘a.b.1’) # => 3
This method is used by the ‘subprocess’ expression and by the EngineParticipant.
Same as Ruote.define()
pdef = Ruote.process_definition :name => 'take_out_garbage' do
sequence do
take_out_regular_garbage
take_out_paper
end
end
engine.launch(pdef)
h = { ‘customer’ => { ‘name’ => ‘alpha’ } }
Ruote.set(h, ‘customer.name’, ‘bravo’)
h #=> { ‘customer’ => { ‘name’ => ‘bravo’ } }
Similar in purpose to Ruote.define and Ruote.process_definition but instead of returning a [process] definition, returns the tree.
tree = Ruote.process_definition :name => 'take_out_garbage' do
sequence do
take_out_regular_garbage
take_out_paper
end
end
p tree
# => [ 'sequence', {}, [ [ 'take_out_regular_garbage', {}, [] ], [ 'take_out_paper', {}, [] ] ] ],
This is useful when modifying a process instance via methods like re_apply :
engine.re_apply(
fei,
:tree => Ruote.to_tree {
sequence do
participant 'alfred'
participant 'bob'
end
})
#
# cancels the segment of process at fei and replaces it with
# a simple alfred-bob sequence.
Turning a tree into a numbered string view
require 'ruote/util/tree'
require 'ruote/parser/ruby_dsl'
pdef = Ruote.process_definition :name => 'def0' do
sequence do
alpha
bravo
end
end
p pdef
# => ["define", {"name"=>"def0"}, [["sequence", {}, [["alpha", {}, []], ["bravo", {}, []]]]]]
puts Ruote.tree_to_s(pdef)
# =>
# 0 define {"name"=>"def0"}
# 0_0 sequence {}
# 0_0_0 alpha {}
# 0_0_1 bravo {}
h = { ‘customer’ => { ‘name’ => ‘alpha’, ‘rank’ => ‘1st’ } } r = Ruote.unset(h, ‘customer.rank’)
h # => { ‘customer’ => { ‘name’ => ‘alpha’ } } r # => ‘1st‘