ruote 2.1.10 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/CHANGELOG.txt +51 -1
  2. data/CREDITS.txt +9 -0
  3. data/README.rdoc +13 -0
  4. data/Rakefile +50 -21
  5. data/TODO.txt +42 -4
  6. data/examples/pong.rb +37 -0
  7. data/lib/ruote/context.rb +19 -9
  8. data/lib/ruote/engine/process_error.rb +10 -0
  9. data/lib/ruote/engine/process_status.rb +140 -41
  10. data/lib/ruote/engine.rb +394 -27
  11. data/lib/ruote/exp/command.rb +2 -0
  12. data/lib/ruote/exp/fe_concurrence.rb +8 -0
  13. data/lib/ruote/exp/fe_concurrent_iterator.rb +3 -0
  14. data/lib/ruote/exp/fe_cursor.rb +48 -4
  15. data/lib/ruote/exp/fe_iterator.rb +40 -0
  16. data/lib/ruote/exp/fe_listen.rb +3 -3
  17. data/lib/ruote/exp/fe_participant.rb +30 -12
  18. data/lib/ruote/exp/fe_ref.rb +126 -0
  19. data/lib/ruote/exp/fe_subprocess.rb +20 -1
  20. data/lib/ruote/exp/fe_wait.rb +4 -1
  21. data/lib/ruote/exp/fe_when.rb +7 -10
  22. data/lib/ruote/exp/flowexpression.rb +23 -12
  23. data/lib/ruote/exp/ro_attributes.rb +5 -8
  24. data/lib/ruote/exp/ro_variables.rb +4 -2
  25. data/lib/ruote/fei.rb +2 -0
  26. data/lib/ruote/id/wfid_generator.rb +1 -1
  27. data/lib/ruote/log/pretty.rb +137 -0
  28. data/lib/ruote/log/storage_history.rb +1 -1
  29. data/lib/ruote/log/test_logger.rb +51 -126
  30. data/lib/ruote/log/wait_logger.rb +8 -13
  31. data/lib/ruote/parser/ruby_dsl.rb +4 -4
  32. data/lib/ruote/parser.rb +2 -2
  33. data/lib/ruote/part/block_participant.rb +1 -1
  34. data/lib/ruote/part/engine_participant.rb +1 -1
  35. data/lib/ruote/part/storage_participant.rb +27 -28
  36. data/lib/ruote/part/template.rb +8 -3
  37. data/lib/ruote/receiver/base.rb +24 -6
  38. data/lib/ruote/storage/base.rb +76 -11
  39. data/lib/ruote/storage/fs_storage.rb +10 -0
  40. data/lib/ruote/storage/hash_storage.rb +19 -8
  41. data/lib/ruote/{part → svc}/dispatch_pool.rb +3 -2
  42. data/lib/ruote/svc/dollar_sub.rb +265 -0
  43. data/lib/ruote/{error_handler.rb → svc/error_handler.rb} +6 -1
  44. data/lib/ruote/{exp → svc}/expression_map.rb +31 -37
  45. data/lib/ruote/{part → svc}/participant_list.rb +165 -25
  46. data/lib/ruote/{evt → svc}/tracker.rb +0 -0
  47. data/lib/ruote/{util → svc}/treechecker.rb +0 -0
  48. data/lib/ruote/util/look.rb +4 -1
  49. data/lib/ruote/util/ometa.rb +21 -5
  50. data/lib/ruote/{subprocess.rb → util/subprocess.rb} +0 -0
  51. data/lib/ruote/version.rb +1 -1
  52. data/lib/ruote/worker.rb +29 -69
  53. data/lib/ruote/workitem.rb +28 -1
  54. data/ruote.gemspec +26 -22
  55. data/test/functional/base.rb +3 -0
  56. data/test/functional/concurrent_base.rb +1 -0
  57. data/test/functional/crunner.sh +1 -1
  58. data/test/functional/ct_0_concurrence.rb +6 -0
  59. data/test/functional/ct_1_iterator.rb +3 -0
  60. data/test/functional/ct_2_cancel.rb +5 -0
  61. data/test/functional/eft_13_iterator.rb +39 -4
  62. data/test/functional/eft_14_cursor.rb +39 -0
  63. data/test/functional/eft_30_ref.rb +140 -0
  64. data/test/functional/eft_3_participant.rb +25 -23
  65. data/test/functional/ft_10_dollar.rb +17 -1
  66. data/test/functional/ft_14_re_apply.rb +76 -0
  67. data/test/functional/ft_1_process_status.rb +170 -29
  68. data/test/functional/ft_20_storage_participant.rb +14 -0
  69. data/test/functional/ft_24_block_participants.rb +1 -1
  70. data/test/functional/ft_26_participant_timeout.rb +93 -0
  71. data/test/functional/ft_2_errors.rb +24 -17
  72. data/test/functional/ft_30_smtp_participant.rb +7 -2
  73. data/test/functional/ft_38_participant_more.rb +15 -0
  74. data/test/functional/ft_39_wait_for.rb +34 -1
  75. data/test/functional/ft_3_participant_registration.rb +270 -2
  76. data/test/functional/ft_40_wait_logger.rb +61 -0
  77. data/test/functional/ft_42_storage_copy.rb +4 -0
  78. data/test/functional/{ft_40_participant_on_reply.rb → ft_43_participant_on_reply.rb} +17 -0
  79. data/test/functional/ft_44_var_participant.rb +35 -0
  80. data/test/functional/ft_45_participant_accept.rb +64 -0
  81. data/test/functional/ft_46_launch_single.rb +49 -0
  82. data/test/functional/ft_5_on_error.rb +39 -1
  83. data/test/functional/storage_helper.rb +7 -1
  84. data/test/test_helper.rb +1 -1
  85. data/test/unit/storage.rb +105 -32
  86. data/test/unit/ut_0_ruby_parser.rb +31 -1
  87. data/test/unit/ut_16_parser.rb +20 -0
  88. data/test/unit/ut_19_part_template.rb +11 -1
  89. data/test/unit/ut_20_composite_storage.rb +1 -1
  90. data/test/unit/ut_4_expmap.rb +1 -1
  91. data/test/unit/ut_6_condition.rb +2 -2
  92. metadata +112 -74
  93. data/lib/ruote/exp/raw.rb +0 -44
  94. data/lib/ruote/util/dollar.rb +0 -193
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruote
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.10
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 1
8
+ - 11
9
+ version: 2.1.11
5
10
  platform: ruby
