ruote 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +166 -1
- data/CREDITS.txt +36 -17
- data/LICENSE.txt +1 -1
- data/README.rdoc +1 -7
- data/Rakefile +38 -29
- data/TODO.txt +93 -52
- data/lib/ruote-fs.rb +3 -0
- data/lib/ruote.rb +5 -1
- data/lib/ruote/context.rb +140 -35
- data/lib/ruote/dashboard.rb +1247 -0
- data/lib/ruote/{engine → dboard}/process_error.rb +22 -2
- data/lib/ruote/dboard/process_status.rb +587 -0
- data/lib/ruote/engine.rb +6 -871
- data/lib/ruote/exp/command.rb +7 -2
- data/lib/ruote/exp/commanded.rb +2 -2
- data/lib/ruote/exp/condition.rb +38 -13
- 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 +357 -0
- data/lib/ruote/exp/fe_cancel_process.rb +17 -3
- data/lib/ruote/exp/fe_command.rb +8 -4
- data/lib/ruote/exp/fe_concurrence.rb +218 -18
- data/lib/ruote/exp/fe_concurrent_iterator.rb +71 -10
- data/lib/ruote/exp/fe_cron.rb +3 -10
- data/lib/ruote/exp/fe_cursor.rb +14 -4
- data/lib/ruote/exp/fe_define.rb +3 -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 +163 -4
- data/lib/ruote/exp/fe_forget.rb +21 -4
- data/lib/ruote/exp/fe_given.rb +1 -1
- data/lib/ruote/exp/fe_if.rb +1 -1
- data/lib/ruote/exp/fe_inc.rb +102 -35
- data/lib/ruote/exp/fe_iterator.rb +47 -12
- data/lib/ruote/exp/fe_listen.rb +96 -11
- data/lib/ruote/exp/fe_lose.rb +31 -4
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/fe_on_error.rb +109 -0
- data/lib/ruote/exp/fe_once.rb +10 -19
- data/lib/ruote/exp/fe_participant.rb +90 -28
- data/lib/ruote/exp/fe_read.rb +69 -0
- data/lib/ruote/exp/fe_redo.rb +3 -2
- data/lib/ruote/exp/fe_ref.rb +57 -27
- data/lib/ruote/exp/fe_registerp.rb +1 -3
- data/lib/ruote/exp/fe_reserve.rb +1 -1
- data/lib/ruote/exp/fe_restore.rb +6 -6
- data/lib/ruote/exp/fe_save.rb +12 -19
- data/lib/ruote/exp/fe_sequence.rb +38 -2
- data/lib/ruote/exp/fe_set.rb +143 -40
- data/lib/ruote/exp/{fe_let.rb → fe_stall.rb} +7 -38
- data/lib/ruote/exp/fe_subprocess.rb +8 -2
- data/lib/ruote/exp/fe_that.rb +1 -1
- data/lib/ruote/exp/fe_undo.rb +40 -4
- data/lib/ruote/exp/fe_unregisterp.rb +1 -3
- data/lib/ruote/exp/fe_wait.rb +12 -25
- data/lib/ruote/exp/{flowexpression.rb → flow_expression.rb} +375 -229
- data/lib/ruote/exp/iterator.rb +2 -2
- data/lib/ruote/exp/merge.rb +78 -17
- data/lib/ruote/exp/ro_attributes.rb +46 -36
- data/lib/ruote/exp/ro_filters.rb +34 -8
- data/lib/ruote/exp/ro_on_x.rb +431 -0
- data/lib/ruote/exp/ro_persist.rb +19 -7
- data/lib/ruote/exp/ro_timers.rb +123 -0
- data/lib/ruote/exp/ro_variables.rb +90 -29
- data/lib/ruote/fei.rb +57 -3
- data/lib/ruote/fs.rb +3 -0
- data/lib/ruote/id/mnemo_wfid_generator.rb +30 -7
- data/lib/ruote/id/wfid_generator.rb +17 -38
- data/lib/ruote/log/default_history.rb +23 -9
- data/lib/ruote/log/fancy_printing.rb +265 -0
- data/lib/ruote/log/storage_history.rb +23 -13
- data/lib/ruote/log/wait_logger.rb +224 -17
- data/lib/ruote/observer.rb +82 -0
- data/lib/ruote/part/block_participant.rb +65 -28
- data/lib/ruote/part/code_participant.rb +81 -0
- data/lib/ruote/part/engine_participant.rb +7 -2
- data/lib/ruote/part/local_participant.rb +221 -21
- 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 +50 -0
- data/lib/ruote/part/rev_participant.rb +178 -0
- data/lib/ruote/part/smtp_participant.rb +2 -2
- data/lib/ruote/part/storage_participant.rb +228 -60
- data/lib/ruote/part/template.rb +1 -1
- data/lib/ruote/participant.rb +2 -0
- data/lib/ruote/reader.rb +205 -68
- data/lib/ruote/reader/json.rb +49 -0
- data/lib/ruote/reader/radial.rb +303 -0
- data/lib/ruote/reader/ruby_dsl.rb +44 -9
- data/lib/ruote/reader/xml.rb +11 -8
- data/lib/ruote/receiver/base.rb +98 -45
- data/lib/ruote/storage/base.rb +104 -35
- data/lib/ruote/storage/composite_storage.rb +50 -60
- data/lib/ruote/storage/fs_storage.rb +25 -34
- data/lib/ruote/storage/hash_storage.rb +38 -36
- data/lib/ruote/svc/dispatch_pool.rb +104 -35
- data/lib/ruote/svc/dollar_sub.rb +10 -8
- data/lib/ruote/svc/error_handler.rb +108 -52
- data/lib/ruote/svc/expression_map.rb +3 -3
- data/lib/ruote/svc/participant_list.rb +160 -55
- data/lib/ruote/svc/tracker.rb +31 -31
- data/lib/ruote/svc/treechecker.rb +28 -16
- data/lib/ruote/tree_dot.rb +1 -1
- data/lib/ruote/util/deep.rb +143 -0
- data/lib/ruote/util/filter.rb +125 -18
- data/lib/ruote/util/hashdot.rb +15 -13
- data/lib/ruote/util/look.rb +1 -1
- data/lib/ruote/util/lookup.rb +60 -22
- data/lib/ruote/util/misc.rb +63 -18
- data/lib/ruote/util/mpatch.rb +53 -0
- data/lib/ruote/util/ometa.rb +1 -2
- data/lib/ruote/util/process_observer.rb +177 -0
- data/lib/ruote/util/subprocess.rb +1 -1
- data/lib/ruote/util/time.rb +2 -2
- data/lib/ruote/util/tree.rb +64 -2
- data/lib/ruote/version.rb +3 -2
- data/lib/ruote/worker.rb +421 -92
- data/lib/ruote/workitem.rb +157 -22
- data/ruote.gemspec +15 -9
- data/test/bm/ci.rb +0 -2
- data/test/bm/ici.rb +0 -2
- data/test/bm/load_26c.rb +0 -3
- data/test/bm/mega.rb +0 -2
- data/test/functional/base.rb +57 -43
- data/test/functional/concurrent_base.rb +16 -13
- data/test/functional/ct_0_concurrence.rb +7 -11
- data/test/functional/ct_1_iterator.rb +9 -11
- data/test/functional/ct_2_cancel.rb +28 -17
- data/test/functional/eft_0_flow_expression.rb +35 -0
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_11_wait.rb +13 -13
- data/test/functional/eft_12_listen.rb +199 -66
- data/test/functional/eft_13_iterator.rb +95 -29
- data/test/functional/eft_14_cursor.rb +74 -24
- data/test/functional/eft_15_loop.rb +7 -7
- data/test/functional/eft_16_if.rb +1 -1
- data/test/functional/eft_17_equals.rb +1 -1
- data/test/functional/eft_18_concurrent_iterator.rb +156 -68
- data/test/functional/eft_19_reserve.rb +15 -15
- data/test/functional/eft_1_echo.rb +1 -1
- data/test/functional/eft_20_save.rb +51 -9
- data/test/functional/eft_21_restore.rb +1 -1
- data/test/functional/eft_22_noop.rb +1 -1
- data/test/functional/eft_23_apply.rb +1 -1
- data/test/functional/eft_24_add_branches.rb +7 -8
- data/test/functional/eft_25_command.rb +1 -1
- data/test/functional/eft_26_error.rb +11 -11
- data/test/functional/eft_27_inc.rb +111 -67
- data/test/functional/eft_28_once.rb +16 -16
- data/test/functional/eft_29_cron.rb +9 -9
- data/test/functional/eft_2_sequence.rb +23 -4
- data/test/functional/eft_30_ref.rb +36 -24
- data/test/functional/eft_31_registerp.rb +24 -24
- data/test/functional/eft_32_lose.rb +46 -20
- data/test/functional/eft_34_given.rb +1 -1
- data/test/functional/eft_35_filter.rb +161 -7
- data/test/functional/eft_36_read.rb +97 -0
- data/test/functional/{eft_0_process_definition.rb → eft_37_process_definition.rb} +4 -4
- data/test/functional/eft_38_on_error.rb +195 -0
- data/test/functional/eft_39_stall.rb +35 -0
- data/test/functional/eft_3_participant.rb +77 -22
- data/test/functional/eft_40_await.rb +297 -0
- data/test/functional/eft_4_set.rb +110 -11
- data/test/functional/eft_5_subprocess.rb +27 -5
- data/test/functional/eft_6_concurrence.rb +299 -60
- data/test/functional/eft_7_forget.rb +24 -22
- data/test/functional/eft_8_undo.rb +52 -15
- data/test/functional/eft_9_redo.rb +18 -20
- data/test/functional/ft_0_worker.rb +122 -13
- data/test/functional/ft_10_dollar.rb +77 -16
- data/test/functional/ft_11_recursion.rb +9 -9
- data/test/functional/ft_12_launchitem.rb +7 -9
- data/test/functional/ft_13_variables.rb +125 -22
- data/test/functional/ft_14_re_apply.rb +112 -56
- data/test/functional/ft_15_timeout.rb +64 -33
- data/test/functional/ft_16_participant_params.rb +59 -6
- data/test/functional/ft_17_conditional.rb +68 -2
- data/test/functional/ft_18_kill.rb +48 -30
- data/test/functional/ft_19_participant_code.rb +67 -0
- data/test/functional/ft_1_process_status.rb +222 -150
- data/test/functional/ft_20_storage_participant.rb +445 -44
- data/test/functional/ft_21_forget.rb +21 -26
- data/test/functional/ft_22_process_definitions.rb +8 -6
- data/test/functional/ft_23_load_defs.rb +29 -5
- data/test/functional/ft_24_block_participant.rb +199 -20
- data/test/functional/ft_25_receiver.rb +98 -46
- data/test/functional/ft_26_participant_rtimeout.rb +34 -26
- data/test/functional/ft_27_var_indirection.rb +40 -5
- data/test/functional/ft_28_null_noop_participants.rb +5 -5
- data/test/functional/ft_29_part_template.rb +2 -2
- data/test/functional/ft_2_errors.rb +106 -74
- data/test/functional/ft_30_smtp_participant.rb +7 -7
- data/test/functional/ft_31_part_blocking.rb +11 -11
- data/test/functional/ft_32_scope.rb +50 -0
- data/test/functional/ft_33_participant_subprocess_priority.rb +3 -3
- data/test/functional/ft_34_cursor_rewind.rb +14 -14
- data/test/functional/ft_35_add_service.rb +67 -9
- data/test/functional/ft_36_storage_history.rb +92 -24
- data/test/functional/ft_37_default_history.rb +35 -23
- data/test/functional/ft_38_participant_more.rb +189 -32
- data/test/functional/ft_39_wait_for.rb +25 -25
- data/test/functional/ft_3_participant_registration.rb +235 -107
- data/test/functional/ft_40_wait_logger.rb +105 -18
- data/test/functional/ft_41_participants.rb +13 -12
- data/test/functional/ft_42_storage_copy.rb +12 -12
- data/test/functional/ft_43_participant_on_reply.rb +85 -11
- data/test/functional/ft_44_var_participant.rb +5 -5
- data/test/functional/ft_45_participant_accept.rb +3 -3
- data/test/functional/ft_46_launch_single.rb +17 -17
- data/test/functional/ft_47_wfids.rb +41 -0
- data/test/functional/ft_48_lose.rb +19 -25
- data/test/functional/ft_49_engine_on_error.rb +54 -70
- data/test/functional/ft_4_cancel.rb +84 -26
- data/test/functional/ft_50_engine_config.rb +4 -4
- data/test/functional/ft_51_misc.rb +12 -12
- data/test/functional/ft_52_case.rb +17 -17
- data/test/functional/ft_53_engine_on_terminate.rb +18 -21
- data/test/functional/ft_54_patterns.rb +18 -16
- data/test/functional/ft_55_engine_participant.rb +55 -55
- data/test/functional/ft_56_filter_attribute.rb +90 -52
- data/test/functional/ft_57_rev_participant.rb +252 -0
- data/test/functional/ft_58_workitem.rb +150 -0
- data/test/functional/ft_59_pause.rb +329 -0
- data/test/functional/ft_5_on_error.rb +430 -77
- data/test/functional/ft_60_code_participant.rb +65 -0
- data/test/functional/ft_61_trailing_fields.rb +34 -0
- data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
- data/test/functional/ft_63_participants_221.rb +458 -0
- data/test/functional/ft_64_stash.rb +41 -0
- data/test/functional/ft_65_timers.rb +313 -0
- data/test/functional/ft_66_flank.rb +133 -0
- data/test/functional/ft_67_radial_misc.rb +34 -0
- data/test/functional/ft_68_reput.rb +72 -0
- data/test/functional/ft_69_worker_info.rb +56 -0
- data/test/functional/ft_6_on_cancel.rb +189 -36
- data/test/functional/ft_70_take_and_discard_attributes.rb +94 -0
- data/test/functional/ft_71_retries.rb +144 -0
- data/test/functional/ft_72_on_terminate.rb +60 -0
- data/test/functional/ft_73_raise_msg.rb +107 -0
- data/test/functional/ft_74_respark.rb +106 -0
- data/test/functional/ft_75_context.rb +66 -0
- data/test/functional/ft_76_observer.rb +53 -0
- data/test/functional/ft_77_process_observer.rb +157 -0
- data/test/functional/ft_78_part_participant.rb +37 -0
- data/test/functional/ft_7_tags.rb +238 -50
- data/test/functional/ft_8_participant_consumption.rb +27 -21
- data/test/functional/ft_9_subprocesses.rb +48 -18
- data/test/functional/restart_base.rb +4 -6
- data/test/functional/rt_0_wait.rb +10 -10
- data/test/functional/rt_1_listen.rb +6 -6
- data/test/functional/rt_2_errors.rb +12 -12
- data/test/functional/rt_3_once.rb +17 -12
- data/test/functional/rt_4_cron.rb +17 -17
- data/test/functional/rt_5_timeout.rb +13 -13
- data/test/functional/signals.rb +103 -0
- data/test/functional/storage.rb +730 -0
- data/test/functional/storage_helper.rb +48 -35
- data/test/functional/test.rb +6 -2
- data/test/misc/idle.rb +21 -0
- data/test/misc/light.rb +29 -0
- data/test/path_helper.rb +1 -1
- data/test/test.rb +2 -5
- data/test/test_helper.rb +13 -0
- data/test/unit/test.rb +1 -4
- data/test/unit/ut_0_ruby_reader.rb +25 -9
- data/test/unit/ut_10_participants.rb +47 -0
- data/test/unit/ut_11_lookup.rb +59 -2
- data/test/unit/ut_12_wait_logger.rb +123 -0
- data/test/unit/ut_14_is_uri.rb +1 -1
- data/test/unit/ut_15_util.rb +1 -1
- data/test/unit/ut_16_reader.rb +136 -14
- data/test/unit/ut_17_merge.rb +155 -0
- data/test/unit/ut_19_part_template.rb +1 -1
- data/test/unit/ut_1_fei.rb +11 -2
- data/test/unit/ut_20_composite_storage.rb +27 -1
- data/test/unit/{ut_21_participant_list.rb → ut_21_svc_participant_list.rb} +2 -3
- data/test/unit/ut_22_filter.rb +231 -10
- data/test/unit/ut_23_svc_tracker.rb +48 -0
- data/test/unit/ut_24_radial_reader.rb +458 -0
- data/test/unit/ut_25_process_status.rb +143 -0
- data/test/unit/ut_26_deep.rb +131 -0
- data/test/unit/ut_2_dashboard.rb +114 -0
- data/test/unit/ut_3_worker.rb +54 -0
- data/test/unit/ut_4_expmap.rb +1 -1
- data/test/unit/ut_5_tree.rb +23 -23
- data/test/unit/ut_6_condition.rb +71 -29
- data/test/unit/ut_7_workitem.rb +18 -4
- data/test/unit/ut_8_tree_to_dot.rb +1 -1
- data/test/unit/ut_9_xml_reader.rb +1 -1
- metadata +142 -63
- data/jruby_issue.txt +0 -32
- data/lib/ruote/engine/process_status.rb +0 -403
- data/lib/ruote/log/pretty.rb +0 -165
- data/lib/ruote/log/test_logger.rb +0 -204
- data/lib/ruote/util/serializer.rb +0 -103
- data/phil.txt +0 -14
- data/test/functional/eft_33_let.rb +0 -31
- data/test/functional/ft_19_alias.rb +0 -33
- data/test/functional/ft_47_wfid_generator.rb +0 -54
- data/test/unit/storage.rb +0 -403
- data/test/unit/storages.rb +0 -37
- data/test/unit/ut_13_serializer.rb +0 -65
- data/test/unit/ut_18_engine.rb +0 -47
- data/test/unit/ut_3_wait_logger.rb +0 -39
data/lib/ruote/part/template.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2012, 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/participant.rb
CHANGED
data/lib/ruote/reader.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2005-
|
2
|
+
# Copyright (c) 2005-2012, 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
|
@@ -22,12 +22,14 @@
|
|
22
22
|
# Made in Japan.
|
23
23
|
#++
|
24
24
|
|
25
|
-
|
26
25
|
require 'uri'
|
27
26
|
require 'open-uri'
|
28
27
|
require 'rufus/json'
|
29
|
-
require 'ruote/reader/ruby_dsl' # just making sure it's loaded
|
30
28
|
require 'ruote/reader/xml'
|
29
|
+
require 'ruote/reader/json'
|
30
|
+
require 'ruote/reader/radial'
|
31
|
+
require 'ruote/reader/ruby_dsl' # just making sure it's loaded
|
32
|
+
require 'ruote/util/mpatch'
|
31
33
|
require 'ruote/util/subprocess'
|
32
34
|
|
33
35
|
|
@@ -40,6 +42,32 @@ module Ruote
|
|
40
42
|
#
|
41
43
|
class Reader
|
42
44
|
|
45
|
+
# This error is emitted by the reader when it failed to read a process
|
46
|
+
# definition (passed as a string).
|
47
|
+
#
|
48
|
+
class Error < ArgumentError
|
49
|
+
|
50
|
+
attr_reader :definition
|
51
|
+
attr_reader :ruby, :radial, :xml, :json
|
52
|
+
|
53
|
+
def initialize(definition)
|
54
|
+
super('cannot read process definition')
|
55
|
+
@definition = definition
|
56
|
+
end
|
57
|
+
|
58
|
+
def <<(args)
|
59
|
+
type, error = args
|
60
|
+
type = type.to_s.match(/^Ruote::(.+)Reader$/)[1].downcase
|
61
|
+
instance_variable_set("@#{type}", error)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the most likely error cause...
|
65
|
+
#
|
66
|
+
def cause
|
67
|
+
@ruby || @radial || @xml || @json
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
43
71
|
def initialize(context)
|
44
72
|
|
45
73
|
@context = context
|
@@ -52,22 +80,41 @@ module Ruote
|
|
52
80
|
|
53
81
|
return definition if Ruote.is_tree?(definition)
|
54
82
|
|
55
|
-
|
56
|
-
|
57
|
-
|
83
|
+
raise ArgumentError.new(
|
84
|
+
"cannot read process definitions of class #{definition.class}"
|
85
|
+
) unless definition.is_a?(String)
|
58
86
|
|
59
|
-
if
|
87
|
+
if is_uri?(definition)
|
60
88
|
|
61
|
-
|
62
|
-
|
63
|
-
|
89
|
+
if
|
90
|
+
Ruote::Reader.remote?(definition) &&
|
91
|
+
@context['remote_definition_allowed'] != true
|
92
|
+
then
|
93
|
+
raise ArgumentError.new('remote process definitions are not allowed')
|
94
|
+
end
|
64
95
|
|
65
96
|
return read(open(definition).read)
|
66
97
|
end
|
67
98
|
|
68
|
-
|
69
|
-
|
70
|
-
|
99
|
+
tree = nil
|
100
|
+
error = Error.new(definition)
|
101
|
+
|
102
|
+
[
|
103
|
+
Ruote::RubyReader, Ruote::RadialReader,
|
104
|
+
Ruote::XmlReader, Ruote::JsonReader
|
105
|
+
].each do |reader|
|
106
|
+
|
107
|
+
next if tree
|
108
|
+
next unless reader.understands?(definition)
|
109
|
+
|
110
|
+
begin
|
111
|
+
tree = reader.read(definition, @context.treechecker)
|
112
|
+
rescue => e
|
113
|
+
error << [ reader, e ]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
tree || raise(error)
|
71
118
|
end
|
72
119
|
|
73
120
|
# Class method for parsing process definition (XML, Ruby, from file or
|
@@ -94,30 +141,55 @@ module Ruote
|
|
94
141
|
#
|
95
142
|
def self.to_xml(tree, options={})
|
96
143
|
|
97
|
-
|
144
|
+
s = StringIO.new
|
145
|
+
s.puts('<?xml version="1.0" encoding="UTF-8"?>')
|
146
|
+
|
147
|
+
_to_xml(tree, options[:indent], 0, s)
|
148
|
+
|
149
|
+
s.string
|
150
|
+
end
|
98
151
|
|
99
|
-
|
152
|
+
# Not as good as the builder gem, but at least doesn't come bundled with
|
153
|
+
# lib/blankslate.rb
|
154
|
+
#
|
155
|
+
def self._to_xml(tree, indent, level, s) # :nodoc:
|
100
156
|
|
101
|
-
|
157
|
+
atts = tree[1].dup
|
102
158
|
|
103
|
-
|
159
|
+
if t = atts.find { |k, v| v == nil }
|
160
|
+
atts.delete(t.first)
|
161
|
+
atts[tree[0] == 'if' ? 'test' : 'ref'] = t.first
|
162
|
+
end
|
104
163
|
|
105
|
-
|
106
|
-
|
107
|
-
atts.delete(t.first)
|
108
|
-
key = tree[0] == 'if' ? 'test' : 'ref'
|
109
|
-
atts[key] = t.first
|
110
|
-
end
|
164
|
+
atts = atts.remap { |(k, v), h| h[k.to_s.gsub(/\_/, '-')] = v }
|
165
|
+
atts = atts.to_a.sort_by { |k, v| k }
|
111
166
|
|
112
|
-
|
167
|
+
s.print ' ' * level
|
113
168
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
169
|
+
s.print '<'
|
170
|
+
s.print tree[0]
|
171
|
+
|
172
|
+
if atts.any?
|
173
|
+
s.print ' '
|
174
|
+
s.print atts.collect { |k, v|
|
175
|
+
"#{k}=#{v.is_a?(String) ? v.inspect : v.inspect.inspect}"
|
176
|
+
}.join(' ')
|
177
|
+
end
|
178
|
+
|
179
|
+
if tree[2].empty?
|
180
|
+
|
181
|
+
s.puts '/>'
|
182
|
+
|
183
|
+
else
|
184
|
+
|
185
|
+
s.puts '>'
|
186
|
+
|
187
|
+
tree[2].each { |child| _to_xml(child, indent, level + (indent || 0), s) }
|
188
|
+
|
189
|
+
s.print ' ' * level
|
190
|
+
s.print '</'
|
191
|
+
s.print tree[0]
|
192
|
+
s.puts '>'
|
121
193
|
end
|
122
194
|
end
|
123
195
|
|
@@ -129,10 +201,9 @@ module Ruote
|
|
129
201
|
def self.to_ruby(tree, level=0)
|
130
202
|
|
131
203
|
expname = tree[0]
|
132
|
-
|
133
204
|
expname = 'Ruote.process_definition' if level == 0 && expname == 'define'
|
134
205
|
|
135
|
-
s =
|
206
|
+
s = ' ' * level + expname + atts_to_ruby(tree[1])
|
136
207
|
|
137
208
|
return "#{s}\n" if tree[2].empty?
|
138
209
|
|
@@ -143,6 +214,61 @@ module Ruote
|
|
143
214
|
s
|
144
215
|
end
|
145
216
|
|
217
|
+
# Turns the given tree into a radial process definition.
|
218
|
+
#
|
219
|
+
def self.to_radial(tree, level=0)
|
220
|
+
|
221
|
+
s = ' ' * level + tree[0] + atts_to_radial(tree[1]) + "\n"
|
222
|
+
|
223
|
+
return s if tree[2].empty?
|
224
|
+
|
225
|
+
tree[2].inject(s) { |ss, child| ss << to_radial(child, level + 1); ss }
|
226
|
+
end
|
227
|
+
|
228
|
+
# Produces an expid annotated radial version of the process definition,
|
229
|
+
# like:
|
230
|
+
#
|
231
|
+
# 0 define name: "nada"
|
232
|
+
# 0_0 sequence
|
233
|
+
# 0_0_0 alpha
|
234
|
+
# 0_0_1 participant "bravo", timeout: "2d", on_board: true
|
235
|
+
#
|
236
|
+
# Can be useful when debugging noisy engines.
|
237
|
+
#
|
238
|
+
def self.to_expid_radial(tree)
|
239
|
+
|
240
|
+
lines = to_raw_expid_radial(tree, '0')
|
241
|
+
max = lines.collect { |l| l[1].length }.max
|
242
|
+
|
243
|
+
lines.collect { |l|
|
244
|
+
"%#{max}s " % l[1] + " " * l[0] + l[2] + l[3]
|
245
|
+
}.join("\n")
|
246
|
+
end
|
247
|
+
|
248
|
+
# Used by .to_expid_radial. Outputs an array of 'lines'. Each line
|
249
|
+
# is a process definition line, represented as an array:
|
250
|
+
#
|
251
|
+
# [ level, expid, name, atts ]
|
252
|
+
#
|
253
|
+
# Like in:
|
254
|
+
#
|
255
|
+
# [[0, "0", "define", " name: \"nada\""],
|
256
|
+
# [1, "0_0", "sequence", ""],
|
257
|
+
# [2, "0_0_0", "alpha", ""],
|
258
|
+
# [2, "0_0_1", "participant", " \"bravo\", timeout: \"2d\"]]
|
259
|
+
#
|
260
|
+
def self.to_raw_expid_radial(tree, expid='0')
|
261
|
+
|
262
|
+
i = -1
|
263
|
+
|
264
|
+
[
|
265
|
+
[ expid.split('_').size - 1, expid, tree[0], atts_to_radial(tree[1]) ]
|
266
|
+
] +
|
267
|
+
tree[2].collect { |t|
|
268
|
+
i = i + 1; to_raw_expid_radial(t, "#{expid}_#{i}")
|
269
|
+
}.flatten(1)
|
270
|
+
end
|
271
|
+
|
146
272
|
# Turns the process definition tree (ruote syntax tree) to a JSON String.
|
147
273
|
#
|
148
274
|
def self.to_json(tree)
|
@@ -161,58 +287,69 @@ module Ruote
|
|
161
287
|
|
162
288
|
protected
|
163
289
|
|
164
|
-
#
|
165
|
-
# treechecker, makes sure it doesn't code malicious ruby code (at least
|
166
|
-
# tries very hard).
|
290
|
+
# Minimal test. Used by #read.
|
167
291
|
#
|
168
|
-
def
|
292
|
+
def is_uri?(s)
|
169
293
|
|
170
|
-
|
171
|
-
eval(s)
|
294
|
+
return false if s.index("\n")
|
172
295
|
|
173
|
-
|
174
|
-
|
175
|
-
|
296
|
+
((URI.parse(s); true) rescue false)
|
297
|
+
end
|
298
|
+
|
299
|
+
def self.to_ra_string(o)
|
300
|
+
|
301
|
+
return 'nil' if o == nil
|
176
302
|
|
177
|
-
|
178
|
-
#p s
|
179
|
-
#puts '-' * 80
|
180
|
-
#puts e
|
181
|
-
#e.backtrace.each { |l| puts l }
|
303
|
+
s = o.to_s
|
182
304
|
|
183
|
-
|
305
|
+
return s if [ true, false ].include?(o)
|
306
|
+
|
307
|
+
i = o.inspect
|
308
|
+
|
309
|
+
return i if %w[ true false nil ].include?(s)
|
310
|
+
return i if s.match(/[\s:]/)
|
311
|
+
return s if i == "\"#{o.to_s}\""
|
312
|
+
|
313
|
+
i
|
184
314
|
end
|
185
315
|
|
186
|
-
#
|
316
|
+
# split the txt => nil entry and sorts the rest of the attributes.
|
187
317
|
#
|
188
|
-
def self.
|
318
|
+
def self.split_atts(atts)
|
189
319
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
b.instruct! unless options[:instruct] == false
|
196
|
-
block.call(b)
|
197
|
-
b.target!
|
198
|
-
end
|
320
|
+
atts = atts.to_a.sort_by { |k, v| k }
|
321
|
+
txt = atts.find { |k, v| v == nil }
|
322
|
+
atts.delete(txt) if txt
|
323
|
+
|
324
|
+
[ txt ? txt.first : nil, atts ]
|
199
325
|
end
|
200
326
|
|
201
|
-
# As used by
|
327
|
+
# As used by to_radial
|
202
328
|
#
|
203
|
-
def self.
|
329
|
+
def self.atts_to_radial(atts, &block)
|
330
|
+
|
331
|
+
s = []
|
332
|
+
txt, atts = split_atts(atts)
|
333
|
+
|
334
|
+
s << to_ra_string(txt) if txt
|
335
|
+
s += atts.collect { |k, v| "#{to_ra_string(k)}: #{to_ra_string(v)}" }
|
336
|
+
|
337
|
+
s = s.join(', ')
|
204
338
|
|
205
|
-
|
339
|
+
s.length > 0 ? " #{s}" : s
|
340
|
+
end
|
341
|
+
|
342
|
+
# As used by to_ruby
|
343
|
+
#
|
344
|
+
def self.atts_to_ruby(atts, &block)
|
206
345
|
|
207
346
|
s = []
|
347
|
+
txt, atts = split_atts(atts)
|
208
348
|
|
209
|
-
|
210
|
-
s
|
349
|
+
s << txt.inspect if txt
|
350
|
+
s += atts.collect { |k, v| ":#{k} => #{v.inspect}" }
|
211
351
|
|
212
|
-
s =
|
213
|
-
a << ":#{k} => #{v.inspect}" if t.nil? || k != t.first
|
214
|
-
a
|
215
|
-
}.join(', ')
|
352
|
+
s = s.join(', ')
|
216
353
|
|
217
354
|
s.length > 0 ? " #{s}" : s
|
218
355
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
module Ruote
|
27
|
+
|
28
|
+
#
|
29
|
+
# Turns an XML string into a process definition tree.
|
30
|
+
#
|
31
|
+
module JsonReader
|
32
|
+
|
33
|
+
# Returns true if s seems to be a JSON string
|
34
|
+
#
|
35
|
+
def self.understands?(s)
|
36
|
+
|
37
|
+
s = s.strip
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
# Simply parses the JSON string
|
42
|
+
#
|
43
|
+
def self.read(s, opt=nil)
|
44
|
+
|
45
|
+
Rufus::Json.decode(s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,303 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'parslet'
|
26
|
+
|
27
|
+
|
28
|
+
module Ruote
|
29
|
+
|
30
|
+
#
|
31
|
+
# Turning radial strings into ruote trees.
|
32
|
+
#
|
33
|
+
module RadialReader
|
34
|
+
|
35
|
+
#
|
36
|
+
# Turns radial strings into intermediate trees.
|
37
|
+
#
|
38
|
+
class Parser < Parslet::Parser
|
39
|
+
|
40
|
+
rule(:spaces) {
|
41
|
+
match('\s').repeat >>
|
42
|
+
(str('#') >> match('[^\n]').repeat >> str("\n").present?).maybe >>
|
43
|
+
match('\s').repeat
|
44
|
+
}
|
45
|
+
rule(:spaces?) { spaces.maybe }
|
46
|
+
|
47
|
+
rule(:comma) { spaces? >> str(',') >> spaces? }
|
48
|
+
rule(:digit) { match('[0-9]') }
|
49
|
+
|
50
|
+
rule(:text) { match('[^\s:,=\[\]#]').repeat(1).as(:text) }
|
51
|
+
|
52
|
+
rule(:number) {
|
53
|
+
(
|
54
|
+
str('-').maybe >> (
|
55
|
+
str('0') | (match('[1-9]') >> digit.repeat)
|
56
|
+
) >> (
|
57
|
+
str('.') >> digit.repeat(1)
|
58
|
+
).maybe >> (
|
59
|
+
match('[eE]') >> (str('+') | str('-')).maybe >> digit.repeat(1)
|
60
|
+
).maybe
|
61
|
+
).as(:number) >> match('[ \n,]').present?
|
62
|
+
}
|
63
|
+
|
64
|
+
rule(:string) {
|
65
|
+
str('"') >> (
|
66
|
+
str('\\') >> any | str('"').absent? >> any
|
67
|
+
).repeat.as(:string) >> str('"') |
|
68
|
+
str("'") >> (
|
69
|
+
str('\\') >> any | str("'").absent? >> any
|
70
|
+
).repeat.as(:string) >> str("'")
|
71
|
+
}
|
72
|
+
|
73
|
+
rule(:regex) {
|
74
|
+
str('/') >> (
|
75
|
+
str('\\') >> any | str('/').absent? >> any
|
76
|
+
).repeat.as(:regex) >> str('/')
|
77
|
+
}
|
78
|
+
|
79
|
+
rule(:array) {
|
80
|
+
str('[') >> spaces? >>
|
81
|
+
(value >> (comma >> value).repeat).maybe.as(:array) >>
|
82
|
+
spaces? >> str(']')
|
83
|
+
}
|
84
|
+
|
85
|
+
rule(:object) {
|
86
|
+
str('{') >> spaces? >>
|
87
|
+
(entry >> (comma >> entry).repeat).maybe.as(:object) >>
|
88
|
+
spaces? >> str('}')
|
89
|
+
}
|
90
|
+
|
91
|
+
rule(:null) {
|
92
|
+
(str('null') | str('nil')).as(:null)
|
93
|
+
}
|
94
|
+
|
95
|
+
rule(:value) {
|
96
|
+
array | object |
|
97
|
+
string | number |
|
98
|
+
str('true').as(:true) | str('false').as(:false) |
|
99
|
+
null | regex | text
|
100
|
+
}
|
101
|
+
|
102
|
+
rule(:entry) {
|
103
|
+
((string | null | regex | text).as(:key) >> spaces? >>
|
104
|
+
(str(':') | str('=>')) >> spaces? >>
|
105
|
+
value.as(:val)).as(:ent)
|
106
|
+
}
|
107
|
+
|
108
|
+
rule(:attribute) { (entry | value).as(:att) }
|
109
|
+
|
110
|
+
rule(:blanks) { match('[ \t]').repeat(1) }
|
111
|
+
|
112
|
+
rule(:blank_line) { blanks.maybe }
|
113
|
+
rule(:line) {
|
114
|
+
(
|
115
|
+
str(' ').repeat.as(:ind) >>
|
116
|
+
match('[^ \n#"\',]').repeat(1).as(:exp) >>
|
117
|
+
(
|
118
|
+
(comma | blanks) >> attribute >> (comma >> attribute).repeat
|
119
|
+
).as(:atts).maybe
|
120
|
+
).as(:line)
|
121
|
+
}
|
122
|
+
|
123
|
+
rule(:comment) {
|
124
|
+
str(' ').repeat >>
|
125
|
+
(str('#') >> match('[^\n]').repeat).maybe >>
|
126
|
+
str("\n").present?
|
127
|
+
}
|
128
|
+
|
129
|
+
rule(:lines) {
|
130
|
+
(str("\n") >> (line | blank_line) >> comment.maybe).repeat
|
131
|
+
}
|
132
|
+
|
133
|
+
root(:lines)
|
134
|
+
end
|
135
|
+
|
136
|
+
#
|
137
|
+
# A helper class to store the temporary tree while it gets read.
|
138
|
+
#
|
139
|
+
class Node
|
140
|
+
|
141
|
+
attr_reader :parent, :indentation, :children
|
142
|
+
|
143
|
+
def initialize(indentation, expname, attributes)
|
144
|
+
|
145
|
+
@parent = nil
|
146
|
+
@indentation = indentation
|
147
|
+
@children = []
|
148
|
+
|
149
|
+
@expname = expname#.gsub(/-/, '_')
|
150
|
+
@expname.gsub!(/-/, '_') if @expname.match(/^[a-z\-]+$/)
|
151
|
+
@attributes = attributes
|
152
|
+
end
|
153
|
+
|
154
|
+
def parent=(node)
|
155
|
+
|
156
|
+
@parent = node
|
157
|
+
@parent.children << self
|
158
|
+
end
|
159
|
+
|
160
|
+
def to_a
|
161
|
+
|
162
|
+
[ @expname, @attributes, @children.collect { |c| c.to_a } ]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
#
|
167
|
+
# Turns intermediate trees into ruote trees.
|
168
|
+
#
|
169
|
+
class Transformer < Parslet::Transform
|
170
|
+
|
171
|
+
class Attribute
|
172
|
+
attr_reader :key, :val
|
173
|
+
def initialize(key, val)
|
174
|
+
@key = key.to_s.gsub(/-/, '_')
|
175
|
+
@val = val
|
176
|
+
end
|
177
|
+
end
|
178
|
+
class Value < Attribute
|
179
|
+
def initialize(key)
|
180
|
+
@key = key
|
181
|
+
@val = nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
rule(:line => subtree(:line)) { line }
|
186
|
+
|
187
|
+
rule(:ind => simple(:i), :exp => simple(:e), :atts => subtree(:as)) {
|
188
|
+
atts = Array(as).each_with_object({}) { |att, h| h[att.key] = att.val }
|
189
|
+
Node.new(i.to_s.length, e.to_s, atts)
|
190
|
+
}
|
191
|
+
rule(:ind => simple(:i), :exp => simple(:e)) {
|
192
|
+
Node.new(i.to_s.length, e.to_s, {})
|
193
|
+
}
|
194
|
+
rule(:ind => sequence(:i), :exp => simple(:e), :atts => subtree(:as)) {
|
195
|
+
atts = Array(as).each_with_object({}) { |att, h| h[att.key] = att.val }
|
196
|
+
Node.new(0, e.to_s, atts)
|
197
|
+
}
|
198
|
+
rule(:ind => sequence(:i), :exp => simple(:e)) {
|
199
|
+
Node.new(0, e.to_s, {})
|
200
|
+
}
|
201
|
+
|
202
|
+
rule(:att => { :ent => { :key => subtree(:k), :val => subtree(:v) } }) {
|
203
|
+
Attribute.new(k, v)
|
204
|
+
}
|
205
|
+
rule(:att => subtree(:t)) {
|
206
|
+
Value.new(t)
|
207
|
+
}
|
208
|
+
|
209
|
+
rule(:string => simple(:st)) {
|
210
|
+
st.to_s.gsub(/\\(.)/) { eval("\"\\" + $~[1] + '"') }
|
211
|
+
}
|
212
|
+
rule(:regex => simple(:re)) {
|
213
|
+
'/' + re.to_s.gsub(/\\(.)/) { eval("\"\\" + $~[1] + '"') } + '/'
|
214
|
+
}
|
215
|
+
|
216
|
+
rule(:text => simple(:te)) { te.to_s }
|
217
|
+
rule(:number => simple(:n)) { n.match(/[eE\.]/) ? Float(n) : Integer(n) }
|
218
|
+
rule(:false => simple(:b)) { false }
|
219
|
+
rule(:true => simple(:b)) { true }
|
220
|
+
rule(:null => simple(:n)) { nil }
|
221
|
+
|
222
|
+
rule(:array => subtree(:ar)) {
|
223
|
+
ar.is_a?(Array) ? ar : [ ar ]
|
224
|
+
}
|
225
|
+
rule(:object => subtree(:es)) {
|
226
|
+
(es.is_a?(Array) ? es : [ es ]).each_with_object({}) { |e, h|
|
227
|
+
e = e[:ent]; h[e[:key]] = e[:val]
|
228
|
+
}
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
#
|
233
|
+
# Some kind of "root container", to avoid having to deal with nils
|
234
|
+
# and making the parsing code more complicated (hopefully).
|
235
|
+
#
|
236
|
+
class PreRoot < Node
|
237
|
+
|
238
|
+
def initialize(first_line)
|
239
|
+
|
240
|
+
@first_line = first_line
|
241
|
+
|
242
|
+
@parent = nil
|
243
|
+
@indentation = -1
|
244
|
+
@children = []
|
245
|
+
end
|
246
|
+
|
247
|
+
def to_a
|
248
|
+
|
249
|
+
raise ArgumentError.new(
|
250
|
+
"couldn't parse process definition out of >#{@first_line}<"
|
251
|
+
) unless @children.first
|
252
|
+
|
253
|
+
@children.first.to_a
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
# Returns tree if s seems to contain a radial process definition
|
258
|
+
#
|
259
|
+
def self.understands?(s)
|
260
|
+
|
261
|
+
return false if s.match(/\n *end\b/)
|
262
|
+
return false if s.match(/\bRuote\.(process_definition|workflow_definition|define)\b/)
|
263
|
+
true
|
264
|
+
end
|
265
|
+
|
266
|
+
# The entry point : takes a radial string and returns, if possible,
|
267
|
+
# a ruote tree.
|
268
|
+
#
|
269
|
+
def self.read(s, opt=nil)
|
270
|
+
|
271
|
+
parser = Parser.new
|
272
|
+
transformer = Transformer.new
|
273
|
+
|
274
|
+
lines = parser.parse("\n#{s}\n")
|
275
|
+
nodes = transformer.apply(lines)
|
276
|
+
|
277
|
+
root = PreRoot.new("#{s.strip.split("\n").first}...")
|
278
|
+
current = root
|
279
|
+
|
280
|
+
nodes = [] unless nodes.is_a?(Array)
|
281
|
+
# force ArgumentError via empty PreRoot
|
282
|
+
|
283
|
+
nodes.each do |node|
|
284
|
+
|
285
|
+
parent = current
|
286
|
+
|
287
|
+
if node.indentation == current.indentation
|
288
|
+
parent = current.parent
|
289
|
+
elsif node.indentation < current.indentation
|
290
|
+
while node.indentation <= parent.indentation
|
291
|
+
parent = parent.parent
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
node.parent = parent
|
296
|
+
current = node
|
297
|
+
end
|
298
|
+
|
299
|
+
root.to_a
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|