openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -59,6 +59,10 @@ module OpenWFE
59
59
  return wiTarget unless wiSource
60
60
 
61
61
  return wiSource if override
62
+
63
+ #puts "merge()"
64
+ #puts "merge() source : " + wiSource.attributes.inspect
65
+ #puts "merge() target : " + wiTarget.attributes.inspect
62
66
 
63
67
  wiSource.attributes.each do |k, v|
64
68
 
@@ -69,6 +73,8 @@ module OpenWFE
69
73
 
70
74
  wiTarget.attributes[nk] = nv
71
75
  end
76
+
77
+ #puts "merge() target after : " + wiTarget.attributes.inspect
72
78
 
73
79
  wiTarget
74
80
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -45,32 +45,50 @@ require 'openwfe/rudefinitions'
45
45
  module OpenWFE
46
46
 
47
47
  #
48
- # An 'abstract' class storing bits (trees) of process definitions just
48
+ # A class storing bits (trees) of process definitions just
49
49
  # parsed. Upon application (apply()) these raw expressions get turned
50
50
  # into real expressions.
51
- # The first and classical extension of this class is XmlRawExpression.
52
51
  #
53
52
  class RawExpression < FlowExpression
54
53
 
55
- def initialize (
56
- fei, parent_id, env_id, application_context, raw_representation)
57
54
 
58
- super(fei, parent_id, env_id, application_context, nil)
55
+ def self.new_raw (
56
+ fei, parent_id, env_id, app_context, raw_representation)
59
57
 
60
- #linfo { "initialize() '#{fei.expression_name}'" }
58
+ re = self.new
61
59
 
62
- @raw_representation = raw_representation
60
+ re.fei = fei
61
+ re.parent_id = parent_id
62
+ re.environment_id = env_id
63
+ re.application_context = app_context
64
+ re.attributes = nil
65
+ re.children = []
66
+ re.apply_time = nil
63
67
 
64
- #new_environment() if not @environment_id
65
- #
66
- # now done in the launch methods of the expression pool
68
+ re.raw_representation = raw_representation
69
+ re
67
70
  end
68
71
 
72
+ #--
73
+ # a duplication method that duplicates everything, except
74
+ # the application context
75
+ #
76
+ #def dup
77
+ # self.class.new_raw(
78
+ # @fei.dup,
79
+ # @parent_id ? @parent_id.dup : nil,
80
+ # @environment_id ? @environment_id.dup : nil,
81
+ # @application_context,
82
+ # raw_representation)
83
+ #end
84
+ #alias :fulldup :dup
85
+ #++
86
+
69
87
  def instantiate_real_expression (
70
88
  workitem, exp_name=nil, exp_class=nil, attributes=nil)
71
89
 
72
- exp_name = expression_name() unless exp_name
73
- exp_class = expression_class() unless exp_class
90
+ exp_name ||= expression_name
91
+ exp_class ||= expression_class
74
92
 
75
93
  raise "unknown expression '#{exp_name}'" \
76
94
  unless exp_class
@@ -79,22 +97,27 @@ module OpenWFE
79
97
  # "instantiate_real_expression() exp_class is #{exp_class}"
80
98
  #end
81
99
 
82
- attributes = extract_attributes() unless attributes
100
+ attributes ||= raw_representation[1]
83
101
 
84
- expression = exp_class.new(
85
- @fei,
86
- @parent_id,
87
- @environment_id,
88
- @application_context,
89
- attributes)
102
+ exp = exp_class.new
103
+ exp.fei = @fei
104
+ exp.parent_id = @parent_id
105
+ exp.environment_id = @environment_id
106
+ exp.application_context = @application_context
107
+ exp.attributes = attributes
90
108
 
91
- consider_tag(workitem, expression)
109
+ exp.raw_representation = raw_representation
110
+ #
111
+ # keeping track of how the expression look at apply /
112
+ # instantiation time
113
+
114
+ consider_tag workitem, exp
92
115
 
93
- handle_descriptions()
116
+ handle_descriptions
94
117
 
95
- expression.children = extract_children()
118
+ exp.children = extract_children
96
119
 
97
- expression
120
+ exp
98
121
  end
99
122
 
100
123
  #
@@ -127,24 +150,30 @@ module OpenWFE
127
150
  end
128
151
  end
129
152
 
153
+ #--
130
154
  #def reply (workitem)
131
155
  # no implementation necessary
132
156
  #end
157
+ #++
158
+
159
+ def is_definition?
133
160
 
134
- def is_definition? ()
135
161
  get_expression_map.is_definition?(expression_name())
136
162
  end
137
163
 
138
- def expression_class ()
164
+ def expression_class
165
+
139
166
  get_expression_map.get_class(expression_name())