6
11
  authors:
7
12
  - John Mettraux
@@ -11,139 +16,163 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2010-06-15 00:00:00 +09:00
19
+ date: 2010-10-01 00:00:00 +09:00
15
20
  default_executable:
16
21
  dependencies:
17
22
  - !ruby/object:Gem::Dependency
18
23
  name: rufus-json
19
- type: :runtime
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
22
26
  requirements:
23
27
  - - ">="
24
28
  - !ruby/object:Gem::Version
25
- version: 0.2.2
26
- version:
29
+ segments:
30
+ - 0
31
+ - 2
32
+ - 5
33
+ version: 0.2.5
34
+ type: :runtime
35
+ version_requirements: *id001
27
36
  - !ruby/object:Gem::Dependency
28
37
  name: rufus-cloche
29
- type: :runtime
30
- version_requirement:
31
- version_requirements: !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
32
40
  requirements:
33
41
  - - ">="
34
42
  - !ruby/object:Gem::Version
35
- version: 0.1.17
36
- version:
43
+ segments:
44
+ - 0
45
+ - 1
46
+ - 20
47
+ version: 0.1.20
48
+ type: :runtime
49
+ version_requirements: *id002
37
50
  - !ruby/object:Gem::Dependency
38
51
  name: rufus-dollar
39
- type: :runtime
40
- version_requirement:
41
- version_requirements: !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
42
54
  requirements:
43
55
  - - ">="
44
56
  - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
45
59
  version: "0"
46
- version:
47
- - !ruby/object:Gem::Dependency
48
- name: rufus-lru
49
60
  type: :runtime
50
- version_requirement:
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
56
- version:
61
+ version_requirements: *id003
57
62
  - !ruby/object:Gem::Dependency
58
63
  name: rufus-mnemo
