ruote 2.3.0.1 → 2.3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +23 -0
- data/CREDITS.txt +4 -0
- data/LICENSE.txt +1 -1
- data/lib/ruote.rb +2 -0
- data/lib/ruote/context.rb +2 -1
- data/lib/ruote/dashboard.rb +169 -13
- data/lib/ruote/dboard/mutation.rb +282 -0
- data/lib/ruote/dboard/process_error.rb +1 -1
- data/lib/ruote/dboard/process_status.rb +61 -48
- data/lib/ruote/engine.rb +1 -1
- data/lib/ruote/exp/command.rb +1 -1
- data/lib/ruote/exp/commanded.rb +1 -1
- data/lib/ruote/exp/condition.rb +2 -1
- data/lib/ruote/exp/fe_add_branches.rb +1 -1
- data/lib/ruote/exp/fe_apply.rb +1 -1
- data/lib/ruote/exp/fe_await.rb +97 -48
- data/lib/ruote/exp/fe_cancel_process.rb +1 -1
- data/lib/ruote/exp/fe_command.rb +2 -3
- data/lib/ruote/exp/fe_concurrence.rb +162 -66
- data/lib/ruote/exp/fe_concurrent_iterator.rb +25 -7
- data/lib/ruote/exp/fe_cron.rb +1 -1
- data/lib/ruote/exp/fe_cursor.rb +10 -11
- data/lib/ruote/exp/fe_define.rb +1 -1
- data/lib/ruote/exp/fe_echo.rb +1 -1
- data/lib/ruote/exp/fe_equals.rb +1 -1
- data/lib/ruote/exp/fe_error.rb +1 -1
- data/lib/ruote/exp/fe_filter.rb +1 -1
- data/lib/ruote/exp/fe_forget.rb +1 -1
- data/lib/ruote/exp/fe_given.rb +1 -1
- data/lib/ruote/exp/fe_if.rb +87 -7
- data/lib/ruote/exp/fe_inc.rb +1 -1
- data/lib/ruote/exp/fe_iterator.rb +1 -1
- data/lib/ruote/exp/fe_listen.rb +1 -1
- data/lib/ruote/exp/fe_lose.rb +1 -1
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/fe_on_error.rb +1 -1
- data/lib/ruote/exp/fe_once.rb +1 -1
- data/lib/ruote/exp/fe_participant.rb +49 -16
- data/lib/ruote/exp/fe_read.rb +1 -1
- data/lib/ruote/exp/fe_redo.rb +1 -1
- data/lib/ruote/exp/fe_ref.rb +1 -1
- data/lib/ruote/exp/fe_registerp.rb +1 -1
- data/lib/ruote/exp/fe_reserve.rb +1 -1
- data/lib/ruote/exp/fe_restore.rb +1 -7
- data/lib/ruote/exp/fe_save.rb +1 -1
- data/lib/ruote/exp/fe_sequence.rb +1 -1
- data/lib/ruote/exp/fe_set.rb +1 -1
- data/lib/ruote/exp/fe_stall.rb +1 -1
- data/lib/ruote/exp/fe_subprocess.rb +1 -1
- data/lib/ruote/exp/fe_that.rb +1 -1
- data/lib/ruote/exp/fe_undo.rb +1 -1
- data/lib/ruote/exp/fe_unregisterp.rb +1 -1
- data/lib/ruote/exp/fe_wait.rb +1 -1
- data/lib/ruote/exp/flow_expression.rb +117 -8
- data/lib/ruote/exp/iterator.rb +1 -1
- data/lib/ruote/exp/ro_attributes.rb +1 -1
- data/lib/ruote/exp/ro_filters.rb +1 -1
- data/lib/ruote/exp/ro_on_x.rb +4 -2
- data/lib/ruote/exp/ro_persist.rb +1 -1
- data/lib/ruote/exp/ro_timers.rb +1 -1
- data/lib/ruote/exp/ro_variables.rb +1 -1
- data/lib/ruote/extract.rb +125 -0
- data/lib/ruote/fei.rb +10 -73
- data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
- data/lib/ruote/id/wfid_generator.rb +1 -1
- data/lib/ruote/log/default_history.rb +17 -3
- data/lib/ruote/log/fancy_printing.rb +12 -32
- data/lib/ruote/log/storage_history.rb +1 -1
- data/lib/ruote/log/wait_logger.rb +15 -7
- data/lib/ruote/merge.rb +123 -0
- data/lib/ruote/observer.rb +1 -1
- data/lib/ruote/part/block_participant.rb +1 -1
- data/lib/ruote/part/code_participant.rb +1 -1
- data/lib/ruote/part/engine_participant.rb +1 -1
- data/lib/ruote/part/local_participant.rb +9 -1
- data/lib/ruote/part/no_op_participant.rb +1 -1
- data/lib/ruote/part/null_participant.rb +1 -1
- data/lib/ruote/part/participant.rb +1 -1
- data/lib/ruote/part/rev_participant.rb +1 -1
- data/lib/ruote/part/smtp_participant.rb +1 -1
- data/lib/ruote/part/storage_participant.rb +18 -1
- data/lib/ruote/part/template.rb +1 -1
- data/lib/ruote/reader.rb +1 -1
- data/lib/ruote/reader/json.rb +1 -1
- data/lib/ruote/reader/radial.rb +4 -4
- data/lib/ruote/reader/ruby_dsl.rb +1 -1
- data/lib/ruote/reader/xml.rb +1 -1
- data/lib/ruote/receiver/base.rb +13 -1
- data/lib/ruote/storage/base.rb +8 -14
- data/lib/ruote/storage/composite_storage.rb +1 -1
- data/lib/ruote/storage/fs_storage.rb +1 -1
- data/lib/ruote/storage/hash_storage.rb +2 -1
- data/lib/ruote/svc/dispatch_pool.rb +29 -18
- data/lib/ruote/svc/dollar_sub.rb +5 -8
- data/lib/ruote/svc/error_handler.rb +1 -1
- data/lib/ruote/svc/expression_map.rb +1 -1
- data/lib/ruote/svc/participant_list.rb +8 -5
- data/lib/ruote/svc/tracker.rb +154 -56
- data/lib/ruote/svc/treechecker.rb +1 -1
- data/lib/ruote/tree_dot.rb +1 -1
- data/lib/ruote/util/deep.rb +4 -2
- data/lib/ruote/util/filter.rb +1 -1
- data/lib/ruote/util/hashdot.rb +1 -1
- data/lib/ruote/util/look.rb +1 -1
- data/lib/ruote/util/lookup.rb +1 -1
- data/lib/ruote/util/misc.rb +51 -1
- data/lib/ruote/util/mpatch.rb +1 -1
- data/lib/ruote/util/ometa.rb +1 -1
- data/lib/ruote/util/subprocess.rb +1 -1
- data/lib/ruote/util/time.rb +3 -3
- data/lib/ruote/util/tree.rb +43 -4
- data/lib/ruote/version.rb +2 -2
- data/lib/ruote/worker.rb +30 -18
- data/lib/ruote/workitem.rb +1 -1
- data/ruote.gemspec +6 -2
- data/test/functional/base.rb +0 -1
- data/test/functional/concurrent_base.rb +1 -1
- data/test/functional/eft_14_cursor.rb +42 -52
- data/test/functional/eft_16_if.rb +24 -16
- data/test/functional/eft_18_concurrent_iterator.rb +31 -1
- data/test/functional/eft_6_concurrence.rb +149 -34
- data/test/functional/ft_10_dollar.rb +14 -30
- data/test/functional/ft_12_launchitem.rb +15 -0
- data/test/functional/ft_1_process_status.rb +62 -13
- data/test/functional/ft_20_storage_participant.rb +25 -0
- data/test/functional/ft_38_participant_more.rb +1 -1
- data/test/functional/ft_42_storage_copy.rb +1 -3
- data/test/functional/ft_43_participant_on_reply.rb +63 -5
- data/test/functional/ft_66_flank.rb +41 -0
- data/test/functional/ft_6_on_cancel.rb +9 -18
- data/test/functional/ft_71_retries.rb +25 -12
- data/test/functional/ft_79_attach.rb +138 -0
- data/test/functional/ft_7_tags.rb +27 -0
- data/test/functional/ft_80_pause_on_apply.rb +64 -0
- data/test/functional/ft_81_mutation.rb +417 -0
- data/test/functional/ft_82_await_attribute.rb +84 -0
- data/test/functional/ft_83_trackers.rb +79 -0
- data/test/functional/storage.rb +3 -4
- data/test/unit/ut_12_wait_logger.rb +41 -3
- data/test/unit/ut_15_util.rb +30 -0
- data/test/unit/ut_17_merge.rb +54 -53
- data/test/unit/ut_1_fei.rb +2 -2
- data/test/unit/ut_24_radial_reader.rb +7 -0
- data/test/unit/ut_26_deep.rb +14 -0
- data/test/unit/ut_5_tree.rb +38 -28
- metadata +206 -169
- data/couch_url.txt +0 -1
- data/lib/ruote/exp/merge.rb +0 -134
data/lib/ruote/observer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -57,6 +57,14 @@ module Ruote
|
|
57
57
|
#
|
58
58
|
attr_accessor :flavour
|
59
59
|
|
60
|
+
# Set right before a call to #on_error
|
61
|
+
#
|
62
|
+
attr_accessor :error
|
63
|
+
|
64
|
+
# Set right before a call to #on_error
|
65
|
+
#
|
66
|
+
attr_accessor :msg
|
67
|
+
|
60
68
|
# Returns the current workitem if no fei is given.
|
61
69
|
# If a fei is given, it will return the applied workitem for that fei
|
62
70
|
# (if any).
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, Alain Hoang and John Mettraux.
|
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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -106,6 +106,23 @@ module Ruote
|
|
106
106
|
r.is_a?(Hash) ? Ruote::Workitem.new(r) : r
|
107
107
|
end
|
108
108
|
|
109
|
+
# Added for https://groups.google.com/forum/?fromgroups#!topic/openwferu-users/5bpV2yfKwM0
|
110
|
+
#
|
111
|
+
# Makes sure the workitem get saved to the storage. Fails if the workitem
|
112
|
+
# is already gone.
|
113
|
+
# Returns nil in case of success.
|
114
|
+
#
|
115
|
+
def do_update(workitem=@workitem)
|
116
|
+
|
117
|
+
r = update(workitem)
|
118
|
+
|
119
|
+
fail ArgumentError.new("workitem is gone") if r == true
|
120
|
+
return nil if r.nil?
|
121
|
+
|
122
|
+
r.h['fields'] = workitem.fields
|
123
|
+
do_update(r)
|
124
|
+
end
|
125
|
+
|
109
126
|
# Removes the document/workitem from the storage.
|
110
127
|
#
|
111
128
|
# Warning: this method is called by the engine (worker), i.e. not by you.
|
data/lib/ruote/part/template.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
data/lib/ruote/reader.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
data/lib/ruote/reader/json.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
data/lib/ruote/reader/radial.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -63,16 +63,16 @@ module Ruote
|
|
63
63
|
|
64
64
|
rule(:string) {
|
65
65
|
str('"') >> (
|
66
|
-
str('\\') >> any |
|
66
|
+
str('\\') >> any | match('[^"]')
|
67
67
|
).repeat.as(:string) >> str('"') |
|
68
68
|
str("'") >> (
|
69
|
-
str('\\') >> any |
|
69
|
+
str('\\') >> any | match("[^']")
|
70
70
|
).repeat.as(:string) >> str("'")
|
71
71
|
}
|
72
72
|
|
73
73
|
rule(:regex) {
|
74
74
|
str('/') >> (
|
75
|
-
str('\\') >> any |
|
75
|
+
str('\\') >> any | match("[^\/]")
|
76
76
|
).repeat.as(:regex) >> str('/')
|
77
77
|
}
|
78
78
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
data/lib/ruote/reader/xml.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
data/lib/ruote/receiver/base.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -129,8 +129,20 @@ module Ruote
|
|
129
129
|
#
|
130
130
|
def launch(process_definition, fields={}, variables={}, root_stash=nil)
|
131
131
|
|
132
|
+
puts caller.select { |l|
|
133
|
+
! (l.match(/test\/unit[\.\/]/) or l.match(/\/rspec-core-/))
|
134
|
+
} if @context.logger.noisy
|
135
|
+
#
|
136
|
+
# this is useful when noisy and running through a set of tests
|
137
|
+
|
132
138
|
wfid = fields[:wfid] || @context.wfidgen.generate
|
133
139
|
|
140
|
+
fields = Rufus::Json.dup(fields)
|
141
|
+
variables = Rufus::Json.dup(variables)
|
142
|
+
root_stash = Rufus::Json.dup(root_stash)
|
143
|
+
#
|
144
|
+
# making sure symbols are turned to strings
|
145
|
+
|
134
146
|
@context.storage.put_msg(
|
135
147
|
'launch',
|
136
148
|
'wfid' => wfid,
|
data/lib/ruote/storage/base.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -55,19 +55,12 @@ module Ruote
|
|
55
55
|
delete(doc).nil?
|
56
56
|
end
|
57
57
|
|
58
|
-
# A helper for the #worker method, it returns that dummy worker
|
59
|
-
# when there is no reference to the calling worker in the current
|
60
|
-
# thread's local variables.
|
61
|
-
#
|
62
|
-
DUMMY_WORKER = OpenStruct.new(
|
63
|
-
:name => 'worker', :identity => 'unknown', :state => 'running')
|
64
|
-
|
65
58
|
# Warning, this is not equivalent to doing @context.worker, this method
|
66
59
|
# fetches the worker from the local thread variables.
|
67
60
|
#
|
68
61
|
def worker
|
69
62
|
|
70
|
-
|
63
|
+
Ruote.current_worker
|
71
64
|
end
|
72
65
|
|
73
66
|
#--
|
@@ -164,7 +157,10 @@ module Ruote
|
|
164
157
|
# trackers
|
165
158
|
#++
|
166
159
|
|
167
|
-
|
160
|
+
# Some storage implementation might need the wfid information when
|
161
|
+
# adding or removing trackers.
|
162
|
+
#
|
163
|
+
def get_trackers(wfid=nil)
|
168
164
|
|
169
165
|
get('variables', 'trackers') ||
|
170
166
|
{ '_id' => 'trackers', 'type' => 'variables', 'trackers' => {} }
|
@@ -341,7 +337,7 @@ module Ruote
|
|
341
337
|
|
342
338
|
at = if s.is_a?(Time) # at or every
|
343
339
|
s
|
344
|
-
elsif Ruote.
|
340
|
+
elsif Ruote.cron_string?(s) # cron
|
345
341
|
Rufus::CronLine.new(s).next_time(Time.now + 1)
|
346
342
|
else # at or every
|
347
343
|
Ruote.s_to_at(s)
|
@@ -400,9 +396,7 @@ module Ruote
|
|
400
396
|
end
|
401
397
|
end
|
402
398
|
|
403
|
-
#
|
404
|
-
#
|
405
|
-
# TODO: remove me at some point
|
399
|
+
# Used by ruote-couch and ruote-asw
|
406
400
|
#
|
407
401
|
def self.key_match?(keys, doc)
|
408
402
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -77,6 +77,7 @@ module Ruote
|
|
77
77
|
|
78
78
|
doc['put_at'] = Ruote.now_to_utc_s
|
79
79
|
doc['_rev'] = doc['_rev'] + 1
|
80
|
+
doc = Ruote.keys_to_s(doc)
|
80
81
|
|
81
82
|
@h[doc['type']][doc['_id']] = Rufus::Json.dup(doc)
|
82
83
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -41,22 +41,24 @@ module Ruote
|
|
41
41
|
|
42
42
|
def handle(msg)
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
when 'dispatch_pause', 'dispatch_resume' then dispatch_pause(msg)
|
48
|
-
else # simply discard the message
|
49
|
-
end
|
44
|
+
return unless msg['action'].match(/^dispatch/)
|
45
|
+
|
46
|
+
send(msg['action'], msg)
|
50
47
|
end
|
51
48
|
|
52
49
|
protected
|
53
50
|
|
51
|
+
# Dispatching the msg.
|
52
|
+
#
|
54
53
|
def dispatch(msg)
|
55
54
|
|
56
55
|
participant = @context.plist.lookup(
|
57
56
|
msg['participant'] || msg['participant_name'], msg['workitem'])
|
58
57
|
|
59
|
-
if
|
58
|
+
if
|
59
|
+
@context['participant_threads_enabled'] == false ||
|
60
|
+
do_not_thread?(participant, msg)
|
61
|
+
then
|
60
62
|
do_dispatch(participant, msg)
|
61
63
|
else
|
62
64
|
do_threaded_dispatch(participant, msg)
|
@@ -65,7 +67,10 @@ module Ruote
|
|
65
67
|
|
66
68
|
# The actual dispatching (call to Participant#consume or #on_workitem).
|
67
69
|
#
|
68
|
-
|
70
|
+
# No error rescuing so it might be interesting for some extension
|
71
|
+
# classes (like in ruote-swf).
|
72
|
+
#
|
73
|
+
def do_raw_dispatch(participant, msg)
|
69
74
|
|
70
75
|
workitem = Ruote::Workitem.new(msg['workitem'])
|
71
76
|
|
@@ -83,6 +88,16 @@ module Ruote
|
|
83
88
|
# participant expression as 'dispatched'
|
84
89
|
end
|
85
90
|
|
91
|
+
# The raw dispatch work, wrapped in error handling.
|
92
|
+
#
|
93
|
+
def do_dispatch(participant, msg)
|
94
|
+
|
95
|
+
do_raw_dispatch(participant, msg)
|
96
|
+
|
97
|
+
rescue => err
|
98
|
+
@context.error_handler.msg_handle(msg, err)
|
99
|
+
end
|
100
|
+
|
86
101
|
# Wraps the call to do_dispatch in a thread.
|
87
102
|
#
|
88
103
|
def do_threaded_dispatch(participant, msg)
|
@@ -97,15 +112,7 @@ module Ruote
|
|
97
112
|
# would be OK.
|
98
113
|
# Or maybe it's the job of an extension / subclass
|
99
114
|
|
100
|
-
Thread.new
|
101
|
-
begin
|
102
|
-
|
103
|
-
do_dispatch(participant, msg)
|
104
|
-
|
105
|
-
rescue => exception
|
106
|
-
@context.error_handler.msg_handle(msg, exception)
|
107
|
-
end
|
108
|
-
end
|
115
|
+
Thread.new { do_dispatch(participant, msg) }
|
109
116
|
end
|
110
117
|
|
111
118
|
# Returns true if the participant doesn't want the #consume to happen
|
@@ -165,6 +172,10 @@ module Ruote
|
|
165
172
|
action,
|
166
173
|
'fei' => Ruote::FlowExpressionId.new(msg['fei']), :default => false)
|
167
174
|
end
|
175
|
+
|
176
|
+
# Route to dispatch_pause which handles both pause and resume.
|
177
|
+
#
|
178
|
+
alias dispatch_resume dispatch_pause
|
168
179
|
end
|
169
180
|
|
170
181
|
# Given a participant, a method name or an array of method names and
|
data/lib/ruote/svc/dollar_sub.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|
@@ -91,20 +91,17 @@ module Ruote
|
|
91
91
|
#
|
92
92
|
def literal_sub(s, fexp, wi)
|
93
93
|
|
94
|
-
|
95
|
-
when /^\$(
|
96
|
-
Ruote.lookup(wi['fields'], $~[1])
|
97
|
-
when /^\$(?:variable|var|v):([^{}]+)$/
|
94
|
+
case s
|
95
|
+
when /^\$(?:variable|var|v):([^{}\s\$]+)$/
|
98
96
|
fexp.lookup_variable($~[1])
|
97
|
+
when /^\$([^{}:\s\$]+)$/, /^\$(?:field|fld|f):([^{}\s\$]+)$/
|
98
|
+
Ruote.lookup(wi['fields'], $~[1])
|
99
99
|
else
|
100
100
|
s
|
101
101
|
end
|
102
|
-
|
103
|
-
result.nil? ? s : result
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
|
-
|
108
105
|
#
|
109
106
|
# A mini-namespace Ruote::Dollar for Dict and RubyContext, just to separate
|
110
107
|
# them from the rest of Ruote.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2013, 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
|