140
167
  end
141
168
 
142
- def definition_name ()
143
- raw_representation.attributes['name'].to_s
169
+ def definition_name
170
+
171
+ raw_representation[1]['name'].to_s
144
172
  end
145
173
 
146
- def expression_name ()
147
- raw_representation.name
174
+ def expression_name
175
+
176
+ raw_representation.first
148
177
  end
149
178
 
150
179
  #
@@ -153,7 +182,18 @@ module OpenWFE
153
182
  # Currently only used by FilterDefinitionExpression.
154
183
  #
155
184
  def load_attributes
156
- @attributes = extract_attributes()
185
+
186
+ @attributes = raw_representation[1]
187
+ end
188
+
189
+ #
190
+ # This method has been made public in order to have quick look
191
+ # at the attributes of an expression before it's really
192
+ # 'instantiated'.
193
+ #
194
+ def extract_attributes
195
+
196
+ raw_representation[1]
157
197
  end
158
198
 
159
199
  protected
@@ -172,35 +212,38 @@ module OpenWFE
172
212
  p = get_participant_map.lookup_participant(name)
173
213
  end
174
214
 
175
- if p
176
- name
177
- else
178
- nil
179
- end
215
+ return name if p
216
+
217
+ nil
180
218
  end
181
219
 
182
220
  #
183
221
  # Determines if this raw expression points to a classical
184
222
  # expression, a participant or a subprocess, or nothing at all...
185
223
  #
186
- def determine_real_expression ()
224
+ def determine_real_expression
187
225
 
188
226
  exp_name = expression_name()
189
-
190
227
  exp_class = expression_class()
191
- attributes = nil
228
+ var_value = lookup_variable exp_name
229
+ attributes = extract_attributes
192
230
 
193
- var_value = lookup_variable(exp_name)
194
-
195
- var_value = exp_name if (not exp_class and not var_value)
231
+ unless var_value
232
+ #
233
+ # accomodating "sub_process_name" and "sub-process-name"
234
+ #
235
+ alt = OpenWFE::to_underscore exp_name
236
+ var_value = lookup_variable(alt) if alt != exp_name
196
237
 
197
- if var_value
198
- attributes = extract_attributes()
238
+ exp_name = alt if var_value
199
239
  end
200
240
 
241
+ var_value = exp_name \
242
+ if (not exp_class and not var_value)
243
+
201
244
  if var_value.is_a?(String)
202
245
 
203
- participant_name = lookup_participant(var_value)
246
+ participant_name = lookup_participant var_value
204
247
 
205
248
  if participant_name
206
249
  exp_name = participant_name
@@ -245,23 +288,93 @@ module OpenWFE
245
288
  unless default
246
289
  end
247
290
 
248
- #--
249
- #def extract_attributes ()
250
- # raise NotImplementedError.new("'abstract method' sorry")
251
- #end
252
- #def extract_children ()
253
- # raise NotImplementedError.new("'abstract method' sorry")
254
- #end
255
- #def extract_descriptions ()
256
- # raise NotImplementedError.new("'abstract method' sorry")
257
- #end
258
- #def extract_parameters ()
259
- # raise NotImplementedError.new("'abstract method' sorry")
260
- #end
261
- #def extract_text_children ()
262
- # raise NotImplementedError.new("'abstract method' sorry")
263
- #end
264
- #++
291
+ def extract_descriptions
292
+
293
+ result = []
294
+ raw_representation.last.each do |child|
295
+
296
+ #next unless child.is_a?(SimpleExpRepresentation)
297
+ next if is_not_a_node?(child)
298
+ next if child.first.intern != :description
299
+
300
+ attributes = child[1]
301
+
302
+ lang = attributes[:language]
303
+ lang = attributes[:lang] unless lang
304
+ lang = "default" unless lang
305
+
306
+ result << [ lang, child.last.first ]
307
+ end
308
+ result
309
+ end
310
+
311
+ def extract_children
312
+
313
+ i = 0
314
+ result = []
315
+ raw_representation.last.each do |child|
316
+
317
+ #if child.kind_of?(SimpleExpRepresentation)
318
+ #if child.kind_of?(Array)
319
+ if is_not_a_node?(child)
320
+
321
+ result << child
322
+ else
323
+
324
+ cname = child.first.intern
325
+
326
+ next if cname == :param
327
+ next if cname == :parameter
328
+ next if cname == :description
329
+
330
+ cfei = @fei.dup
331
+ cfei.expression_name = child.first
332
+ cfei.expression_id = "#{cfei.expression_id}.#{i}"
333
+
334
+ efei = @environment_id
335
+
336
+ rawexp = RawExpression.new_raw(
337
+ cfei, @fei, efei, @application_context, child)
338
+
339
+ get_expression_pool.update rawexp
340
+
341
+ i = i + 1
342
+
343
+ result << rawexp.fei
344
+ end
345
+ end
346
+ result
347
+ end
348
+
349
+ def extract_parameters
350
+
351
+ r = []
352
+ raw_representation.last.each do |child|
353
+
354
+ #next unless child.is_a?(SimpleExpRepresentation)
355
+ #next unless child.is_a?(Array)
356
+ next if is_not_a_node?(child)
357
+
358
+ name = child.first.to_sym
359
+ next unless (name == :parameter or name == :param)
360
+
361
+ attributes = child[1]
362
+
363
+ r << Parameter.new(
364
+ attributes['field'],
365
+ attributes['match'],
366
+ attributes['default'],
367
+ attributes['type'])
368
+ end
369
+ r
370
+ end
371
+
372
+ def is_not_a_node? (child)
373
+
374
+ (( ! child.is_a?(Array)) ||
375
+ child.size != 3 ||
376
+ ( ! child.first.is_a?(String)))
377
+ end
265
378
 