59
- type: :runtime
60
- version_requirement:
61
- version_requirements: !ruby/object:Gem::Requirement
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
62
66
  requirements:
63
67
  - - ">="
64
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 1
72
+ - 0
65
73
  version: 1.1.0
66
- version:
74
+ type: :runtime
75
+ version_requirements: *id004
67
76
  - !ruby/object:Gem::Dependency
68
77
  name: rufus-scheduler
69
- type: :runtime
70
- version_requirement:
71
- version_requirements: !ruby/object:Gem::Requirement
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
72
80
  requirements:
73
81
  - - ">="
74
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 2
85
+ - 0
86
+ - 5
75
87
  version: 2.0.5
76
- version:
88
+ type: :runtime
89
+ version_requirements: *id005
77
90
  - !ruby/object:Gem::Dependency
78
91
  name: rufus-treechecker
79
- type: :runtime
80
- version_requirement:
81
- version_requirements: !ruby/object:Gem::Requirement
92
+ prerelease: false
93
+ requirement: &id006 !ruby/object:Gem::Requirement
82
94
  requirements:
83
95
  - - ">="
84
96
  - !ruby/object:Gem::Version
97
+ segments:
98
+ - 1
99
+ - 0
100
+ - 3
85
101
  version: 1.0.3
86
- version:
102
+ type: :runtime
103
+ version_requirements: *id006
87
104
  - !ruby/object:Gem::Dependency
88
105
  name: rake
89
- type: :development
90
- version_requirement:
91
- version_requirements: !ruby/object:Gem::Requirement
106
+ prerelease: false
107
+ requirement: &id007 !ruby/object:Gem::Requirement
92
108
  requirements:
93
109
  - - ">="
94
110
  - !ruby/object:Gem::Version
111
+ segments:
112
+ - 0
95
113
  version: "0"
96
- version:
114
+ type: :development
115
+ version_requirements: *id007
97
116
  - !ruby/object:Gem::Dependency
98
117
  name: yard
99
- type: :development
100
- version_requirement:
101
- version_requirements: !ruby/object:Gem::Requirement
118
+ prerelease: false
119
+ requirement: &id008 !ruby/object:Gem::Requirement
102
120
  requirements:
103
121
  - - ">="
104
122
  - !ruby/object:Gem::Version
123
+ segments:
124
+ - 0
105
125
  version: "0"
106
- version:
126
+ type: :development
127
+ version_requirements: *id008
107
128
  - !ruby/object:Gem::Dependency
108
129
  name: json
109
- type: :development
110
- version_requirement:
111
- version_requirements: !ruby/object:Gem::Requirement
130
+ prerelease: false
131
+ requirement: &id009 !ruby/object:Gem::Requirement
112
132
  requirements:
113
133
  - - ">="
114
134
  - !ruby/object:Gem::Version
135
+ segments:
136
+ - 0
115
137
  version: "0"
116
- version:
138
+ type: :development
139
+ version_requirements: *id009
117
140
  - !ruby/object:Gem::Dependency
118
141
  name: builder
119
- type: :development
120
- version_requirement:
121
- version_requirements: !ruby/object:Gem::Requirement
142
+ prerelease: false
143
+ requirement: &id010 !ruby/object:Gem::Requirement
122
144
  requirements:
123
145
  - - ">="
124
146
  - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
125
149
  version: "0"
126
- version:
150
+ type: :development
151
+ version_requirements: *id010
127
152
  - !ruby/object:Gem::Dependency
128
153
  name: mailtrap
129
- type: :development
130
- version_requirement:
131
- version_requirements: !ruby/object:Gem::Requirement
154
+ prerelease: false
155
+ requirement: &id011 !ruby/object:Gem::Requirement
132
156
  requirements:
133
157
  - - ">="
134
158
  - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
135
161
  version: "0"
136
- version:
162
+ type: :development
163
+ version_requirements: *id011
137
164
  - !ruby/object:Gem::Dependency
138
165
  name: jeweler
139
- type: :development
140
- version_requirement:
141
- version_requirements: !ruby/object:Gem::Requirement
166
+ prerelease: false
167
+ requirement: &id012 !ruby/object:Gem::Requirement
142
168
  requirements:
