Skip to content
Browse files

implemented Rufus::Decision::Participant

  • Loading branch information...
1 parent 982cbef commit 3c9710013d5755c54d20857aa5bb4688df7d161c @jmettraux committed
Showing with 78 additions and 4 deletions.
  1. +2 −0 CHANGELOG.txt
  2. +1 −1 TODO.txt
  3. +44 −0 lib/rufus/decision/participant.rb
  4. +6 −2 rufus-decision.gemspec
  5. +25 −1 test/ruote/rt_0_basic.rb
View
2 CHANGELOG.txt
@@ -4,6 +4,8 @@
== rufus-decision - 1.3.1 not yet released
+- implemented Rufus::Decision::Participant, a ruote participant
+
== rufus-decision - 1.3.0 released 2010/02/15
View
2 TODO.txt
@@ -4,8 +4,8 @@
[x] transform(h, options), :accumulate option ? NO
[o] something about demo in README
[o] demo/README.txt
+[o] ruote participant
[ ] non csv string representation ? JSON ?
[ ] dsl ?
-[ ] ruote participant
View
44 lib/rufus/decision/participant.rb
@@ -28,6 +28,50 @@
module Rufus::Decision
+ #
+ # Decision participants were named 'CSV participants' prior to ruote 2.1.
+ #
+ # Make sure you have the gem "rufus-decision" installed in order to
+ # use this decision participant.
+ #
+ # In this example, a participant named 'decide_team_member' is bound in the
+ # ruote engine and, depending on the value of the workitem fields 'topic'
+ # and region, sets the value of the field named 'team_member' :
+ #
+ # require 'rufus/decision/participant'
+ #
+ # engine.register_participant(
+ # :decide_team_member
+ # Rufus::Decision::Participant, :table => %{
+ # in:topic,in:region,out:team_member
+ # sports,europe,Alice
+ # sports,,Bob
+ # finance,america,Charly
+ # finance,europe,Donald
+ # finance,,Ernest
+ # politics,asia,Fujio
+ # politics,america,Gilbert
+ # politics,,Henry
+ # ,,Zach
+ # })
+ #
+ # pdef = Ruote.process_definition :name => 'dec-test', :revision => '1' do
+ # sequence do
+ # decide_team_member
+ # participant :ref => '${team_member}'
+ # end
+ # end
+ #
+ # A process instance about the election results in Venezuela :
+ #
+ # engine.launch(
+ # pdef,
+ # 'topic' => 'politics',
+ # 'region' => 'america',
+ # 'line' => 'election results in Venezuela')
+ #
+ # would thus get routed to Gilbert.
+ #
class Participant
include Ruote::LocalParticipant
View
8 rufus-decision.gemspec
@@ -43,9 +43,11 @@ CSV based Ruby decision tables
"lib/rufus-decision.rb",
"lib/rufus/decision.rb",
"lib/rufus/decision/hashes.rb",
+ "lib/rufus/decision/participant.rb",
"lib/rufus/decision/table.rb",
"lib/rufus/decision/version.rb",
"rufus-decision.gemspec",
+ "test/base.rb",
"test/dt_0_basic.rb",
"test/dt_1_vertical.rb",
"test/dt_2_google.rb",
@@ -54,9 +56,11 @@ CSV based Ruby decision tables
"test/dt_5_transpose.rb",
"test/goal.csv",
"test/input.csv",
+ "test/ruote/base.rb",
+ "test/ruote/rt_0_basic.rb",
+ "test/ruote/test.rb",
"test/table.csv",
- "test/test.rb",
- "test/test_base.rb"
+ "test/test.rb"
]
s.homepage = %q{http://github.com/jmettraux/rufus-decision/}
s.rdoc_options = ["--charset=UTF-8"]
View
26 test/ruote/rt_0_basic.rb
@@ -14,7 +14,31 @@ class Rt0Test < Test::Unit::TestCase
def test_basic
- flunk
+ @engine.register_participant(
+ :decision,
+ Rufus::Decision::Participant, :table => %{
+ in:topic,in:region,out:team_member
+ sports,europe,Alice
+ sports,,Bob
+ finance,america,Charly
+ finance,europe,Donald
+ finance,,Ernest
+ politics,asia,Fujio
+ politics,america,Gilbert
+ politics,,Henry
+ ,,Zach
+ })
+
+ pdef = Ruote.process_definition :name => 'dec-test', :revision => '1' do
+ decision
+ end
+
+ wfid = @engine.launch(pdef, 'topic' => 'politics', 'region' => 'america')
+ r = @engine.wait_for(wfid)
+
+ assert_equal(
+ {"topic"=>"politics", "region"=>"america", "team_member"=>"Gilbert"},
+ r['workitem']['fields'])
end
end

0 comments on commit 3c97100

Please sign in to comment.
Something went wrong with that request. Please try again.