ruote 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +60 -0
- data/CREDITS.txt +22 -4
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -7
- data/Rakefile +58 -59
- data/TODO.txt +137 -65
- data/couch_url.txt +1 -0
- data/jruby_issue.txt +32 -0
- data/lib/ruote.rb +1 -1
- data/lib/ruote/context.rb +12 -10
- data/lib/ruote/engine.rb +280 -145
- data/lib/ruote/engine/process_error.rb +5 -5
- data/lib/ruote/engine/process_status.rb +47 -28
- data/lib/ruote/exp/command.rb +7 -10
- data/lib/ruote/exp/commanded.rb +2 -2
- data/lib/ruote/exp/condition.rb +130 -43
- data/lib/ruote/exp/fe_add_branches.rb +2 -2
- data/lib/ruote/exp/fe_apply.rb +1 -1
- data/lib/ruote/exp/fe_cancel_process.rb +3 -3
- data/lib/ruote/exp/fe_command.rb +3 -3
- data/lib/ruote/exp/fe_concurrence.rb +4 -4
- data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
- data/lib/ruote/exp/fe_cron.rb +3 -3
- data/lib/ruote/exp/fe_cursor.rb +5 -5
- data/lib/ruote/exp/fe_define.rb +3 -3
- data/lib/ruote/exp/fe_echo.rb +3 -3
- data/lib/ruote/exp/fe_equals.rb +2 -2
- data/lib/ruote/exp/fe_error.rb +2 -2
- data/lib/ruote/exp/fe_filter.rb +519 -0
- data/lib/ruote/exp/fe_forget.rb +9 -2
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +16 -13
- data/lib/ruote/exp/fe_inc.rb +3 -3
- data/lib/ruote/exp/fe_iterator.rb +4 -4
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +68 -12
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
- data/lib/ruote/exp/fe_participant.rb +14 -17
- data/lib/ruote/exp/fe_redo.rb +10 -6
- data/lib/ruote/exp/fe_ref.rb +1 -1
- data/lib/ruote/exp/fe_registerp.rb +112 -0
- data/lib/ruote/exp/fe_reserve.rb +3 -3
- data/lib/ruote/exp/fe_restore.rb +2 -2
- data/lib/ruote/exp/fe_save.rb +2 -2
- data/lib/ruote/exp/fe_sequence.rb +3 -4
- data/lib/ruote/exp/fe_set.rb +16 -7
- data/lib/ruote/exp/fe_subprocess.rb +23 -1
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +3 -3
- data/lib/ruote/exp/fe_unregisterp.rb +71 -0
- data/lib/ruote/exp/fe_wait.rb +2 -2
- data/lib/ruote/exp/flowexpression.rb +153 -78
- data/lib/ruote/exp/iterator.rb +2 -2
- data/lib/ruote/exp/merge.rb +2 -2
- data/lib/ruote/exp/ro_attributes.rb +14 -12
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +51 -35
- data/lib/ruote/exp/ro_variables.rb +18 -27
- data/lib/ruote/fei.rb +73 -33
- data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
- data/lib/ruote/id/wfid_generator.rb +11 -4
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +36 -8
- data/lib/ruote/log/storage_history.rb +37 -5
- data/lib/ruote/log/test_logger.rb +26 -24
- data/lib/ruote/log/wait_logger.rb +5 -3
- data/lib/ruote/part/block_participant.rb +22 -11
- data/lib/ruote/part/engine_participant.rb +6 -7
- data/lib/ruote/part/local_participant.rb +6 -12
- data/lib/ruote/part/no_op_participant.rb +4 -4
- data/lib/ruote/part/null_participant.rb +4 -4
- data/lib/ruote/part/smtp_participant.rb +4 -4
- data/lib/ruote/part/storage_participant.rb +40 -20
- data/lib/ruote/part/template.rb +4 -4
- data/lib/ruote/participant.rb +0 -1
- data/lib/ruote/{parser.rb → reader.rb} +30 -25
- data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
- data/lib/ruote/{parser → reader}/xml.rb +6 -5
- data/lib/ruote/receiver/base.rb +35 -13
- data/lib/ruote/storage/base.rb +20 -18
- data/lib/ruote/storage/composite_storage.rb +10 -10
- data/lib/ruote/storage/fs_storage.rb +17 -10
- data/lib/ruote/storage/hash_storage.rb +29 -18
- data/lib/ruote/svc/dispatch_pool.rb +41 -14
- data/lib/ruote/svc/dollar_sub.rb +50 -17
- data/lib/ruote/svc/error_handler.rb +19 -11
- data/lib/ruote/svc/expression_map.rb +4 -4
- data/lib/ruote/svc/participant_list.rb +105 -100
- data/lib/ruote/svc/tracker.rb +58 -18
- data/lib/ruote/svc/treechecker.rb +51 -24
- data/lib/ruote/tree_dot.rb +4 -4
- data/lib/ruote/util/filter.rb +440 -0
- data/lib/ruote/util/hashdot.rb +4 -4
- data/lib/ruote/util/look.rb +2 -6
- data/lib/ruote/util/lookup.rb +9 -7
- data/lib/ruote/util/misc.rb +40 -8
- data/lib/ruote/util/ometa.rb +1 -1
- data/lib/ruote/util/serializer.rb +4 -4
- data/lib/ruote/util/subprocess.rb +29 -9
- data/lib/ruote/util/time.rb +4 -4
- data/lib/ruote/util/tree.rb +3 -3
- data/lib/ruote/version.rb +2 -2
- data/lib/ruote/worker.rb +55 -32
- data/lib/ruote/workitem.rb +64 -11
- data/ruote.gemspec +31 -302
- data/test/bm/launch_bench.rb +37 -0
- data/test/functional/base.rb +60 -18
- data/test/functional/concurrent_base.rb +2 -2
- data/test/functional/ct_0_concurrence.rb +1 -1
- data/test/functional/ct_1_iterator.rb +1 -1
- data/test/functional/ct_2_cancel.rb +1 -1
- data/test/functional/eft_0_process_definition.rb +2 -2
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_11_wait.rb +19 -11
- data/test/functional/eft_12_listen.rb +79 -13
- data/test/functional/eft_13_iterator.rb +13 -10
- data/test/functional/eft_14_cursor.rb +98 -9
- data/test/functional/eft_15_loop.rb +6 -4
- data/test/functional/eft_16_if.rb +12 -0
- data/test/functional/eft_18_concurrent_iterator.rb +31 -32
- data/test/functional/eft_19_reserve.rb +4 -4
- data/test/functional/eft_1_echo.rb +9 -0
- data/test/functional/eft_20_save.rb +4 -4
- data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
- data/test/functional/eft_30_ref.rb +17 -2
- data/test/functional/eft_31_registerp.rb +130 -0
- data/test/functional/eft_32_lose.rb +93 -0
- data/test/functional/eft_33_let.rb +31 -0
- data/test/functional/eft_34_given.rb +123 -0
- data/test/functional/eft_35_filter.rb +269 -0
- data/test/functional/eft_3_participant.rb +4 -6
- data/test/functional/eft_4_set.rb +16 -2
- data/test/functional/eft_5_subprocess.rb +2 -4
- data/test/functional/eft_6_concurrence.rb +29 -29
- data/test/functional/eft_8_undo.rb +39 -3
- data/test/functional/eft_9_redo.rb +94 -2
- data/test/functional/ft_10_dollar.rb +81 -2
- data/test/functional/ft_11_recursion.rb +13 -17
- data/test/functional/ft_12_launchitem.rb +9 -5
- data/test/functional/ft_13_variables.rb +7 -9
- data/test/functional/ft_14_re_apply.rb +6 -9
- data/test/functional/ft_15_timeout.rb +18 -18
- data/test/functional/ft_16_participant_params.rb +1 -3
- data/test/functional/ft_17_conditional.rb +25 -2
- data/test/functional/ft_18_kill.rb +65 -12
- data/test/functional/ft_1_process_status.rb +147 -71
- data/test/functional/ft_20_storage_participant.rb +0 -1
- data/test/functional/ft_21_forget.rb +82 -1
- data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
- data/test/functional/ft_25_receiver.rb +47 -17
- data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
- data/test/functional/ft_29_part_template.rb +6 -5
- data/test/functional/ft_2_errors.rb +21 -37
- data/test/functional/ft_30_smtp_participant.rb +1 -1
- data/test/functional/ft_31_part_blocking.rb +8 -6
- data/test/functional/ft_34_cursor_rewind.rb +13 -10
- data/test/functional/ft_35_add_service.rb +1 -1
- data/test/functional/ft_36_storage_history.rb +24 -1
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +10 -10
- data/test/functional/ft_39_wait_for.rb +12 -9
- data/test/functional/ft_3_participant_registration.rb +111 -32
- data/test/functional/ft_40_wait_logger.rb +2 -1
- data/test/functional/ft_41_participants.rb +30 -4
- data/test/functional/ft_43_participant_on_reply.rb +6 -23
- data/test/functional/ft_45_participant_accept.rb +4 -4
- data/test/functional/ft_46_launch_single.rb +36 -2
- data/test/functional/ft_47_wfid_generator.rb +54 -0
- data/test/functional/ft_48_lose.rb +112 -0
- data/test/functional/ft_49_engine_on_error.rb +201 -0
- data/test/functional/ft_4_cancel.rb +66 -6
- data/test/functional/ft_50_engine_config.rb +22 -0
- data/test/functional/ft_51_misc.rb +67 -0
- data/test/functional/ft_52_case.rb +134 -0
- data/test/functional/ft_53_engine_on_terminate.rb +95 -0
- data/test/functional/ft_54_patterns.rb +104 -0
- data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_5_on_error.rb +77 -30
- data/test/functional/ft_6_on_cancel.rb +66 -11
- data/test/functional/ft_7_tags.rb +94 -5
- data/test/functional/ft_8_participant_consumption.rb +36 -5
- data/test/functional/ft_9_subprocesses.rb +10 -10
- data/test/functional/rt_1_listen.rb +3 -3
- data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
- data/test/functional/storage_helper.rb +15 -13
- data/test/functional/test.rb +1 -3
- data/test/test_helper.rb +0 -8
- data/test/unit/storage.rb +154 -10
- data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
- data/test/unit/ut_11_lookup.rb +7 -0
- data/test/unit/ut_13_serializer.rb +1 -1
- data/test/unit/ut_15_util.rb +23 -0
- data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
- data/test/unit/ut_1_fei.rb +57 -10
- data/test/unit/ut_20_composite_storage.rb +25 -11
- data/test/unit/ut_21_participant_list.rb +47 -0
- data/test/unit/ut_22_filter.rb +903 -0
- data/test/unit/ut_3_wait_logger.rb +2 -6
- data/test/unit/ut_6_condition.rb +164 -17
- data/test/unit/ut_7_workitem.rb +28 -0
- data/test/unit/ut_8_tree_to_dot.rb +1 -1
- data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
- metadata +108 -84
- data/.gitignore +0 -4
- data/examples/barley.rb +0 -391
- data/examples/flickr_report.rb +0 -107
- data/examples/pong.rb +0 -37
- data/examples/ruote_quickstart.rb +0 -43
- data/examples/web_first_page.rb +0 -68
- data/lib/ruote/part/hash_participant.rb +0 -91
- data/test/README.rdoc +0 -15
- data/test/functional/crunner.sh +0 -19
- data/test/pdef.xml +0 -7
- data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -39,17 +39,19 @@ module Ruote
|
|
39
39
|
|
40
40
|
attr_reader :h
|
41
41
|
|
42
|
-
def initialize
|
42
|
+
def initialize(options={})
|
43
43
|
|
44
44
|
super()
|
45
45
|
# since were including MonitorMixin, this super() is necessary
|
46
46
|
|
47
|
+
@options = options
|
48
|
+
|
47
49
|
purge!
|
48
50
|
|
49
51
|
put(options.merge('type' => 'configurations', '_id' => 'engine'))
|
50
52
|
end
|
51
53
|
|
52
|
-
def put
|
54
|
+
def put(doc, opts={})
|
53
55
|
|
54
56
|
i = @h.size
|
55
57
|
|
@@ -79,16 +81,23 @@ module Ruote
|
|
79
81
|
|
80
82
|
nil
|
81
83
|
end
|
84
|
+
|
85
|
+
rescue => e
|
86
|
+
puts "=" * 80
|
87
|
+
File.open('doc.json', 'wb') do |f|
|
88
|
+
f.puts Rufus::Json.pretty_encode(doc)
|
89
|
+
end
|
90
|
+
raise e
|
82
91
|
end
|
83
92
|
|
84
|
-
def get
|
93
|
+
def get(type, key)
|
85
94
|
|
86
95
|
synchronize do
|
87
96
|
Ruote.fulldup(@h[type][key])
|
88
97
|
end
|
89
98
|
end
|
90
99
|
|
91
|
-
def delete
|
100
|
+
def delete(doc)
|
92
101
|
|
93
102
|
drev = doc['_rev']
|
94
103
|
|
@@ -102,20 +111,15 @@ module Ruote
|
|
102
111
|
|
103
112
|
doc['_rev'] ||= 0
|
104
113
|
|
105
|
-
if prev['_rev']
|
114
|
+
return prev if prev['_rev'] != drev
|
106
115
|
|
107
|
-
|
108
|
-
|
109
|
-
nil
|
110
|
-
|
111
|
-
else
|
116
|
+
@h[doc['type']].delete(doc['_id'])
|
112
117
|
|
113
|
-
|
114
|
-
end
|
118
|
+
nil # success
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
118
|
-
def get_many
|
122
|
+
def get_many(type, key=nil, opts={})
|
119
123
|
|
120
124
|
# NOTE : no dup here for now
|
121
125
|
|
@@ -145,7 +149,7 @@ module Ruote
|
|
145
149
|
|
146
150
|
# Returns a sorted list of all the ids for a given type.
|
147
151
|
#
|
148
|
-
def ids
|
152
|
+
def ids(type)
|
149
153
|
|
150
154
|
@h[type].keys.sort
|
151
155
|
end
|
@@ -173,17 +177,17 @@ module Ruote
|
|
173
177
|
@h['configurations']['engine'] = @options
|
174
178
|
end
|
175
179
|
|
176
|
-
def add_type
|
180
|
+
def add_type(type)
|
177
181
|
|
178
182
|
@h[type] = {}
|
179
183
|
end
|
180
184
|
|
181
|
-
def purge_type!
|
185
|
+
def purge_type!(type)
|
182
186
|
|
183
187
|
@h[type] = {}
|
184
188
|
end
|
185
189
|
|
186
|
-
def dump
|
190
|
+
def dump(type)
|
187
191
|
|
188
192
|
s = "=== #{type} ===\n"
|
189
193
|
|
@@ -195,6 +199,13 @@ module Ruote
|
|
195
199
|
end
|
196
200
|
end
|
197
201
|
end
|
202
|
+
|
203
|
+
# Shuts this storage down.
|
204
|
+
#
|
205
|
+
def shutdown
|
206
|
+
|
207
|
+
# nothing to do
|
208
|
+
end
|
198
209
|
end
|
199
210
|
end
|
200
211
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -34,12 +34,12 @@ module Ruote
|
|
34
34
|
#
|
35
35
|
class DispatchPool
|
36
36
|
|
37
|
-
def initialize
|
37
|
+
def initialize(context)
|
38
38
|
|
39
39
|
@context = context
|
40
40
|
end
|
41
41
|
|
42
|
-
def handle
|
42
|
+
def handle(msg)
|
43
43
|
|
44
44
|
case msg['action']
|
45
45
|
when 'dispatch'
|
@@ -47,13 +47,13 @@ module Ruote
|
|
47
47
|
when 'dispatch_cancel'
|
48
48
|
dispatch_cancel(msg)
|
49
49
|
else
|
50
|
-
# simply discard message
|
50
|
+
# simply discard the message
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
protected
|
55
55
|
|
56
|
-
def dispatch_cancel
|
56
|
+
def dispatch_cancel(msg)
|
57
57
|
|
58
58
|
flavour = msg['flavour']
|
59
59
|
|
@@ -61,7 +61,7 @@ module Ruote
|
|
61
61
|
|
62
62
|
begin
|
63
63
|
participant.cancel(Ruote::FlowExpressionId.new(msg['fei']), flavour)
|
64
|
-
rescue
|
64
|
+
rescue => e
|
65
65
|
raise(e) if flavour != 'kill'
|
66
66
|
end
|
67
67
|
|
@@ -71,19 +71,21 @@ module Ruote
|
|
71
71
|
'workitem' => msg['workitem'])
|
72
72
|
end
|
73
73
|
|
74
|
-
def dispatch
|
74
|
+
def dispatch(msg)
|
75
75
|
|
76
76
|
participant = @context.plist.lookup(
|
77
77
|
msg['participant'] || msg['participant_name'], msg['workitem'])
|
78
78
|
|
79
|
-
if participant
|
79
|
+
if do_not_thread(participant, msg)
|
80
80
|
do_dispatch(participant, msg)
|
81
81
|
else
|
82
82
|
do_threaded_dispatch(participant, msg)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
# The actual dispatching (call to Participant#consume).
|
87
|
+
#
|
88
|
+
def do_dispatch(participant, msg)
|
87
89
|
|
88
90
|
workitem = Ruote::Workitem.new(msg['workitem'])
|
89
91
|
|
@@ -91,12 +93,23 @@ module Ruote
|
|
91
93
|
|
92
94
|
participant.consume(workitem)
|
93
95
|
|
94
|
-
@context.storage.put_msg(
|
95
|
-
|
96
|
-
|
96
|
+
@context.storage.put_msg(
|
97
|
+
'dispatched',
|
98
|
+
'fei' => msg['fei'],
|
99
|
+
'participant_name' => workitem.participant_name)
|
100
|
+
# once the consume is done, asynchronously flag the
|
101
|
+
# participant expression as 'dispatched'
|
97
102
|
end
|
98
103
|
|
99
|
-
|
104
|
+
# Wraps the call to do_dispatch in a thread.
|
105
|
+
#
|
106
|
+
def do_threaded_dispatch(participant, msg)
|
107
|
+
|
108
|
+
msg = Rufus::Json.dup(msg)
|
109
|
+
#
|
110
|
+
# the thread gets its own copy of the message
|
111
|
+
# (especially important if the main thread does something with
|
112
|
+
# the message 'during' the dispatch)
|
100
113
|
|
101
114
|
# Maybe at some point a limit on the number of dispatch threads
|
102
115
|
# would be OK.
|
@@ -107,11 +120,25 @@ module Ruote
|
|
107
120
|
|
108
121
|
do_dispatch(participant, msg)
|
109
122
|
|
110
|
-
rescue
|
123
|
+
rescue => exception
|
111
124
|
@context.error_handler.msg_handle(msg, exception)
|
112
125
|
end
|
113
126
|
end
|
114
127
|
end
|
128
|
+
|
129
|
+
# Returns true if the participant doesn't want the #consume to happen
|
130
|
+
# in a new Thread.
|
131
|
+
#
|
132
|
+
def do_not_thread(participant, msg)
|
133
|
+
|
134
|
+
return false unless participant.respond_to?(:do_not_thread)
|
135
|
+
|
136
|
+
if participant.method(:do_not_thread).arity == 0
|
137
|
+
participant.do_not_thread
|
138
|
+
else
|
139
|
+
participant.do_not_thread(Ruote::Workitem.new(msg['workitem']))
|
140
|
+
end
|
141
|
+
end
|
115
142
|
end
|
116
143
|
end
|
117
144
|
|
data/lib/ruote/svc/dollar_sub.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -40,7 +40,7 @@ module Ruote
|
|
40
40
|
#
|
41
41
|
class DollarSubstitution
|
42
42
|
|
43
|
-
def initialize
|
43
|
+
def initialize(context)
|
44
44
|
|
45
45
|
@context = context
|
46
46
|
end
|
@@ -50,11 +50,14 @@ module Ruote
|
|
50
50
|
#
|
51
51
|
# With help from Nick Petrella (2008/03/20)
|
52
52
|
#
|
53
|
-
def s
|
53
|
+
def s(text, flow_expression, workitem)
|
54
54
|
|
55
55
|
if text.is_a?(String)
|
56
56
|
|
57
|
-
|
57
|
+
literal_sub(
|
58
|
+
Rufus.dsub(text, dict_class.new(flow_expression, workitem)),
|
59
|
+
flow_expression,
|
60
|
+
workitem)
|
58
61
|
|
59
62
|
elsif text.is_a?(Array)
|
60
63
|
|
@@ -82,6 +85,26 @@ module Ruote
|
|
82
85
|
|
83
86
|
::Ruote::Dollar::Dict
|
84
87
|
end
|
88
|
+
|
89
|
+
protected
|
90
|
+
|
91
|
+
# If the final text is of the form "$f:x" or "$v:y" will lookup the
|
92
|
+
# x field or the y variable. If the lookup is successful (not nil) will
|
93
|
+
# return the, not the text.
|
94
|
+
#
|
95
|
+
def literal_sub(s, fexp, wi)
|
96
|
+
|
97
|
+
result = case s
|
98
|
+
when /^\$([^{}:])$/, /^\$(?:field|fld|f):([^{}]+)$/
|
99
|
+
Ruote.lookup(wi['fields'], $~[1])
|
100
|
+
when /^\$(?:variable|var|v):([^{}]+)$/
|
101
|
+
fexp.lookup_variable($~[1])
|
102
|
+
else
|
103
|
+
s
|
104
|
+
end
|
105
|
+
|
106
|
+
result.nil? ? s : result
|
107
|
+
end
|
85
108
|
end
|
86
109
|
|
87
110
|
|
@@ -100,18 +123,20 @@ module Ruote
|
|
100
123
|
attr_reader :fexp
|
101
124
|
attr_reader :workitem
|
102
125
|
|
103
|
-
def initialize
|
126
|
+
def initialize(flowexpression, workitem)
|
104
127
|
|
105
128
|
@fexp = flowexpression
|
106
129
|
@workitem = workitem
|
107
130
|
end
|
108
131
|
|
109
|
-
def []
|
132
|
+
def [](key)
|
110
133
|
|
111
134
|
return @fexp.fei.to_storage_id if key == 'fei'
|
112
135
|
return @fexp.fei.wfid if key == 'wfid'
|
113
|
-
return @fexp.fei.
|
136
|
+
return @fexp.fei.subid if key == 'subid'
|
137
|
+
return @fexp.fei.subid if key == 'sub_wfid' # deprecated in 2.1.12
|
114
138
|
return @fexp.fei.expid if key == 'expid'
|
139
|
+
return @fexp.fei.engine_id if key == 'engine_id'
|
115
140
|
|
116
141
|
pr, k = extract_prefix(key)
|
117
142
|
|
@@ -128,7 +153,7 @@ module Ruote
|
|
128
153
|
lookup(pr[1, 1], k)
|
129
154
|
end
|
130
155
|
|
131
|
-
def []=
|
156
|
+
def []=(key, value)
|
132
157
|
|
133
158
|
pr, k = extract_prefix(key)
|
134
159
|
pr = pr[0, 1]
|
@@ -143,7 +168,7 @@ module Ruote
|
|
143
168
|
end
|
144
169
|
end
|
145
170
|
|
146
|
-
def has_key?
|
171
|
+
def has_key?(key)
|
147
172
|
|
148
173
|
pr, k = extract_prefix(key)
|
149
174
|
|
@@ -154,7 +179,7 @@ module Ruote
|
|
154
179
|
|
155
180
|
protected
|
156
181
|
|
157
|
-
def lookup
|
182
|
+
def lookup(pr, key)
|
158
183
|
|
159
184
|
case pr
|
160
185
|
when 'v' then @fexp.lookup_variable(key)
|
@@ -164,7 +189,7 @@ module Ruote
|
|
164
189
|
end
|
165
190
|
end
|
166
191
|
|
167
|
-
def extract_prefix
|
192
|
+
def extract_prefix(key)
|
168
193
|
|
169
194
|
i = key.index(':')
|
170
195
|
|
@@ -181,11 +206,15 @@ module Ruote
|
|
181
206
|
|
182
207
|
# TODO : rdoc me
|
183
208
|
#
|
184
|
-
def ruby_eval
|
209
|
+
def ruby_eval(ruby_code)
|
185
210
|
|
186
|
-
|
211
|
+
raise ArgumentError.new(
|
212
|
+
"'ruby_eval_allowed' is set to false, cannot evaluate >" +
|
213
|
+
ruby_code +
|
214
|
+
"< (http://ruote.rubyforge.org/dollar.html)"
|
215
|
+
) if @fexp.context['ruby_eval_allowed'] != true
|
187
216
|
|
188
|
-
@fexp.context.treechecker.
|
217
|
+
@fexp.context.treechecker.dollar_check(ruby_code)
|
189
218
|
|
190
219
|
RubyContext.new(self).instance_eval(ruby_code)
|
191
220
|
end
|
@@ -198,7 +227,7 @@ module Ruote
|
|
198
227
|
|
199
228
|
attr_reader :workitem
|
200
229
|
|
201
|
-
def initialize
|
230
|
+
def initialize(dict)
|
202
231
|
|
203
232
|
@dict = dict
|
204
233
|
@workitem = Ruote::Workitem.new(@dict.workitem)
|
@@ -207,8 +236,10 @@ module Ruote
|
|
207
236
|
# The FlowExpression for which the rendering/substitution is occurring.
|
208
237
|
#
|
209
238
|
def flow_expression
|
239
|
+
|
210
240
|
@dict.fexp
|
211
241
|
end
|
242
|
+
|
212
243
|
alias fe flow_expression
|
213
244
|
alias fexp flow_expression
|
214
245
|
|
@@ -216,6 +247,7 @@ module Ruote
|
|
216
247
|
# rendering/substitution is occurring.
|
217
248
|
#
|
218
249
|
def fei
|
250
|
+
|
219
251
|
@dict.fexp.fei
|
220
252
|
end
|
221
253
|
|
@@ -224,6 +256,7 @@ module Ruote
|
|
224
256
|
# The engine_id, if any.
|
225
257
|
#
|
226
258
|
def engine_id
|
259
|
+
|
227
260
|
@dict.fexp.context.engine_id
|
228
261
|
end
|
229
262
|
|
@@ -238,7 +271,7 @@ module Ruote
|
|
238
271
|
#
|
239
272
|
# will yield "person".
|
240
273
|
#
|
241
|
-
def d
|
274
|
+
def d(s)
|
242
275
|
|
243
276
|
Rufus.dsub("${#{s}}", @dict)
|
244
277
|
end
|
@@ -251,7 +284,7 @@ module Ruote
|
|
251
284
|
#
|
252
285
|
# Else the regular NoMethodError will be raised.
|
253
286
|
#
|
254
|
-
def method_missing
|
287
|
+
def method_missing(m, *args)
|
255
288
|
|
256
289
|
if args.length < 1 && v = @workitem.fields[m.to_s]
|
257
290
|
return v
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -35,14 +35,14 @@ module Ruote
|
|
35
35
|
#
|
36
36
|
class ErrorHandler
|
37
37
|
|
38
|
-
def initialize
|
38
|
+
def initialize(context)
|
39
39
|
|
40
40
|
@context = context
|
41
41
|
end
|
42
42
|
|
43
43
|
# As used by the dispatch pool and the worker.
|
44
44
|
#
|
45
|
-
def msg_handle
|
45
|
+
def msg_handle(msg, exception)
|
46
46
|
|
47
47
|
fexp = Ruote::Exp::FlowExpression.fetch(
|
48
48
|
@context, msg['fei'] || msg['workitem']['fei']
|
@@ -53,7 +53,7 @@ module Ruote
|
|
53
53
|
|
54
54
|
# As used by some receivers (see ruote-beanstalk's receiver).
|
55
55
|
#
|
56
|
-
def action_handle
|
56
|
+
def action_handle(action, fei, exception)
|
57
57
|
|
58
58
|
fexp = Ruote::Exp::FlowExpression.fetch(@context, fei)
|
59
59
|
|
@@ -70,7 +70,7 @@ module Ruote
|
|
70
70
|
|
71
71
|
# As used by the worker.
|
72
72
|
#
|
73
|
-
def handle
|
73
|
+
def handle(msg, fexp, exception)
|
74
74
|
|
75
75
|
wfid = msg['wfid'] || (msg['fei']['wfid'] rescue nil)
|
76
76
|
fei = msg['fei'] || (fexp.h.fei rescue nil)
|
@@ -88,8 +88,11 @@ module Ruote
|
|
88
88
|
puts "..."
|
89
89
|
puts
|
90
90
|
puts "-- msg --"
|
91
|
+
key_length = msg.keys.collect { |k| k.length }.max + 1
|
91
92
|
msg.keys.sort.each { |k|
|
92
|
-
|
93
|
+
v = msg[k]
|
94
|
+
v = (Ruote.sid(v) rescue nil) if k == 'fei' || k == 'parent_id'
|
95
|
+
printf("%*s : %s\n", key_length, k, v.inspect)
|
93
96
|
}
|
94
97
|
puts "-- . --"
|
95
98
|
puts
|
@@ -100,15 +103,20 @@ module Ruote
|
|
100
103
|
return if fexp && fexp.handle_on_error(msg, exception)
|
101
104
|
|
102
105
|
# emit 'msg'
|
106
|
+
#
|
107
|
+
# (this message might get intercepted by a tracker)
|
103
108
|
|
104
109
|
@context.storage.put_msg(
|
105
110
|
'error_intercepted',
|
106
|
-
'
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
+
'error' => {
|
112
|
+
'fei' => fei,
|
113
|
+
'at' => Ruote.now_to_utc_s,
|
114
|
+
'class' => exception.class.name,
|
115
|
+
'message' => exception.message,
|
116
|
+
'trace' => backtrace
|
117
|
+
},
|
111
118
|
'wfid' => wfid,
|
119
|
+
'fei' => fei,
|
112
120
|
'msg' => msg)
|
113
121
|
|
114
122
|
# fill error in the error journal
|