143
169
  - - ">="
144
170
  - !ruby/object:Gem::Version
171
+ segments:
172
+ - 0
145
173
  version: "0"
146
- version:
174
+ type: :development
175
+ version_requirements: *id012
147
176
  description: "\n\
148
177
  ruote is an open source ruby workflow engine.\n "
149
178
  email: jmettraux@gmail.com
@@ -164,6 +193,7 @@ files:
164
193
  - TODO.txt
165
194
  - examples/barley.rb
166
195
  - examples/flickr_report.rb
196
+ - examples/pong.rb
167
197
  - examples/ruote_quickstart.rb
168
198
  - examples/web_first_page.rb
169
199
  - lib/ruote.rb
@@ -171,12 +201,9 @@ files:
171
201
  - lib/ruote/engine.rb
172
202
  - lib/ruote/engine/process_error.rb
173
203
  - lib/ruote/engine/process_status.rb
174
- - lib/ruote/error_handler.rb
175
- - lib/ruote/evt/tracker.rb
176
204
  - lib/ruote/exp/command.rb
177
205
  - lib/ruote/exp/commanded.rb
178
206
  - lib/ruote/exp/condition.rb
179
- - lib/ruote/exp/expression_map.rb
180
207
  - lib/ruote/exp/fe_add_branches.rb
181
208
  - lib/ruote/exp/fe_apply.rb
182
209
  - lib/ruote/exp/fe_cancel_process.rb
@@ -197,6 +224,7 @@ files:
197
224
  - lib/ruote/exp/fe_noop.rb
198
225
  - lib/ruote/exp/fe_participant.rb
199
226
  - lib/ruote/exp/fe_redo.rb
227
+ - lib/ruote/exp/fe_ref.rb
200
228
  - lib/ruote/exp/fe_reserve.rb
201
229
  - lib/ruote/exp/fe_restore.rb
202
230
  - lib/ruote/exp/fe_save.rb
@@ -209,13 +237,13 @@ files:
209
237
  - lib/ruote/exp/flowexpression.rb
210
238
  - lib/ruote/exp/iterator.rb
211
239
  - lib/ruote/exp/merge.rb
212
- - lib/ruote/exp/raw.rb
213
240
  - lib/ruote/exp/ro_attributes.rb
214
241
  - lib/ruote/exp/ro_persist.rb
215
242
  - lib/ruote/exp/ro_variables.rb
216
243
  - lib/ruote/fei.rb
217
244
  - lib/ruote/id/mnemo_wfid_generator.rb
218
245
  - lib/ruote/id/wfid_generator.rb
246
+ - lib/ruote/log/pretty.rb
219
247
  - lib/ruote/log/storage_history.rb
220
248
  - lib/ruote/log/test_logger.rb
221
249
  - lib/ruote/log/wait_logger.rb
@@ -223,13 +251,11 @@ files:
223
251
  - lib/ruote/parser/ruby_dsl.rb
224
252
  - lib/ruote/parser/xml.rb
225
253
  - lib/ruote/part/block_participant.rb
226
- - lib/ruote/part/dispatch_pool.rb
227
254
  - lib/ruote/part/engine_participant.rb
228
255
  - lib/ruote/part/hash_participant.rb
229
256
  - lib/ruote/part/local_participant.rb
230
257
  - lib/ruote/part/no_op_participant.rb
231
258
  - lib/ruote/part/null_participant.rb
232
- - lib/ruote/part/participant_list.rb
233
259
  - lib/ruote/part/smtp_participant.rb
234
260
  - lib/ruote/part/storage_participant.rb
235
261
  - lib/ruote/part/template.rb
@@ -239,18 +265,23 @@ files:
239
265
  - lib/ruote/storage/composite_storage.rb
240
266
  - lib/ruote/storage/fs_storage.rb
241
267
  - lib/ruote/storage/hash_storage.rb
242
- - lib/ruote/subprocess.rb
268
+ - lib/ruote/svc/dispatch_pool.rb
269
+ - lib/ruote/svc/dollar_sub.rb
270
+ - lib/ruote/svc/error_handler.rb
271
+ - lib/ruote/svc/expression_map.rb
272
+ - lib/ruote/svc/participant_list.rb
273
+ - lib/ruote/svc/tracker.rb
274
+ - lib/ruote/svc/treechecker.rb
243
275
  - lib/ruote/tree_dot.rb