266
379
  #
267
380
  # Expressions can get tagged. Tagged expressions can easily
@@ -275,7 +388,7 @@ module OpenWFE
275
388
 
276
389
  ldebug { "consider_tag() tag is '#{tagname}'" }
277
390
 
278
- set_variable(tagname, Tag.new(self, workitem))
391
+ set_variable tagname, Tag.new(self, workitem)
279
392
  #
280
393
  # keep copy of raw expression and workitem as applied
281
394
 
@@ -310,6 +423,9 @@ module OpenWFE
310
423
  # Encapsulating
311
424
  # <parameter field="x" default="y" type="z" match="m" />
312
425
  #
426
+ # Somehow I have that : OpenWFEru is not a strongly typed language
427
+ # ... Anyway I implemented that to please Pat.
428
+ #
313
429
  class Parameter
314
430
 
315
431
  def initialize (field, match, default, type)
@@ -391,5 +507,87 @@ module OpenWFE
391
507
  end
392
508
  end
393
509
 
510
+ #
511
+ # This class is only present to ensure that OpenWFEru 0.9.17 can read
512
+ # previous (<= 0.9.16) expools.
513
+ #
514
+ class ProgRawExpression < RawExpression
515
+
516
+ def raw_representation
517
+
518
+ @raw_representation.to_a
519
+ end
520
+ end
521
+
522
+ #
523
+ # This class is only present to ensure that OpenWFEru 0.9.17 can read
524
+ # previous (<= 0.9.16) expools.
525
+ #
526
+ class XmlRawExpression < RawExpression
527
+
528
+ def raw_representation
529
+
530
+ #SimpleExpRepresentation.from_xml @raw_representation_s
531
+ DefParser.parse_xml @raw_representation_s
532
+ end
533
+ end
534
+
535
+ #
536
+ # This class is only present to ensure that OpenWFEru 0.9.17 can read
537
+ # previous (<= 0.9.16) expools.
538
+ #
539
+ class SimpleExpRepresentation
540
+
541
+ def to_a
542
+
543
+ children = @children.collect do |c|
544
+ if c.is_a?(SimpleExpRepresentation)
545
+ c.to_a
546
+ else
547
+ c
548
+ end
549
+ end
550
+
551
+ a = [ @name, @attributes, children ]
552
+ end
553
+ end
554
+
555
+ private
556
+
557
+ #
558
+ # OpenWFE process definitions do use some
559
+ # Ruby keywords... The workaround is to put an underscore
560
+ # just before the name to 'escape' it.
561
+ #
562
+ # 'undo' isn't reserved by Ruby, but lets keep it in line
563
+ # with 'do' and 'redo' that are.
564
+ #
565
+ KEYWORDS = [
566
+ :if, :do, :redo, :undo, :print, :sleep, :loop, :break, :when
567
+ #:until, :while
568
+ ]
569
+
570
+ #
571
+ # Ensures the method name is not conflicting with Ruby keywords
572
+ # and turn dashes to underscores.
573
+ #
574
+ def OpenWFE.make_safe (method_name)
575
+
576
+ method_name = OpenWFE::to_underscore(method_name)
577
+
578
+ return "_" + method_name \
579
+ if KEYWORDS.include? eval(":"+method_name)
580
+
581
+ method_name
582
+ end
583
+
584
+ def OpenWFE.to_expression_name (method_name)
585
+
586
+ method_name = method_name.to_s
587
+ method_name = method_name[1..-1] if method_name[0, 1] == "_"
588
+ method_name = OpenWFE::to_dash(method_name)
589
+ method_name
590
+ end
591
+
394
592
  end
395
593