ruote 2.1.11 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. data/CHANGELOG.txt +60 -0
  2. data/CREDITS.txt +22 -4
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +6 -7
  5. data/Rakefile +58 -59
  6. data/TODO.txt +137 -65
  7. data/couch_url.txt +1 -0
  8. data/jruby_issue.txt +32 -0
  9. data/lib/ruote.rb +1 -1
  10. data/lib/ruote/context.rb +12 -10
  11. data/lib/ruote/engine.rb +280 -145
  12. data/lib/ruote/engine/process_error.rb +5 -5
  13. data/lib/ruote/engine/process_status.rb +47 -28
  14. data/lib/ruote/exp/command.rb +7 -10
  15. data/lib/ruote/exp/commanded.rb +2 -2
  16. data/lib/ruote/exp/condition.rb +130 -43
  17. data/lib/ruote/exp/fe_add_branches.rb +2 -2
  18. data/lib/ruote/exp/fe_apply.rb +1 -1
  19. data/lib/ruote/exp/fe_cancel_process.rb +3 -3
  20. data/lib/ruote/exp/fe_command.rb +3 -3
  21. data/lib/ruote/exp/fe_concurrence.rb +4 -4
  22. data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
  23. data/lib/ruote/exp/fe_cron.rb +3 -3
  24. data/lib/ruote/exp/fe_cursor.rb +5 -5
  25. data/lib/ruote/exp/fe_define.rb +3 -3
  26. data/lib/ruote/exp/fe_echo.rb +3 -3
  27. data/lib/ruote/exp/fe_equals.rb +2 -2
  28. data/lib/ruote/exp/fe_error.rb +2 -2
  29. data/lib/ruote/exp/fe_filter.rb +519 -0
  30. data/lib/ruote/exp/fe_forget.rb +9 -2
  31. data/lib/ruote/exp/fe_given.rb +154 -0
  32. data/lib/ruote/exp/fe_if.rb +16 -13
  33. data/lib/ruote/exp/fe_inc.rb +3 -3
  34. data/lib/ruote/exp/fe_iterator.rb +4 -4
  35. data/lib/ruote/exp/fe_let.rb +75 -0
  36. data/lib/ruote/exp/fe_listen.rb +68 -12
  37. data/lib/ruote/exp/fe_lose.rb +110 -0
  38. data/lib/ruote/exp/fe_noop.rb +1 -1
  39. data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
  40. data/lib/ruote/exp/fe_participant.rb +14 -17
  41. data/lib/ruote/exp/fe_redo.rb +10 -6
  42. data/lib/ruote/exp/fe_ref.rb +1 -1
  43. data/lib/ruote/exp/fe_registerp.rb +112 -0
  44. data/lib/ruote/exp/fe_reserve.rb +3 -3
  45. data/lib/ruote/exp/fe_restore.rb +2 -2
  46. data/lib/ruote/exp/fe_save.rb +2 -2
  47. data/lib/ruote/exp/fe_sequence.rb +3 -4
  48. data/lib/ruote/exp/fe_set.rb +16 -7
  49. data/lib/ruote/exp/fe_subprocess.rb +23 -1
  50. data/lib/ruote/exp/fe_that.rb +92 -0
  51. data/lib/ruote/exp/fe_undo.rb +3 -3
  52. data/lib/ruote/exp/fe_unregisterp.rb +71 -0
  53. data/lib/ruote/exp/fe_wait.rb +2 -2
  54. data/lib/ruote/exp/flowexpression.rb +153 -78
  55. data/lib/ruote/exp/iterator.rb +2 -2
  56. data/lib/ruote/exp/merge.rb +2 -2
  57. data/lib/ruote/exp/ro_attributes.rb +14 -12
  58. data/lib/ruote/exp/ro_filters.rb +136 -0
  59. data/lib/ruote/exp/ro_persist.rb +51 -35
  60. data/lib/ruote/exp/ro_variables.rb +18 -27
  61. data/lib/ruote/fei.rb +73 -33
  62. data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
  63. data/lib/ruote/id/wfid_generator.rb +11 -4
  64. data/lib/ruote/log/default_history.rb +122 -0
  65. data/lib/ruote/log/pretty.rb +36 -8
  66. data/lib/ruote/log/storage_history.rb +37 -5
  67. data/lib/ruote/log/test_logger.rb +26 -24
  68. data/lib/ruote/log/wait_logger.rb +5 -3
  69. data/lib/ruote/part/block_participant.rb +22 -11
  70. data/lib/ruote/part/engine_participant.rb +6 -7
  71. data/lib/ruote/part/local_participant.rb +6 -12
  72. data/lib/ruote/part/no_op_participant.rb +4 -4
  73. data/lib/ruote/part/null_participant.rb +4 -4
  74. data/lib/ruote/part/smtp_participant.rb +4 -4
  75. data/lib/ruote/part/storage_participant.rb +40 -20
  76. data/lib/ruote/part/template.rb +4 -4
  77. data/lib/ruote/participant.rb +0 -1
  78. data/lib/ruote/{parser.rb → reader.rb} +30 -25
  79. data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
  80. data/lib/ruote/{parser → reader}/xml.rb +6 -5
  81. data/lib/ruote/receiver/base.rb +35 -13
  82. data/lib/ruote/storage/base.rb +20 -18
  83. data/lib/ruote/storage/composite_storage.rb +10 -10
  84. data/lib/ruote/storage/fs_storage.rb +17 -10
  85. data/lib/ruote/storage/hash_storage.rb +29 -18
  86. data/lib/ruote/svc/dispatch_pool.rb +41 -14
  87. data/lib/ruote/svc/dollar_sub.rb +50 -17
  88. data/lib/ruote/svc/error_handler.rb +19 -11
  89. data/lib/ruote/svc/expression_map.rb +4 -4
  90. data/lib/ruote/svc/participant_list.rb +105 -100
  91. data/lib/ruote/svc/tracker.rb +58 -18
  92. data/lib/ruote/svc/treechecker.rb +51 -24
  93. data/lib/ruote/tree_dot.rb +4 -4
  94. data/lib/ruote/util/filter.rb +440 -0
  95. data/lib/ruote/util/hashdot.rb +4 -4
  96. data/lib/ruote/util/look.rb +2 -6
  97. data/lib/ruote/util/lookup.rb +9 -7
  98. data/lib/ruote/util/misc.rb +40 -8
  99. data/lib/ruote/util/ometa.rb +1 -1
  100. data/lib/ruote/util/serializer.rb +4 -4
  101. data/lib/ruote/util/subprocess.rb +29 -9
  102. data/lib/ruote/util/time.rb +4 -4
  103. data/lib/ruote/util/tree.rb +3 -3
  104. data/lib/ruote/version.rb +2 -2
  105. data/lib/ruote/worker.rb +55 -32
  106. data/lib/ruote/workitem.rb +64 -11
  107. data/ruote.gemspec +31 -302
  108. data/test/bm/launch_bench.rb +37 -0
  109. data/test/functional/base.rb +60 -18
  110. data/test/functional/concurrent_base.rb +2 -2
  111. data/test/functional/ct_0_concurrence.rb +1 -1
  112. data/test/functional/ct_1_iterator.rb +1 -1
  113. data/test/functional/ct_2_cancel.rb +1 -1
  114. data/test/functional/eft_0_process_definition.rb +2 -2
  115. data/test/functional/eft_10_cancel_process.rb +1 -1
  116. data/test/functional/eft_11_wait.rb +19 -11
  117. data/test/functional/eft_12_listen.rb +79 -13
  118. data/test/functional/eft_13_iterator.rb +13 -10
  119. data/test/functional/eft_14_cursor.rb +98 -9
  120. data/test/functional/eft_15_loop.rb +6 -4
  121. data/test/functional/eft_16_if.rb +12 -0
  122. data/test/functional/eft_18_concurrent_iterator.rb +31 -32
  123. data/test/functional/eft_19_reserve.rb +4 -4
  124. data/test/functional/eft_1_echo.rb +9 -0
  125. data/test/functional/eft_20_save.rb +4 -4
  126. data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
  127. data/test/functional/eft_30_ref.rb +17 -2
  128. data/test/functional/eft_31_registerp.rb +130 -0
  129. data/test/functional/eft_32_lose.rb +93 -0
  130. data/test/functional/eft_33_let.rb +31 -0
  131. data/test/functional/eft_34_given.rb +123 -0
  132. data/test/functional/eft_35_filter.rb +269 -0
  133. data/test/functional/eft_3_participant.rb +4 -6
  134. data/test/functional/eft_4_set.rb +16 -2
  135. data/test/functional/eft_5_subprocess.rb +2 -4
  136. data/test/functional/eft_6_concurrence.rb +29 -29
  137. data/test/functional/eft_8_undo.rb +39 -3
  138. data/test/functional/eft_9_redo.rb +94 -2
  139. data/test/functional/ft_10_dollar.rb +81 -2
  140. data/test/functional/ft_11_recursion.rb +13 -17
  141. data/test/functional/ft_12_launchitem.rb +9 -5
  142. data/test/functional/ft_13_variables.rb +7 -9
  143. data/test/functional/ft_14_re_apply.rb +6 -9
  144. data/test/functional/ft_15_timeout.rb +18 -18
  145. data/test/functional/ft_16_participant_params.rb +1 -3
  146. data/test/functional/ft_17_conditional.rb +25 -2
  147. data/test/functional/ft_18_kill.rb +65 -12
  148. data/test/functional/ft_1_process_status.rb +147 -71
  149. data/test/functional/ft_20_storage_participant.rb +0 -1
  150. data/test/functional/ft_21_forget.rb +82 -1
  151. data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
  152. data/test/functional/ft_25_receiver.rb +47 -17
  153. data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
  154. data/test/functional/ft_29_part_template.rb +6 -5
  155. data/test/functional/ft_2_errors.rb +21 -37
  156. data/test/functional/ft_30_smtp_participant.rb +1 -1
  157. data/test/functional/ft_31_part_blocking.rb +8 -6
  158. data/test/functional/ft_34_cursor_rewind.rb +13 -10
  159. data/test/functional/ft_35_add_service.rb +1 -1
  160. data/test/functional/ft_36_storage_history.rb +24 -1
  161. data/test/functional/ft_37_default_history.rb +109 -0
  162. data/test/functional/ft_38_participant_more.rb +10 -10
  163. data/test/functional/ft_39_wait_for.rb +12 -9
  164. data/test/functional/ft_3_participant_registration.rb +111 -32
  165. data/test/functional/ft_40_wait_logger.rb +2 -1
  166. data/test/functional/ft_41_participants.rb +30 -4
  167. data/test/functional/ft_43_participant_on_reply.rb +6 -23
  168. data/test/functional/ft_45_participant_accept.rb +4 -4
  169. data/test/functional/ft_46_launch_single.rb +36 -2
  170. data/test/functional/ft_47_wfid_generator.rb +54 -0
  171. data/test/functional/ft_48_lose.rb +112 -0
  172. data/test/functional/ft_49_engine_on_error.rb +201 -0
  173. data/test/functional/ft_4_cancel.rb +66 -6
  174. data/test/functional/ft_50_engine_config.rb +22 -0
  175. data/test/functional/ft_51_misc.rb +67 -0
  176. data/test/functional/ft_52_case.rb +134 -0
  177. data/test/functional/ft_53_engine_on_terminate.rb +95 -0
  178. data/test/functional/ft_54_patterns.rb +104 -0
  179. data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
  180. data/test/functional/ft_56_filter_attribute.rb +259 -0
  181. data/test/functional/ft_5_on_error.rb +77 -30
  182. data/test/functional/ft_6_on_cancel.rb +66 -11
  183. data/test/functional/ft_7_tags.rb +94 -5
  184. data/test/functional/ft_8_participant_consumption.rb +36 -5
  185. data/test/functional/ft_9_subprocesses.rb +10 -10
  186. data/test/functional/rt_1_listen.rb +3 -3
  187. data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
  188. data/test/functional/storage_helper.rb +15 -13
  189. data/test/functional/test.rb +1 -3
  190. data/test/test_helper.rb +0 -8
  191. data/test/unit/storage.rb +154 -10
  192. data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
  193. data/test/unit/ut_11_lookup.rb +7 -0
  194. data/test/unit/ut_13_serializer.rb +1 -1
  195. data/test/unit/ut_15_util.rb +23 -0
  196. data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
  197. data/test/unit/ut_1_fei.rb +57 -10
  198. data/test/unit/ut_20_composite_storage.rb +25 -11
  199. data/test/unit/ut_21_participant_list.rb +47 -0
  200. data/test/unit/ut_22_filter.rb +903 -0
  201. data/test/unit/ut_3_wait_logger.rb +2 -6
  202. data/test/unit/ut_6_condition.rb +164 -17
  203. data/test/unit/ut_7_workitem.rb +28 -0
  204. data/test/unit/ut_8_tree_to_dot.rb +1 -1
  205. data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
  206. metadata +108 -84
  207. data/.gitignore +0 -4
  208. data/examples/barley.rb +0 -391
  209. data/examples/flickr_report.rb +0 -107
  210. data/examples/pong.rb +0 -37
  211. data/examples/ruote_quickstart.rb +0 -43
  212. data/examples/web_first_page.rb +0 -68
  213. data/lib/ruote/part/hash_participant.rb +0 -91
  214. data/test/README.rdoc +0 -15
  215. data/test/functional/crunner.sh +0 -19
  216. data/test/pdef.xml +0 -7
  217. data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
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
@@ -31,16 +31,16 @@ module Ruote
31
31
  #