244
- - lib/ruote/util/dollar.rb
245
276
  - lib/ruote/util/hashdot.rb
246
277
  - lib/ruote/util/look.rb
247
278
  - lib/ruote/util/lookup.rb
248
279
  - lib/ruote/util/misc.rb
249
280
  - lib/ruote/util/ometa.rb
250
281
  - lib/ruote/util/serializer.rb
282
+ - lib/ruote/util/subprocess.rb
251
283
  - lib/ruote/util/time.rb
252
284
  - lib/ruote/util/tree.rb
253
- - lib/ruote/util/treechecker.rb
254
285
  - lib/ruote/version.rb
255
286
  - lib/ruote/worker.rb
256
287
  - lib/ruote/workitem.rb
@@ -294,6 +325,7 @@ files:
294
325
  - test/functional/eft_28_when.rb
295
326
  - test/functional/eft_29_cron.rb
296
327
  - test/functional/eft_2_sequence.rb
328
+ - test/functional/eft_30_ref.rb
297
329
  - test/functional/eft_3_participant.rb
298
330
  - test/functional/eft_4_set.rb
299
331
  - test/functional/eft_5_subprocess.rb
@@ -334,9 +366,13 @@ files:
334
366
  - test/functional/ft_38_participant_more.rb
335
367
  - test/functional/ft_39_wait_for.rb
336
368
  - test/functional/ft_3_participant_registration.rb
337
- - test/functional/ft_40_participant_on_reply.rb
369
+ - test/functional/ft_40_wait_logger.rb
338
370
  - test/functional/ft_41_participants.rb
339
371
  - test/functional/ft_42_storage_copy.rb
372
+ - test/functional/ft_43_participant_on_reply.rb
373
+ - test/functional/ft_44_var_participant.rb
374
+ - test/functional/ft_45_participant_accept.rb
375
+ - test/functional/ft_46_launch_single.rb
340
376
  - test/functional/ft_4_cancel.rb
341
377
  - test/functional/ft_5_on_error.rb
342
378
  - test/functional/ft_6_on_cancel.rb
@@ -392,18 +428,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
392
428
  requirements:
393
429
  - - ">="
394
430
  - !ruby/object:Gem::Version
431
+ segments:
432
+ - 0
395
433
  version: "0"
396
- version:
397
434
  required_rubygems_version: !ruby/object:Gem::Requirement
398
435
  requirements:
399
436
  - - ">="
400
437
  - !ruby/object:Gem::Version
438
+ segments:
439
+ - 0
401
440
  version: "0"
402
- version:
403
441
  requirements: []
404
442
 
405
443
  rubyforge_project: ruote
406
- rubygems_version: 1.3.5
444
+ rubygems_version: 1.3.6
407
445
  signing_key:
408
446
  specification_version: 3
409
447
  summary: an open source ruby workflow engine
