rufus-decision 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.txt +7 -0
- data/CREDITS.txt +1 -0
- data/README.rdoc +4 -1
- data/Rakefile +1 -0
- data/TODO.txt +2 -0
- data/examples/reimbursement.rb +142 -0
- data/examples/reimbursement2.csv +7 -0
- data/lib/rufus/decision/participant.rb +34 -1
- data/lib/rufus/decision/table.rb +3 -1
- data/lib/rufus/decision/version.rb +1 -1
- data/rufus-decision.gemspec +8 -3
- data/test/dt_0_basic.rb +8 -0
- metadata +49 -20
data/CHANGELOG.txt
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
= rufus-decision CHANGELOG.txt
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
== rufus-decision - 1.3.2 released 2010/05/28
|
|
6
|
+
|
|
7
|
+
- ruote participant : passing the participant options to the decision table
|
|
8
|
+
Thanks Wes Gamble
|
|
9
|
+
- accepting symbol or string as table option keys
|
|
10
|
+
|
|
11
|
+
|
|
5
12
|
== rufus-decision - 1.3.1 released 2010/02/16
|
|
6
13
|
|
|
7
14
|
- implemented Rufus::Decision::Participant, a ruote participant
|
data/CREDITS.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
gem install rufus-decision
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
==
|
|
10
|
+
== blog posts
|
|
11
11
|
|
|
12
12
|
http://jmettraux.wordpress.com/2009/04/25/rufus-decision-11-ruby-decision-tables/
|
|
13
13
|
|
|
14
|
+
http://jmettraux.wordpress.com/2010/02/17/ruote-and-decision-tables/
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
|
|
15
18
|
== usage
|
|
16
19
|
|
data/Rakefile
CHANGED
|
@@ -37,6 +37,7 @@ CSV based Ruby decision tables
|
|
|
37
37
|
|
|
38
38
|
gem.add_dependency 'rufus-dollar'
|
|
39
39
|
gem.add_dependency 'rufus-treechecker'
|
|
40
|
+
gem.add_development_dependency 'rake'
|
|
40
41
|
gem.add_development_dependency 'yard'
|
|
41
42
|
gem.add_development_dependency 'jeweler'
|
|
42
43
|
#gem.add_development_dependency 'ruote', '>= 2.1.7'
|
data/TODO.txt
CHANGED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
|
|
2
|
+
#
|
|
3
|
+
# ruote + rufus-decision example
|
|
4
|
+
#
|
|
5
|
+
# featured in
|
|
6
|
+
#
|
|
7
|
+
# http://jmettraux.wordpress.com/2010/02/17/ruote-and-decision-tables/
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
require 'rubygems'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
# preparing the workflow engine
|
|
15
|
+
|
|
16
|
+
require 'ruote'
|
|
17
|
+
|
|
18
|
+
engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new()))
|
|
19
|
+
# for this example we use a transient, in-memory engine
|
|
20
|
+
|
|
21
|
+
#engine.context.logger.noisy = true
|
|
22
|
+
# useful when debugging
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# the process definition
|
|
27
|
+
|
|
28
|
+
pdef = Ruote.process_definition :name => 'reimbursement', :revision => '1.0' do
|
|
29
|
+
cursor do
|
|
30
|
+
customer :task => 'fill form'
|
|
31
|
+
clerk :task => 'control form'
|
|
32
|
+
rewind :if => '${f:missing_info}'
|
|
33
|
+
determine_reimbursement_level
|
|
34
|
+
finance :task => 'reimburse customer'
|
|
35
|
+
customer :task => 'reimbursement notification'
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# the 'inbox/worklist' participant
|
|
42
|
+
#
|
|
43
|
+
# for this example, they are only STDOUT/STDIN participants
|
|
44
|
+
|
|
45
|
+
class StdoutParticipant
|
|
46
|
+
include Ruote::LocalParticipant
|
|
47
|
+
|
|
48
|
+
def initialize (opts)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def consume (workitem)
|
|
52
|
+
|
|
53
|
+
puts '-' * 80
|
|
54
|
+
puts "participant : #{workitem.participant_name}"
|
|
55
|
+
|
|
56
|
+
if workitem.fields['params']['task'] == 'fill form'
|
|
57
|
+
puts " * reimbursement claim, please fill details :"
|
|
58
|
+
echo "description : "
|
|
59
|
+
workitem.fields['description'] = STDIN.gets.strip
|
|
60
|
+
echo "type of visit (doctor office / hospital visit / lab visit) : "
|
|
61
|
+
workitem.fields['type of visit'] = STDIN.gets.strip
|
|
62
|
+
echo "participating physician ? (yes or no) : "
|
|
63
|
+
workitem.fields['participating physician ?'] = STDIN.gets.strip
|
|
64
|
+
else
|
|
65
|
+
puts " . reimbursement claim :"
|
|
66
|
+
workitem.fields.each do |k, v|
|
|
67
|
+
puts "#{k} --> #{v.inspect}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
reply_to_engine(workitem)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def echo (s)
|
|
75
|
+
print(s); STDOUT.flush
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
engine.register_participant 'customer', StdoutParticipant
|
|
80
|
+
engine.register_participant 'clerk', StdoutParticipant
|
|
81
|
+
engine.register_participant 'finance', StdoutParticipant
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
#
|
|
85
|
+
# the "decision" participant
|
|
86
|
+
|
|
87
|
+
#engine.register_participant 'determine_reimbursement_level' do |workitem|
|
|
88
|
+
# workitem.fields['reimbursement'] =
|
|
89
|
+
# case workitem.fields['type of visit']
|
|
90
|
+
# when 'doctor office'
|
|
91
|
+
# workitem.fields['participating physician ?'] == 'yes' ? '90%' : '50%'
|
|
92
|
+
# when 'hospital visit'
|
|
93
|
+
# workitem.fields['participating physician ?'] == 'yes' ? '0%' : '80%'
|
|
94
|
+
# when 'lab visit'
|
|
95
|
+
# workitem.fields['participating physician ?'] == 'yes' ? '0%' : '70%'
|
|
96
|
+
# else
|
|
97
|
+
# '0%'
|
|
98
|
+
# end
|
|
99
|
+
#end
|
|
100
|
+
|
|
101
|
+
require 'rufus/decision/participant'
|
|
102
|
+
|
|
103
|
+
#engine.register_participant(
|
|
104
|
+
# 'determine_reimbursement_level',
|
|
105
|
+
# Rufus::Decision::Participant,
|
|
106
|
+
# :table => %{
|
|
107
|
+
#in:type of visit,in:participating physician ?,out:reimbursement
|
|
108
|
+
#doctor office,yes,90%
|
|
109
|
+
#doctor office,no,50%
|
|
110
|
+
#hospital visit,yes,0%
|
|
111
|
+
#hospital visit,no,80%
|
|
112
|
+
#lab visit,yes,0%
|
|
113
|
+
#lab visit,no,70%
|
|
114
|
+
# })
|
|
115
|
+
|
|
116
|
+
engine.register_participant(
|
|
117
|
+
'determine_reimbursement_level',
|
|
118
|
+
Rufus::Decision::Participant,
|
|
119
|
+
:table => 'http://github.com/jmettraux/rufus-decision/raw/master/examples/reimbursement2.csv')
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
#
|
|
123
|
+
# running the example...
|
|
124
|
+
|
|
125
|
+
puts '=' * 80
|
|
126
|
+
puts "launching process"
|
|
127
|
+
|
|
128
|
+
wfid = engine.launch(pdef)
|
|
129
|
+
|
|
130
|
+
engine.wait_for(wfid)
|
|
131
|
+
# don't let the Ruby runtime exits until our [unique] process instance is over
|
|
132
|
+
|
|
133
|
+
#ps = engine.process(wfid)
|
|
134
|
+
#if ps
|
|
135
|
+
# puts ps.errors.first.message
|
|
136
|
+
# puts ps.errors.first.trace
|
|
137
|
+
#end
|
|
138
|
+
# useful when debugging
|
|
139
|
+
|
|
140
|
+
puts '=' * 80
|
|
141
|
+
puts "done."
|
|
142
|
+
|
|
@@ -34,6 +34,17 @@ module Rufus::Decision
|
|
|
34
34
|
# Make sure you have the gem "rufus-decision" installed in order to
|
|
35
35
|
# use this decision participant.
|
|
36
36
|
#
|
|
37
|
+
#
|
|
38
|
+
# == blog post
|
|
39
|
+
#
|
|
40
|
+
# This Rufus::Decision::Participant was introduced in the "ruote and
|
|
41
|
+
# decision tables" blog post :
|
|
42
|
+
#
|
|
43
|
+
# http://jmettraux.wordpress.com/2010/02/17/ruote-and-decision-tables/
|
|
44
|
+
#
|
|
45
|
+
#
|
|
46
|
+
# == example
|
|
47
|
+
#
|
|
37
48
|
# In this example, a participant named 'decide_team_member' is bound in the
|
|
38
49
|
# ruote engine and, depending on the value of the workitem fields 'topic'
|
|
39
50
|
# and region, sets the value of the field named 'team_member' :
|
|
@@ -72,6 +83,28 @@ module Rufus::Decision
|
|
|
72
83
|
#
|
|
73
84
|
# would thus get routed to Gilbert.
|
|
74
85
|
#
|
|
86
|
+
# To learn more about decision tables :
|
|
87
|
+
#
|
|
88
|
+
# http://github.com/jmettraux/rufus-decision
|
|
89
|
+
#
|
|
90
|
+
#
|
|
91
|
+
# == pointing to a table via a URI
|
|
92
|
+
#
|
|
93
|
+
# Note that you can reference the table by its URI :
|
|
94
|
+
#
|
|
95
|
+
# engine.register_participant(
|
|
96
|
+
# :decide_team_member
|
|
97
|
+
# Rufus::Decision::Participant,
|
|
98
|
+
# :table => 'http://decisions.example.com/journalists.csv')
|
|
99
|
+
#
|
|
100
|
+
# If the table were a Google Spreadsheet, it would look like (note the
|
|
101
|
+
# trailing &output=csv) :
|
|
102
|
+
#
|
|
103
|
+
# engine.register_participant(
|
|
104
|
+
# :decide_team_member
|
|
105
|
+
# Rufus::Decision::Participant,
|
|
106
|
+
# :table => 'http://spreadsheets.google.com/pub?key=pCZNVR1TQ&output=csv')
|
|
107
|
+
#
|
|
75
108
|
class Participant
|
|
76
109
|
include Ruote::LocalParticipant
|
|
77
110
|
|
|
@@ -85,7 +118,7 @@ module Rufus::Decision
|
|
|
85
118
|
table = @options['table']
|
|
86
119
|
raise(ArgumentError.new("'table' option is missing")) unless table
|
|
87
120
|
|
|
88
|
-
table = Rufus::Decision::Table.new(table)
|
|
121
|
+
table = Rufus::Decision::Table.new(table, @options)
|
|
89
122
|
|
|
90
123
|
workitem.fields = table.run(workitem.fields)
|
|
91
124
|
|
data/lib/rufus/decision/table.rb
CHANGED
data/rufus-decision.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{rufus-decision}
|
|
8
|
-
s.version = "1.3.
|
|
8
|
+
s.version = "1.3.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["John Mettraux"]
|
|
12
|
-
s.date = %q{2010-
|
|
12
|
+
s.date = %q{2010-05-28}
|
|
13
13
|
s.default_executable = %q{rufus_decide}
|
|
14
14
|
s.description = %q{
|
|
15
15
|
CSV based Ruby decision tables
|
|
@@ -40,6 +40,8 @@ CSV based Ruby decision tables
|
|
|
40
40
|
"examples/journalists.rb",
|
|
41
41
|
"examples/readme_example.rb",
|
|
42
42
|
"examples/reimbursement.csv",
|
|
43
|
+
"examples/reimbursement.rb",
|
|
44
|
+
"examples/reimbursement2.csv",
|
|
43
45
|
"lib/rufus-decision.rb",
|
|
44
46
|
"lib/rufus/decision.rb",
|
|
45
47
|
"lib/rufus/decision/hashes.rb",
|
|
@@ -66,7 +68,7 @@ CSV based Ruby decision tables
|
|
|
66
68
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
67
69
|
s.require_paths = ["lib"]
|
|
68
70
|
s.rubyforge_project = %q{rufus}
|
|
69
|
-
s.rubygems_version = %q{1.3.
|
|
71
|
+
s.rubygems_version = %q{1.3.6}
|
|
70
72
|
s.summary = %q{CSV based Ruby decision tables}
|
|
71
73
|
s.test_files = [
|
|
72
74
|
"test/test.rb"
|
|
@@ -79,17 +81,20 @@ CSV based Ruby decision tables
|
|
|
79
81
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
80
82
|
s.add_runtime_dependency(%q<rufus-dollar>, [">= 0"])
|
|
81
83
|
s.add_runtime_dependency(%q<rufus-treechecker>, [">= 0"])
|
|
84
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
|
82
85
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
|
83
86
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
|
84
87
|
else
|
|
85
88
|
s.add_dependency(%q<rufus-dollar>, [">= 0"])
|
|
86
89
|
s.add_dependency(%q<rufus-treechecker>, [">= 0"])
|
|
90
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
|
87
91
|
s.add_dependency(%q<yard>, [">= 0"])
|
|
88
92
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
89
93
|
end
|
|
90
94
|
else
|
|
91
95
|
s.add_dependency(%q<rufus-dollar>, [">= 0"])
|
|
92
96
|
s.add_dependency(%q<rufus-treechecker>, [">= 0"])
|
|
97
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
|
93
98
|
s.add_dependency(%q<yard>, [">= 0"])
|
|
94
99
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
95
100
|
end
|
data/test/dt_0_basic.rb
CHANGED
|
@@ -292,6 +292,14 @@ e,f,2
|
|
|
292
292
|
do_test(table, wi, { 'fz' => '3' }, false)
|
|
293
293
|
end
|
|
294
294
|
|
|
295
|
+
def test_ruby_eval_string_key
|
|
296
|
+
|
|
297
|
+
table = Rufus::Decision::Table.new(CSV9, 'ruby_eval' => true)
|
|
298
|
+
|
|
299
|
+
wi = { 'fx' => 'c', 'fy' => 'd' }
|
|
300
|
+
do_test(table, wi, { 'fz' => '3' }, false)
|
|
301
|
+
end
|
|
302
|
+
|
|
295
303
|
CSV10 = %{
|
|
296
304
|
in:fx,in:fx,out:fz
|
|
297
305
|
>90,<92,ok
|
metadata
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rufus-decision
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 1
|
|
7
|
+
- 3
|
|
8
|
+
- 2
|
|
9
|
+
version: 1.3.2
|
|
5
10
|
platform: ruby
|
|
6
11
|
authors:
|
|
7
12
|
- John Mettraux
|
|
@@ -9,49 +14,69 @@ autorequire:
|
|
|
9
14
|
bindir: bin
|
|
10
15
|
cert_chain: []
|
|
11
16
|
|
|
12
|
-
date: 2010-
|
|
17
|
+
date: 2010-05-28 00:00:00 +09:00
|
|
13
18
|
default_executable: rufus_decide
|
|
14
19
|
dependencies:
|
|
15
20
|
- !ruby/object:Gem::Dependency
|
|
16
21
|
name: rufus-dollar
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
20
24
|
requirements:
|
|
21
25
|
- - ">="
|
|
22
26
|
- !ruby/object:Gem::Version
|
|
27
|
+
segments:
|
|
28
|
+
- 0
|
|
23
29
|
version: "0"
|
|
24
|
-
|
|
30
|
+
type: :runtime
|
|
31
|
+
version_requirements: *id001
|
|
25
32
|
- !ruby/object:Gem::Dependency
|
|
26
33
|
name: rufus-treechecker
|
|
34
|
+
prerelease: false
|
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
segments:
|
|
40
|
+
- 0
|
|
41
|
+
version: "0"
|
|
27
42
|
type: :runtime
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
version_requirements: *id002
|
|
44
|
+
- !ruby/object:Gem::Dependency
|
|
45
|
+
name: rake
|
|
46
|
+
prerelease: false
|
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
30
48
|
requirements:
|
|
31
49
|
- - ">="
|
|
32
50
|
- !ruby/object:Gem::Version
|
|
51
|
+
segments:
|
|
52
|
+
- 0
|
|
33
53
|
version: "0"
|
|
34
|
-
|
|
54
|
+
type: :development
|
|
55
|
+
version_requirements: *id003
|
|
35
56
|
- !ruby/object:Gem::Dependency
|
|
36
57
|
name: yard
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
+
prerelease: false
|
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
40
60
|
requirements:
|
|
41
61
|
- - ">="
|
|
42
62
|
- !ruby/object:Gem::Version
|
|
63
|
+
segments:
|
|
64
|
+
- 0
|
|
43
65
|
version: "0"
|
|
44
|
-
|
|
66
|
+
type: :development
|
|
67
|
+
version_requirements: *id004
|
|
45
68
|
- !ruby/object:Gem::Dependency
|
|
46
69
|
name: jeweler
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
70
|
+
prerelease: false
|
|
71
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
50
72
|
requirements:
|
|
51
73
|
- - ">="
|
|
52
74
|
- !ruby/object:Gem::Version
|
|
75
|
+
segments:
|
|
76
|
+
- 0
|
|
53
77
|
version: "0"
|
|
54
|
-
|
|
78
|
+
type: :development
|
|
79
|
+
version_requirements: *id005
|
|
55
80
|
description: "\n\
|
|
56
81
|
CSV based Ruby decision tables\n "
|
|
57
82
|
email: jmettraux@gmail.com
|
|
@@ -82,6 +107,8 @@ files:
|
|
|
82
107
|
- examples/journalists.rb
|
|
83
108
|
- examples/readme_example.rb
|
|
84
109
|
- examples/reimbursement.csv
|
|
110
|
+
- examples/reimbursement.rb
|
|
111
|
+
- examples/reimbursement2.csv
|
|
85
112
|
- lib/rufus-decision.rb
|
|
86
113
|
- lib/rufus/decision.rb
|
|
87
114
|
- lib/rufus/decision/hashes.rb
|
|
@@ -116,18 +143,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
116
143
|
requirements:
|
|
117
144
|
- - ">="
|
|
118
145
|
- !ruby/object:Gem::Version
|
|
146
|
+
segments:
|
|
147
|
+
- 0
|
|
119
148
|
version: "0"
|
|
120
|
-
version:
|
|
121
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
150
|
requirements:
|
|
123
151
|
- - ">="
|
|
124
152
|
- !ruby/object:Gem::Version
|
|
153
|
+
segments:
|
|
154
|
+
- 0
|
|
125
155
|
version: "0"
|
|
126
|
-
version:
|
|
127
156
|
requirements: []
|
|
128
157
|
|
|
129
158
|
rubyforge_project: rufus
|
|
130
|
-
rubygems_version: 1.3.
|
|
159
|
+
rubygems_version: 1.3.6
|
|
131
160
|
signing_key:
|
|
132
161
|
specification_version: 3
|
|
133
162
|
summary: CSV based Ruby decision tables
|