public
Created

  • Download Gist
.gitignore
1
*.swp
.rvmrc
1
rvm use 1.8.7-p334
Gemfile
Ruby
1 2 3 4 5
 
source :rubygems
 
gem 'ruote', '2.2.0'
#gem 'ruote', :git => 'git://github.com/jmettraux/ruote.git'
alex.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
 
require 'ruote'
 
$engine = Ruote::Engine.new(
Ruote::Worker.new(
Ruote::HashStorage.new))
 
# When I complete alpha with field "processed" set to "yes", the concurrence
# ends. I expect to see my second echo for field "processed" to be "yes", but
# it prints "no", therefore zeta never comes to play.
#
# It appears that the reason the value of field "processed" does not get merged
# over correctly is because I have a conditional branch (beta) and that
# condition evals as false. If I take out the beta branch (which should be
# equivalent to leaving it with false condition), OR leave it in without
# setting the :if condition, OR the :if condition evals a true value (i.e.,
# :if=>"${f:isok}= 'no'"), the value of 'processed' field printed out then is
# 'yes'.
 
pdef0 = Ruote.process_definition :name => 'mytest', :revision => '1' do
sequence do
 
#set :field => 'isok', :value => 'no'
set :field => 'isok', :value => 'yes'
 
#set :field => 'processed', :value => 'no'
 
echo '=== 0 processed: ${f:processed}'
 
concurrence :over_if => '${f:processed} == yes' do
#concurrence :over_if => '${f:processed} == yes', :merge_type => 'mix' do
alpha
beta :if => '${f:isok} == yes'
gamma
end
 
echo '=== 1 processed: ${f:processed}'
# prints 'no' even when it's set to 'yes' when completing alpha
 
zeta :if => '${f:processed} == yes'
end
end
 
pdef1 = Ruote.process_definition :name => 'mytest', :revision => '1' do
sequence do
 
set :field => 'isok', :value => 'no'
#set :field => 'isok', :value => 'yes'
 
#set :field => 'processed', :value => 'no'
 
echo '=== 0 processed: ${f:processed}'
 
concurrence :over_if => '${f:processed} == yes' do
#concurrence :over_if => '${f:processed} == yes', :merge_type => 'mix' do
alpha
beta :if => '${f:isok} == yes'
gamma
end
 
echo '=== 1 processed: ${f:processed}'
# prints 'no' even when it's set to 'yes' when completing alpha
 
zeta :if => '${f:processed} == yes'
end
end
 
pdef2 = Ruote.process_definition :name => 'mytest', :revision => '1' do
sequence do
 
set :field => 'isok', :value => 'no'
#set :field => 'isok', :value => 'yes'
 
#set :field => 'processed', :value => 'no'
 
echo '=== 0 processed: ${f:processed}'
 
#concurrence :over_if => '${f:processed} == yes' do
concurrence :over_if => '${f:processed} == yes', :merge_type => 'mix' do
alpha
beta :if => '${f:isok} == yes'
gamma
end
 
echo '=== 1 processed: ${f:processed}'
# prints 'no' even when it's set to 'yes' when completing alpha
 
zeta :if => '${f:processed} == yes'
end
end
 
pdef3 = Ruote.process_definition :name => 'mytest', :revision => '1' do
sequence do
 
#set :field => 'isok', :value => 'no'
set :field => 'isok', :value => 'yes'
 
#set :field => 'processed', :value => 'no'
 
echo '=== 0 processed: ${f:processed}'
 
#concurrence :over_if => '${f:processed} == yes' do
concurrence :over_if => '${f:processed} == yes', :merge_type => 'mix' do
alpha
beta :if => '${f:isok} == yes'
gamma
end
 
echo '=== 1 processed: ${f:processed}'
# prints 'no' even when it's set to 'yes' when completing alpha
 
zeta :if => '${f:processed} == yes'
end
end
 
$engine.register :alpha do |workitem|
p :alpha
workitem.fields['processed'] = 'yes'
end
$engine.register :beta do |workitem|
p :beta
end
$engine.register :gamma do |workitem|
sleep 0.5
p :gamma
end
$engine.register :zeta do |workitem|
p :zeta
end
 
#$engine.noisy = true
 
[ pdef0, pdef1, pdef2, pdef3 ].each do |pdef|
 
puts '-' * 80
puts Ruote::VERSION
puts
 
puts Ruote::Reader.to_ruby(pdef)
puts
 
wfid = $engine.launch(pdef)
$engine.wait_for(wfid)
puts
end
ruote_220_output.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
--------------------------------------------------------------------------------
2.2.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "yes"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
:beta
=== 1 processed: yes
:zeta
 
--------------------------------------------------------------------------------
2.2.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "no"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
=== 1 processed:
 
--------------------------------------------------------------------------------
2.2.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "no"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes", :merge_type => "mix" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:gamma
:alpha
=== 1 processed: yes
:zeta
 
--------------------------------------------------------------------------------
2.2.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "yes"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes", :merge_type => "mix" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
:gamma
:beta
:gamma
:gamma
=== 1 processed: yes
:zeta
ruote_230_output.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
--------------------------------------------------------------------------------
2.3.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "yes"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
:beta
=== 1 processed: yes
:zeta
:gamma
 
--------------------------------------------------------------------------------
2.3.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "no"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
=== 1 processed:
 
--------------------------------------------------------------------------------
2.3.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "no"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes", :merge_type => "mix" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
=== 1 processed: yes
:zeta
:gamma
 
--------------------------------------------------------------------------------
2.3.0
 
Ruote.process_definition :name => "mytest", :revision => "1" do
sequence do
set :field => "isok", :value => "yes"
echo "=== 0 processed: ${f:processed}"
concurrence :over_if => "${f:processed} == yes", :merge_type => "mix" do
alpha
beta :if => "${f:isok} == yes"
gamma
end
echo "=== 1 processed: ${f:processed}"
zeta :if => "${f:processed} == yes"
end
end
 
=== 0 processed:
:alpha
:beta
:gamma
:gamma
=== 1 processed: yes
:zeta

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.