32
32
  # Turns an XML string into a process definition tree.
33
33
  #
34
- module XmlParser
34
+ module XmlReader
35
35
 
36
36
  #
37
- # A helper class to store the temporary tree while it gets parsed.
37
+ # A helper class to store the temporary tree while it gets read.
38
38
  #
39
39
  class Node
40
40
 
41
41
  attr_reader :parent, :attributes, :children
42
42
 
43
- def initialize (parent, name, attributes)
43
+ def initialize(parent, name, attributes)
44
44
 
45
45
  @parent = parent
46
46
  @name = name
@@ -54,6 +54,7 @@ module Ruote
54
54
  end
55
55
 
56
56
  def to_a
57
+
57
58
  [ @name, @attributes, @children.collect { |c| c.to_a } ]
58
59
  end
59
60
  end
@@ -61,7 +62,7 @@ module Ruote
61
62
  #
62
63
  # Parses the XML string into a process definition tree (array of arrays).
63
64
  #
64
- def self.parse (s)
65
+ def self.read(s)
65
66
 
66
67
  parser = REXML::Parsers::SAX2Parser.new(s)
67
68
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
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
@@ -37,7 +37,7 @@ module Ruote
37
37
  # This method pipes back a workitem into the engine, letting it resume
38
38
  # in its flow, hopefully.