data/lib/ruote/exp/raw.rb DELETED
@@ -1,44 +0,0 @@
1
- #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
-
26
- module Ruote::Exp
27
-
28
- #
29
- # Not a 'real' expression. Used to keep track of failure of [pre-]apply.
30
- #
31
- class RawExpression < FlowExpression
32
-
33
- names '!raw'
34
-
35
- def apply
36
- raise "can't apply or reply [to] raw expression"
37
- end
38
-
39
- def reply (workitem)
40
- raise "can't apply or reply [to] raw expression"
41
- end
42
- end
43
- end
44
-
@@ -1,193 +0,0 @@
1
- #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
-
26
- require 'rufus/dollar' # gem 'rufus-dollar'
27
- require 'ruote/util/lookup'
28
- require 'ruote/util/treechecker'
29
-
30
-
31
- module Ruote
32
-
33
- # Performs 'dollar substitution' on a piece of text with as input
34
- # a flow expression and a workitem (fields and variables).
35
- #
36
- def self.dosub (text, flow_expression, workitem)
37
-
38
- #
39
- # patch by Nick Petrella (2008/03/20)
40
- #
41
-
42
- if text.is_a?(String)
43
-
44
- Rufus.dsub(text, FlowDict.new(flow_expression, workitem))
45
-
46
- elsif text.is_a?(Array)
47
-
48
- text.collect { |e| dosub(e, flow_expression, workitem) }
49
-
50
- elsif text.is_a?(Hash)
51
-
52
- text.inject({}) do |h, (k, v)|
53
-
54
- h[dosub(k, flow_expression, workitem)] =
55
- dosub(v, flow_expression, workitem)
56
- h
57
- end
58
-
59
- else
60
-
61
- text
62
- end
63
- end
64
-
65
- #
66
- # Wrapping a process expression and the current workitem as a
67
- # Hash object ready for lookup at substitution time.
68
- #
69
- class FlowDict
70
-
71
- def initialize (flow_expression, workitem, default_prefix='f')
72
-
73
- @fexp = flow_expression
74
- @workitem = workitem
75
- @default_prefix = default_prefix
76
- end
77
-
78
- def [] (key)
79
-
80
- return @fexp.fei.to_storage_id if key == 'fei'
81
- return @fexp.fei.wfid if key == 'wfid'
82
- return @fexp.fei.sub_wfid if key == 'sub_wfid'
83
- return @fexp.fei.expid if key == 'expid'
84
-
85
- pr, k = extract_prefix(key)
86
-
87
- # stage 0
88
-
89
- v = lookup(pr[0, 1], k)
90
-
91
- return v if v != nil
92
-
93
- # stage 1
94
-
95
- return '' if pr.size < 2
96
-
97
- lookup(pr[1, 1], k)
98
- end
99
-
100
- def []= (key, value)
101
-
102
- pr, k = extract_prefix(key)
103
- pr = pr[0, 1]
104
-
105
- if pr == 'f'
106
-
107
- @workitem.set_attribute(k, value)
108
-
109
- elsif @fexp
110
-
111
- @fexp.set_variable(k, value)
112
- end
113
- end
114
-
115
- def has_key? (key)
116
-
117
- pr, k = extract_prefix(key)
118
-
119
- return true if pr == 'r'
120
-
121
- (self[key] != nil)
122
- end
123
-
124
- protected
125
-
126
- def lookup (pr, key)
127
-
128
- case pr
129
- when 'v' then @fexp.lookup_variable(key)
130
- when 'f' then Ruote.lookup(@workitem['fields'], key)
131
- when 'r' then call_ruby(key)
132
- else nil
133
- end
134
- end
135
-
136
- def extract_prefix (key)
137
-
138
- i = key.index(':')
139
-
140
- return [ @default_prefix, key ] if not i
141
-
142
- pr = key[0..i-1] # until ':'
143
- pr = pr[0, 2] # the first two chars
144
-
145
- pr = pr[0, 1] unless (pr == 'vf') or (pr == 'fv')
146
-
147
- [ pr, key[i+1..-1] ]
148
- end
149
-
150
- # The ${r:1+2} stuff. ("3").
151
- #
152
- def call_ruby (ruby_code)
153
-
154
- return '' if @fexp.context['ruby_eval_allowed'] != true
155
-
156
- engine_id = @fexp.context.engine_id
157
-
158
- wi = Ruote::Workitem.new(@workitem)
159
- workitem = wi
160
-
161
- fe = @fexp
162
- fexp = @fexp
163
- flow_expression = @fexp
164
- fei = @fexp.fei
165
- #
166
- # some simple notations made available to ${ruby:...}
167
- # notations
168
-
169
- @fexp.context.treechecker.check(ruby_code)
170
-
171
- # clear for eval...
172
-
173
- eval(ruby_code, binding()).to_s
174
- end
175
-
176
- # This 'd' function can be called from inside ${r:...} notations.
177
- #
178
- # pdef = Ruote.process_definition do
179
- # sequence do
180
- # set 'f:toto' => 'person'
181
- # echo "${r:d('f:toto')}"
182
- # end
183
- # end
184
- #
185
- # will yield "person".
186
- #
187
- def d (s)
188
-
189
- Rufus.dsub("${#{s}}", self)
190
- end
191
- end
192
- end
193
-