39
39
  #
40
- def receive (workitem)
40
+ def receive(workitem)
41
41
 
42
42
  workitem = workitem.to_h if workitem.respond_to?(:to_h)
43
43
 
@@ -57,20 +57,20 @@ module Ruote
57
57
  #
58
58
  # process_definition must be a result of Ruote.process_definition call
59
59
  # or XML or JSON serialized process definition, as accepted by
60
- # Ruote::Parser#parse.
60
+ # Ruote::Reader#read.
61
61
  #
62
62
  # fields are workflow parameters that will be placed in workitem.fields.
63
63
  #
64
64
  # variables contain engine variables.
65
65
  #
66
- def launch (process_definition, fields={}, variables={})
66
+ def launch(process_definition, fields={}, variables={})
67
67
 
68
68
  wfid = @context.wfidgen.generate
69
69
 
70
70
  @context.storage.put_msg(
71
71
  'launch',
72
72
  'wfid' => wfid,
73
- 'tree' => @context.parser.parse(process_definition),
73
+ 'tree' => @context.reader.read(process_definition),
74
74
  'workitem' => { 'fields' => fields },
75
75
  'variables' => variables)
76
76
 
@@ -82,9 +82,9 @@ module Ruote
82
82
  # Not aliasing so that if someone changes the receive implementation,
83
83
  # reply is affected as well.
84
84
  #
85
- def reply (workitem)
85
+ def reply(workitem)
86
86
 
87
- receive (workitem)
87
+ receive(workitem)
88
88
  end
89
89
 
90
90
  # Wraps a call to receive(workitem)
@@ -92,9 +92,9 @@ module Ruote
92
92
  # Not aliasing so that if someone changes the receive implementation,
93
93
  # reply_to_engine is affected as well.
94
94
  #
95
- def reply_to_engine (workitem)
95
+ def reply_to_engine(workitem)
96
96
 
97
- receive (workitem)
97
+ receive(workitem)
98
98
  end
99
99
 
100
100
  # A receiver signs a workitem when it comes back.
@@ -109,7 +109,7 @@ module Ruote
109
109
  # Convenience method, given a workitem or a fei, returns the
110
110
  # corresponding flow expession.
111
111
  #
112
- def fetch_flow_expression (workitem_or_fei)
112
+ def fetch_flow_expression(workitem_or_fei)
113
113
 
114
114
  Ruote::Exp::FlowExpression.fetch(
115
115
  @context,
@@ -124,6 +124,28 @@ module Ruote
124
124
  #
125
125
  alias fexp fetch_flow_expression
126
126
 
127
+ # A convenience methods for advanced users (like Oleg).
128
+ #
129
+ # Given a fei (flow expression id), fetches the workitem as stored in
130
+ # the expression with that fei.
131
+ # This is the "applied workitem", if the workitem is currently handed to
132
+ # a participant, this method will return the workitem as applied, not
133
+ # the workitem as saved by the participant/user in whatever worklist it
134
+ # uses. If you need that workitem, do the vanilla thing and ask it to
135
+ # the [storage] participant or its worklist.
136
+ #
137
+ # The fei might be a string fei (result of fei.to_storage_id), a
138
+ # FlowExpressionId instance or a hash.
139
+ #
140
+ # on_terminate processes are not triggered for on_error processes.
141
+ # on_error processes are triggered for on_terminate processes as well.
142
+ #
143
+ def applied_workitem(fei)
144
+
145
+ Ruote::Workitem.new(fexp(fei).h.applied_workitem)
146
+ end
147
+ alias workitem applied_workitem
148
+
127
149
  protected
128
150
 
129
151
  # Stashes values in the participant expression (in the storage).
@@ -139,7 +161,7 @@ module Ruote
139
161
  # http://groups.google.com/group/openwferu-users/t/2e6a95708c10847b for the
140
162
  # justification.
141
163
  #
142
- def put (fei, hash)
164
+ def put(fei, hash)
143
165
 
144
166
  fexp = Ruote::Exp::FlowExpression.fetch(@context, fei.to_h)
145
167
 
@@ -161,7 +183,7 @@ module Ruote
161
183
  # put & get are useful for a participant that needs to communicate
162
184
  # between its consume and its cancel.
163
185
  #
164
- def get (fei, key=nil)
186
+ def get(fei, key=nil)
165
187
 
166
188
  fexp = Ruote::Exp::FlowExpression.fetch(@context, fei.to_h)
167
189
 
@@ -180,7 +202,7 @@ module Ruote
180
202
 
181
203
  # Accepts context, worker, engine or storage as first argument.
182
204
  #
183
- def initialize (cwes, options={})
205
+ def initialize(cwes, options={})
184
206
 
185
207
  @context = cwes.context
186
208
  @options = options
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
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
@@ -37,7 +37,7 @@ module Ruote
37
37
  @context ||= Ruote::Context.new(self)
38
38
  end
39
39
 
40
- def context= (c)
40
+ def context=(c)
41
41
 
42
42
  @context = c
43
43
  end
@@ -45,7 +45,7 @@ module Ruote
45
45
  # Attempts to delete a document, returns true if the deletion
46
46
  # succeeded. This is used with msgs to reserve work on them.
47
47
  #
48
- def reserve (doc)
48
+ def reserve(doc)
49
49
 
50
50
  delete(doc).nil?
51
51
  end
@@ -54,7 +54,7 @@ module Ruote
54
54
  # configurations
55
55
  #++
56
56
 
57
- def get_configuration (key)
57
+ def get_configuration(key)
58
58
 
59
59
  get('configurations', key)
60
60
  end
@@ -63,7 +63,7 @@ module Ruote
63
63
  # messages
64
64
  #++
65
65
 
66
- def put_msg (action, options)
66
+ def put_msg(action, options)
67
67
 
68
68
  msg = prepare_msg_doc(action, options)
69
69
 
@@ -93,7 +93,7 @@ module Ruote
93
93
  }
94
94
  end
95
95
 
96
- def empty? (type)
96
+ def empty?(type)
97
97
 
98
98
  (get_many(type, nil, :count => true) == 0)
99
99
  end
@@ -102,7 +102,7 @@ module Ruote
102
102
  # expressions
103
103
  #++
104
104
 
105
- def find_root_expression (wfid)
105
+ def find_root_expression(wfid)
106
106
 
107
107
  get_many('expressions', wfid).sort_by { |fexp|
108
108
  fexp['fei']['expid']
@@ -120,7 +120,7 @@ module Ruote
120
120
  # come up with different implementations (think CouchDB, which could
121
121
  # provide a view for it).
122
122
  #
123
- def expression_wfids (opts)
123
+ def expression_wfids(opts)
124
124
 
125
125
  wfids = ids('expressions').collect { |fei| fei.split('!').last }.uniq.sort
126
126
 
@@ -146,7 +146,7 @@ module Ruote
146
146
  # ats and crons
147
147
  #++
148
148
 
149
- def get_schedules (delta, now)
149
+ def get_schedules(delta, now)
150
150
 
151
151
  # TODO : bring that 'optimization' back in,
152
152
  # maybe every minute, if min != last_min ...
@@ -169,7 +169,7 @@ module Ruote
169
169
  # Places schedule in storage. Returns the id of the 'schedule' document.
170
170
  # If the schedule got triggered immediately, nil is returned.
171
171
  #
172
- def put_schedule (flavour, owner_fei, s, msg)
172
+ def put_schedule(flavour, owner_fei, s, msg)
173
173
 
174
174
  doc = prepare_schedule_doc(flavour, owner_fei, s, msg)
175
175
 
@@ -182,7 +182,9 @@ module Ruote
182
182
  doc['_id']
183
183
  end
184
184
 
185
- def delete_schedule (schedule_id)
185
+ def delete_schedule(schedule_id)
186
+
187
+ return if schedule_id.nil?
186
188
 
187
189
  s = get('schedules', schedule_id)
188
190
  delete(s) if s
@@ -192,12 +194,12 @@ module Ruote
192
194
  # engine variables
193
195
  #++
194
196
 
195
- def get_engine_variable (k)
197
+ def get_engine_variable(k)
196
198
 
197
199
  get_engine_variables['variables'][k]
198
200
  end
199
201
 
200
- def put_engine_variable (k, v)
202
+ def put_engine_variable(k, v)
201
203
 
202
204
  vars = get_engine_variables
203
205
  vars['variables'][k] = v
@@ -213,7 +215,7 @@ module Ruote
213
215
  #
214
216
  # Of course, the target storage may be a different implementation.
215
217
  #
216
- def copy_to (target, opts={})
218
+ def copy_to(target, opts={})
217
219
 
218
220
  counter = 0
219
221
 
@@ -252,7 +254,7 @@ module Ruote
252
254
 
253
255
  # Used by put_msg
254
256
  #
255
- def prepare_msg_doc (action, options)
257
+ def prepare_msg_doc(action, options)
256
258
 
257
259
  # merge! is way faster than merge (no object creation probably)
258
260
 
@@ -275,7 +277,7 @@ module Ruote
275
277
 
276
278
  # Used by put_schedule
277
279
  #
278
- def prepare_schedule_doc (flavour, owner_fei, s, msg)
280
+ def prepare_schedule_doc(flavour, owner_fei, s, msg)
279
281
 
280
282
  at = if s.is_a?(Time) # at or every
281
283
  s
@@ -313,7 +315,7 @@ module Ruote
313
315
 
314
316
  # Returns all the ats whose due date arrived (now or earlier)
315
317
  #
316
- def filter_schedules (schedules, now)
318
+ def filter_schedules(schedules, now)
317
319
 
318
320
  now = Ruote.time_to_utc_s(now)
319
321
 
@@ -333,7 +335,7 @@ module Ruote
333
335
  # It's a class method meant to be used by the various storage
334
336
  # implementations.
335
337
  #
336
- def self.key_match? (keys, doc)
338
+ def self.key_match?(keys, doc)
337
339
 
338
340
  _id = doc.is_a?(Hash) ? doc['_id'] : doc
339
341
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
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
@@ -47,7 +47,7 @@ module Ruote
47
47
 
48
48
  include StorageBase
49
49
 
50
- def initialize (default_storage, storages)
50
+ def initialize(default_storage, storages)
51
51
 
52
52
  @default_storage = default_storage
53
53
  @storages = storages
@@ -55,27 +55,27 @@ module Ruote
55
55
  prepare_base_methods
56
56
  end
57
57
 
58
- def put (doc, opts={})
58
+ def put(doc, opts={})
59
59
 
60
60
  storage(doc['type']).put(doc, opts)
61
61
  end
62
62
 
63
- def get (type, key)
63
+ def get(type, key)
64
64
 
65
65
  storage(type).get(type, key)
66
66
  end
67
67
 
68
- def delete (doc)
68
+ def delete(doc)
69
69
 
70
- storage(type).delete(doc)
70
+ storage(doc['type']).delete(doc)
71
71
  end
72
72
 
73
- def get_many (type, key=nil, opts={})
73
+ def get_many(type, key=nil, opts={})
74
74
 
75
75
  storage(type).get_many(type, key, opts)
76
76
  end
77
77
 
78
- def ids (type)
78
+ def ids(type)
79
79
 
80
80
  storage(type).ids(type)
81
81
  end
@@ -85,7 +85,7 @@ module Ruote
85
85
  TYPES.collect { |t| storage(t) }.uniq.each { |s| s.purge! }
86
86
  end
87
87
 
88
- def purge_type! (type)
88
+ def purge_type!(type)
89
89
 
90
90
  storage(type).purge_type!(type)
91
91
  end
@@ -125,7 +125,7 @@ module Ruote
125
125
  end
126
126
  end
127
127
 
128
- def storage (type)
128
+ def storage(type)
129
129
 
130
130
  @storages[type] || @default_storage
131
131
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
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
@@ -57,7 +57,7 @@ module Ruote
57
57
  # The options are classical engine configuration, but the 'cloche_nolock'
58
58
  # option is read by the storage and followed.
59
59
  #
60
- def initialize (dir, options={})
60
+ def initialize(dir, options={})
61
61
 
62
62
  FileUtils.mkdir_p(dir)
63
63
 
@@ -69,22 +69,22 @@ module Ruote
69
69
  @cloche.put(@options.merge('type' => 'configurations', '_id' => 'engine'))
70
70
  end
71
71
 
72
- def put (doc, opts={})
72
+ def put(doc, opts={})
73
73
 
74
74
  @cloche.put(doc.merge!('put_at' => Ruote.now_to_utc_s), opts)
75
75
  end
76
76
 
77
- def get (type, key)
77
+ def get(type, key)
78
78
 
79
79
  @cloche.get(type, key)
80
80
  end
81
81
 
82
- def delete (doc)
82
+ def delete(doc)
83
83
 
84
84
  @cloche.delete(doc)
85
85
  end
86
86
 
87
- def get_many (type, key=nil, opts={})
87
+ def get_many(type, key=nil, opts={})
88
88
 
89
89
  if key
90
90
  key = Array(key)
@@ -95,7 +95,7 @@ module Ruote
95
95
  @cloche.get_many(type, key, opts)
96
96
  end
97
97
 
98
- def ids (type)
98
+ def ids(type)
99
99
 
100
100
  @cloche.ids(type)
101
101
  end
@@ -109,15 +109,15 @@ module Ruote
109
109
 
110
110
  # No need for that here (FsStorage adds type on the fly).
111
111
  #
112
- def add_type (type)
112
+ def add_type(type)
113
113
  end
114
114
 
115
- def purge_type! (type)
115
+ def purge_type!(type)
116
116
 
117
117
  @cloche.purge_type!(type)
118
118
  end
119
119
 
120
- def dump (type)
120
+ def dump(type)
121
121
 
122
122
  s = "=== #{type} ===\n"
123
123
 
@@ -128,6 +128,13 @@ module Ruote
128
128
  end
129
129
  end
130
130
  end
131
+
132
+ # Shuts this storage down.
133
+ #
134
+ def shutdown
135
+
136
+ # nothing to do
137
+ end
131
138
  end
132
139
  end
133
140