weel 1.99.78 → 1.99.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ba66fd2448bc777292487140faac23d6f0fd00a264953dff4b16e302a6a9344
4
- data.tar.gz: 93a76802212618b1e5fb20dd29475ee671a2d5d53bc7595655b9a8d751332765
3
+ metadata.gz: b5a2078e30e109e2157cbf57097fb9397ef6c70be651ecd126921e2387a25e2e
4
+ data.tar.gz: b71439bf1e34769f65e708cbbc81b6c7304df708c1e1ba3ced934974624b6e0c
5
5
  SHA512:
6
- metadata.gz: 6a8773185c37a30e34a6f8712cd9c7ad41bd44f6a76bb99e7ab41839448846c1b8a3a4a1285700c913b6a5a2b169b4fe3e38be2e688fc3e42cd08e3dea9b41c6
7
- data.tar.gz: 243c9322426d3db3ee97d9e78cf9dd5f9221dab1c7206ce49a983406acf59bcc3f6275a4d95177d4ea9aa70d440a841ad1d8ff1d052fc52849daa65ec9431a75
6
+ metadata.gz: 68272ea7e69825b4c1aa7e4ba7ab570d9df41f82ff40c641d87beacfedca8e5e1bd53eb6885753c3f738bec921709ebf37ed44aff0d32cd9630fdb122143c35e
7
+ data.tar.gz: 4cbad38225d73f475669926c7aaa1ea645bdebdc235512ecd08a8c64ad8fd91599b846e276cdce2a30deea78d184503ea8da542fe6d66cba4447c00a215c5c3c
@@ -0,0 +1,35 @@
1
+ All code in this package is provided under the LGPL-3 license.
2
+ Please read the file COPYING.
3
+
4
+ Tested for MRI 2.6, 2.7
5
+
6
+ # Example Process (DSL)
7
+
8
+ ```ruby
9
+ class SimpleWorkflow < WEEL
10
+ handlerwrapper SimpleHandlerWrapper
11
+
12
+ endpoint :ep1 => "orf.at"
13
+ data :a => 17
14
+
15
+ control flow do
16
+ call :a1, :ep1, parameters: { :a => data.a, :b => 2 } do
17
+ data.a += 3
18
+ end
19
+ end
20
+ end
21
+ ```
22
+
23
+ HandlerWrappers are classes that implement communication protocols. Endpoints hold the communication targets and can be reused throughout the control flow. Data elements are control flow scoped variables.
24
+
25
+ Please check out the "example" directory to see a minimal set of necessary artefacts.
26
+
27
+ # Further Reading
28
+
29
+ For an evaluation and description of all available control flow statements, see https://arxiv.org/pdf/1003.3330.pdf.
30
+
31
+ # Installation
32
+
33
+ ```bash
34
+ gem install weel
35
+ ```
@@ -1,13 +1,13 @@
1
1
  # This file is part of WEEL.
2
- #
2
+ #
3
3
  # WEEL is free software: you can redistribute it and/or modify it under the terms
4
4
  # of the GNU General Public License as published by the Free Software Foundation,
5
5
  # either version 3 of the License, or (at your option) any later version.
6
- #
6
+ #
7
7
  # WEEL is distributed in the hope that it will be useful, but WITHOUT ANY
8
8
  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9
9
  # PARTICULAR PURPOSE. See the GNU General Public License for more details.
10
- #
10
+ #
11
11
  # You should have received a copy of the GNU General Public License along with
12
12
  # WEEL (file COPYING in the main directory). If not, see
13
13
  # <http://www.gnu.org/licenses/>.
@@ -15,14 +15,23 @@
15
15
  require "pp"
16
16
 
17
17
  class SimpleHandlerWrapper < WEEL::HandlerWrapperBase
18
- def initialize(args,endpoint=nil,position=nil,continue=nil)
18
+ def self::inform_state_change(arguments,newstate); puts "#{newstate}: #{arguments}"; end
19
+ def self::inform_syntax_error(arguments,err,code); puts "Syntax error: #{err}"; end
20
+ def self::inform_handlerwrapper_error(arguments,err); puts "Handlerwrapper error: #{err}"; end
21
+
22
+ def initialize(args,position=nil,continue=nil)
19
23
  @__myhandler_stopped = false
20
24
  @__myhandler_position = position
21
25
  @__myhandler_continue = continue
22
- @__myhandler_endpoint = endpoint
26
+ @__myhandler_endpoint = nil
23
27
  @__myhandler_returnValue = nil
24
28
  end
25
29
 
30
+ def prepare(readonly, endpoints, parameters, replay=false)
31
+ @__myhandler_endpoints = endpoints
32
+ parameters
33
+ end
34
+
26
35
  # executes a ws-call to the given endpoint with the given parameters. the call
27
36
  # can be executed asynchron, see finished_call & return_value
28
37
  def activity_handle(passthrough, parameters)
@@ -35,7 +44,7 @@ class SimpleHandlerWrapper < WEEL::HandlerWrapperBase
35
44
  @__myhandler_returnValue = 'Handler_Dummy_Result'
36
45
  @__myhandler_continue.continue
37
46
  end
38
-
47
+
39
48
  # returns the result of the last handled call
40
49
  def activity_result_value
41
50
  @__myhandler_returnValue
@@ -1,13 +1,13 @@
1
1
  # This file is part of WEEL.
2
- #
2
+ #
3
3
  # WEEL is free software: you can redistribute it and/or modify it under the terms
4
4
  # of the GNU General Public License as published by the Free Software Foundation,
5
5
  # either version 3 of the License, or (at your option) any later version.
6
- #
6
+ #
7
7
  # WEEL is distributed in the hope that it will be useful, but WITHOUT ANY
8
8
  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9
9
  # PARTICULAR PURPOSE. See the GNU General Public License for more details.
10
- #
10
+ #
11
11
  # You should have received a copy of the GNU General Public License along with
12
12
  # WEEL (file COPYING in the main directory). If not, see
13
13
  # <http://www.gnu.org/licenses/>.
@@ -17,12 +17,12 @@ require ::File.dirname(__FILE__) + '/SimpleHandlerWrapper'
17
17
 
18
18
  class SimpleWorkflow < WEEL
19
19
  handlerwrapper SimpleHandlerWrapper
20
-
20
+
21
21
  endpoint :ep1 => "orf.at"
22
22
  data :a => 17
23
23
 
24
24
  control flow do
25
- activity :a1, :call, :ep1, :a => data.a, :b => 2 do
25
+ call :a1, :ep1, parameters: { :a => data.a, :b => 2 } do
26
26
  data.a += 3
27
27
  end
28
28
  end
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This file is part of WEEL.
3
- #
3
+ #
4
4
  # WEEL is free software: you can redistribute it and/or modify it under the terms
5
5
  # of the GNU General Public License as published by the Free Software Foundation,
6
6
  # either version 3 of the License, or (at your option) any later version.
7
- #
7
+ #
8
8
  # WEEL is distributed in the hope that it will be useful, but WITHOUT ANY
9
9
  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
10
10
  # PARTICULAR PURPOSE. See the GNU General Public License for more details.
11
- #
11
+ #
12
12
  # You should have received a copy of the GNU General Public License along with
13
13
  # WEEL (file COPYING in the main directory). If not, see
14
14
  # <http://www.gnu.org/licenses/>.
@@ -40,33 +40,43 @@ class WEEL
40
40
  class Salvage < Exception; end
41
41
  end # }}}
42
42
 
43
- class ReadStructure # {{{
44
- def initialize(data,endpoints)
45
- @__weel_data = data.dup
46
- @__weel_data.transform_values! do |v|
47
- if v.is_a? XML::Smart::Dom
48
- v.root.to_doc
49
- else
43
+ class ReadStructure # {{{
44
+ def initialize(data,endpoints,additional)
45
+ @__weel_data = data.dup
46
+ @__weel_data.transform_values! do |v|
47
+ if Object.const_defined?(:XML) && XML.const_defined?(:Smart) && v.is_a?(XML::Smart::Dom)
48
+ v.root.to_doc
49
+ else
50
+ begin
51
+ Marshal.load(Marshal.dump(v))
52
+ rescue
53
+ v.to_s rescue nil
54
+ end
55
+ end
56
+ end
57
+ @__weel_endpoints = endpoints.dup
58
+ @__weel_endpoints.transform_values!{ |v| v.dup }
59
+ @additional = additional
60
+ end
61
+
62
+ def method_missing(m,args,&block)
63
+ if @additional.exists?(m)
50
64
  begin
51
- Marshal.load(Marshal.dump(v))
65
+ Marshal.load(Marshal.dump(@aditional[m]))
52
66
  rescue
53
67
  v.to_s rescue nil
54
68
  end
55
69
  end
56
70
  end
57
- @__weel_endpoints = endpoints.dup
58
- @__weel_endpoints.transform_values!{ |v| v.dup }
59
- end
60
-
61
- def data
62
- ReadHash.new(@__weel_data)
63
- end
64
- def endpoints
65
- ReadHash.new(@__weel_endpoints)
66
- end
67
- end # }}}
71
+ def data
72
+ ReadHash.new(@__weel_data)
73
+ end
74
+ def endpoints
75
+ ReadHash.new(@__weel_endpoints)
76
+ end
77
+ end # }}}
68
78
  class ManipulateStructure # {{{
69
- def initialize(data,endpoints,status)
79
+ def initialize(data,endpoints,status,additional)
70
80
  @__weel_data = data
71
81
  @__weel_data_orig = @__weel_data.transform_values{|val| Marshal.dump(val) } rescue nil
72
82
  @__weel_endpoints = endpoints
@@ -77,6 +87,17 @@ end # }}}
77
87
  @touched_data = []
78
88
  @changed_endpoints = []
79
89
  @touched_endpoints = []
90
+ @additional = additional
91
+ end
92
+
93
+ def method_missing(m,args,&block)
94
+ if @additional.exists?(m)
95
+ begin
96
+ Marshal.load(Marshal.dump(@aditional[m]))
97
+ rescue
98
+ v.to_s rescue nil
99
+ end
100
+ end
80
101
  end
81
102
 
82
103
  def changed_data
@@ -209,17 +230,18 @@ end # }}}
209
230
  def self::inform_state_change(arguments,newstate); end
210
231
  def self::inform_syntax_error(arguments,err,code); end
211
232
  def self::inform_handlerwrapper_error(arguments,err); end
212
- def self::inform_position_change(arguments,ipc); end
213
- def self::modify_position_details(arguments); end
233
+ def self::inform_position_change(arguments,ipc={}); end
214
234
 
215
- def initialize(arguments,endpoint=nil,position=nil,continue=nil); end
235
+ def initialize(arguments,position=nil,continue=nil); end
216
236
 
217
- def prepare(readonly, endpoints, parameters); parameters; end
237
+ def prepare(readonly, endpoints, parameters, replay=false); parameters; end
238
+ def additional; {}; end
218
239
 
219
240
  def activity_handle(passthrough, parameters); end
220
241
  def activity_manipulate_handle(parameters); end
221
242
 
222
243
  def activity_result_value; end
244
+ def activity_result_options; end
223
245
 
224
246
  def activity_stop; end
225
247
  def activity_passthrough_value; end
@@ -288,7 +310,7 @@ end # }}}
288
310
  end
289
311
  end #}}}
290
312
 
291
- def self::search(weel_search)# {{{
313
+ def self::search(*weel_search)# {{{
292
314
  define_method :initialize_search do
293
315
  self.search weel_search
294
316
  end
@@ -338,9 +360,10 @@ end # }}}
338
360
  @__weel_handlerwrapper_args = []
339
361
  @__weel_state = :ready
340
362
  @__weel_status = Status.new(0,"undefined")
363
+ @__weel_replay = false
341
364
  @__weel_sim = -1
342
365
  end #}}}
343
- attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_handlerwrapper, :__weel_handlerwrapper_args
366
+ attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_handlerwrapper, :__weel_handlerwrapper_args, :__weel_replay
344
367
  attr_reader :__weel_state, :__weel_status
345
368
 
346
369
  # DSL-Constructs for atomic calls to external services (calls) and pure context manipulations (manipulate).
@@ -363,8 +386,8 @@ end # }}}
363
386
  # Parallel DSL-Construct
364
387
  # Defines Workflow paths that can be executed parallel.
365
388
  # May contain multiple branches (parallel_branch)
366
- def parallel(type=nil)# {{{
367
- return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
389
+ def parallel(type=nil,&block)# {{{
390
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
368
391
 
369
392
  Thread.current[:branches] = []
370
393
  Thread.current[:branch_finished_count] = 0
@@ -373,7 +396,7 @@ end # }}}
373
396
 
374
397
  hw, pos = __weel_sim_start(:parallel) if __weel_sim
375
398
 
376
- __weel_protect_yield(&Proc.new)
399
+ __weel_protect_yield(&block)
377
400
 
378
401
  Thread.current[:branch_wait_count] = (type.is_a?(Hash) && type.size == 1 && type[:wait] != nil && (type[:wait].is_a?(Integer) && type[:wait] > 0) ? type[:wait] : Thread.current[:branches].size)
379
402
  1.upto Thread.current[:branches].size do
@@ -386,10 +409,10 @@ end # }}}
386
409
  if Thread.current[:branch_search] == false
387
410
  thread[:branch_search] = false
388
411
  end
389
- thread[:start_event].continue
412
+ thread[:start_event]&.continue # sometimes start event might not even exist yet (i.e. race condition)
390
413
  end
391
414
 
392
- Thread.current[:branch_event].wait
415
+ Thread.current[:branch_event].wait unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
393
416
 
394
417
  __weel_sim_stop(:parallel,hw,pos) if __weel_sim
395
418
 
@@ -409,7 +432,7 @@ end # }}}
409
432
  end # }}}
410
433
 
411
434
  # Defines a branch of a parallel-Construct
412
- def parallel_branch(*vars)# {{{
435
+ def parallel_branch(*vars,&block)# {{{
413
436
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
414
437
  branch_parent = Thread.current
415
438
 
@@ -435,14 +458,16 @@ end # }}}
435
458
  Thread.current[:alternative_mode] = [branch_parent[:alternative_mode].last]
436
459
  end
437
460
  branch_parent[:branch_event].continue
438
- Thread.current[:start_event].wait
461
+ Thread.current[:start_event].wait unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
439
462
 
440
463
  if __weel_sim
441
464
  handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args
442
465
  handlerwrapper.simulate(:parallel_branch,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos)
443
466
  end
444
467
 
445
- __weel_protect_yield(*local, &Proc.new)
468
+ unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
469
+ __weel_protect_yield(*local, &block)
470
+ end
446
471
 
447
472
  __weel_sim_stop(:parallel_branch,handlerwrapper,current_branch_sim_pos) if __weel_sim
448
473
 
@@ -453,7 +478,7 @@ end # }}}
453
478
  branch_parent[:branch_event].continue
454
479
  end
455
480
  end
456
- if self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
481
+ unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
457
482
  if Thread.current[:branch_position]
458
483
  @__weel_positions.delete Thread.current[:branch_position]
459
484
  begin
@@ -470,14 +495,14 @@ end # }}}
470
495
  # Choose DSL-Construct
471
496
  # Defines a choice in the Workflow path.
472
497
  # May contain multiple execution alternatives
473
- def choose(mode=:inclusive) # {{{
498
+ def choose(mode=:inclusive,&block) # {{{
474
499
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
475
500
  Thread.current[:alternative_executed] ||= []
476
501
  Thread.current[:alternative_mode] ||= []
477
502
  Thread.current[:alternative_executed] << false
478
503
  Thread.current[:alternative_mode] << mode
479
504
  hw, pos = __weel_sim_start(:choose,:mode => Thread.current[:alternative_mode].last) if __weel_sim
480
- __weel_protect_yield(&Proc.new)
505
+ __weel_protect_yield(&block)
481
506
  __weel_sim_stop(:choose,hw,pos,:mode => Thread.current[:alternative_mode].last) if __weel_sim
482
507
  Thread.current[:alternative_executed].pop
483
508
  Thread.current[:alternative_mode].pop
@@ -487,7 +512,7 @@ end # }}}
487
512
  # Defines a possible choice of a choose-Construct
488
513
  # Block is executed if condition == true or
489
514
  # searchmode is active (to find the starting position)
490
- def alternative(condition,args={})# {{{
515
+ def alternative(condition,args={},&block)# {{{
491
516
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
492
517
  hw, pos = __weel_sim_start(:alternative,args.merge(:mode => Thread.current[:alternative_mode].last, :condition => ((condition.is_a?(String) || condition.is_a?(Proc)) ? condition : nil))) if __weel_sim
493
518
  Thread.current[:mutex] ||= Mutex.new
@@ -498,18 +523,18 @@ end # }}}
498
523
  end
499
524
  Thread.current[:alternative_executed][-1] = true if condition
500
525
  end
501
- __weel_protect_yield(&Proc.new) if __weel_is_in_search_mode || __weel_sim || condition
526
+ __weel_protect_yield(&block) if __weel_is_in_search_mode || __weel_sim || condition
502
527
  __weel_sim_stop(:alternative,hw,pos,args.merge(:mode => Thread.current[:alternative_mode].last, :condition => ((condition.is_a?(String) || condition.is_a?(Proc)) ? condition : nil))) if __weel_sim
503
528
  end # }}}
504
- def otherwise(args={}) # {{{
529
+ def otherwise(args={},&block) # {{{
505
530
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
506
531
  hw, pos = __weel_sim_start(:otherwise,args.merge(:mode => Thread.current[:alternative_mode].last)) if __weel_sim
507
- __weel_protect_yield(&Proc.new) if __weel_is_in_search_mode || __weel_sim || !Thread.current[:alternative_executed].last
532
+ __weel_protect_yield(&block) if __weel_is_in_search_mode || __weel_sim || !Thread.current[:alternative_executed].last
508
533
  __weel_sim_stop(:otherwise,hw,pos,args.merge(:mode => Thread.current[:alternative_mode].last)) if __weel_sim
509
534
  end # }}}
510
535
 
511
536
  # Defines a critical block (=Mutex)
512
- def critical(id)# {{{
537
+ def critical(id,&block)# {{{
513
538
  @__weel_critical ||= Mutex.new
514
539
  semaphore = nil
515
540
  @__weel_critical.synchronize do
@@ -518,19 +543,19 @@ end # }}}
518
543
  @__weel_critical_sections[id] = semaphore if id
519
544
  end
520
545
  semaphore.synchronize do
521
- __weel_protect_yield(&Proc.new)
546
+ __weel_protect_yield(&block)
522
547
  end
523
548
  end # }}}
524
549
 
525
550
  # Defines a Cycle (loop/iteration)
526
- def loop(condition,args={})# {{{
551
+ def loop(condition,args={},&block)# {{{
527
552
  unless condition.is_a?(Array) && (condition[0].is_a?(Proc) || condition[0].is_a?(String)) && [:pre_test,:post_test].include?(condition[1]) && args.is_a?(Hash)
528
553
  raise "condition must be called pre_test{} or post_test{}"
529
554
  end
530
555
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
531
556
  if __weel_is_in_search_mode
532
557
  catch :escape do
533
- __weel_protect_yield(&Proc.new)
558
+ __weel_protect_yield(&block)
534
559
  end
535
560
  if __weel_is_in_search_mode
536
561
  return
@@ -544,7 +569,7 @@ end # }}}
544
569
  cond = condition[0].is_a?(Proc) ? true : condition[0]
545
570
  hw, pos = __weel_sim_start(:loop,args.merge(:testing=>condition[1],:condition=>cond))
546
571
  catch :escape do
547
- __weel_protect_yield(&Proc.new)
572
+ __weel_protect_yield(&block)
548
573
  end
549
574
  __weel_sim_stop(:loop,hw,pos,args.merge(:testing=>condition[1],:condition=>cond))
550
575
  return
@@ -553,11 +578,11 @@ end # }}}
553
578
  case condition[1]
554
579
  when :pre_test
555
580
  while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
556
- __weel_protect_yield(&Proc.new)
581
+ __weel_protect_yield(&block)
557
582
  end
558
583
  when :post_test
559
584
  begin
560
- __weel_protect_yield(&Proc.new)
585
+ __weel_protect_yield(&block)
561
586
  end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
562
587
  end
563
588
  end
@@ -619,7 +644,7 @@ end # }}}
619
644
  def __weel_eval_condition(condition) #{{{
620
645
  begin
621
646
  handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args unless condition.is_a?(Proc)
622
- condition.is_a?(Proc) ? condition.call : handlerwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints),condition)
647
+ condition.is_a?(Proc) ? condition.call : handlerwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional),condition)
623
648
  rescue NameError => err # don't look into it, or it will explode
624
649
  # if you access $! here, BOOOM
625
650
  self.__weel_state = :stopping
@@ -688,10 +713,10 @@ end # }}}
688
713
  handlerwrapper.activity_manipulate_handle(parameters)
689
714
  handlerwrapper.inform_activity_manipulate
690
715
  if finalize.is_a?(Proc)
691
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
716
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
692
717
  mr.instance_eval(&finalize)
693
718
  elsif finalize.is_a?(String)
694
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
719
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
695
720
  handlerwrapper.manipulate(mr,finalize)
696
721
  end
697
722
  handlerwrapper.inform_manipulate_change(
@@ -708,15 +733,15 @@ end # }}}
708
733
  when :call
709
734
  begin
710
735
  again = catch Signal::Again do
711
- rs = ReadStructure.new(@__weel_data,@__weel_endpoints)
736
+ rs = ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional)
712
737
  if prepare
713
738
  if prepare.is_a?(Proc)
714
- rs.instance_exec &prepare
739
+ rs.instance_exec(&prepare)
715
740
  elsif prepare.is_a?(String)
716
741
  rs.instance_eval prepare
717
742
  end
718
743
  end
719
- params = handlerwrapper.prepare(rs,endpoint,parameters)
744
+ params = handlerwrapper.prepare(rs,endpoint,parameters,@__weel_replay)
720
745
  raise Signal::Stop unless handlerwrapper.vote_sync_before(params)
721
746
  raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
722
747
 
@@ -726,7 +751,6 @@ end # }}}
726
751
  else
727
752
  passthrough = nil
728
753
  end
729
-
730
754
  handlerwrapper.activity_handle passthrough, params
731
755
  wp.passthrough = handlerwrapper.activity_passthrough_value
732
756
  unless wp.passthrough.nil?
@@ -759,18 +783,18 @@ end # }}}
759
783
  if code.is_a?(Proc) || code.is_a?(String)
760
784
  handlerwrapper.inform_activity_manipulate
761
785
  if code.is_a?(Proc)
762
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
763
- case code.arity
764
- when 1; mr.instance_exec(handlerwrapper.activity_result_value,&code)
765
- when 2; mr.instance_exec(handlerwrapper.activity_result_value,&code)
766
- else
767
- ma = catch Signal::Again do
786
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
787
+ ma = catch Signal::Again do
788
+ case code.arity
789
+ when 1; mr.instance_exec(handlerwrapper.activity_result_value,&code)
790
+ when 2; mr.instance_exec(handlerwrapper.activity_result_value,&code)
791
+ else
768
792
  mr.instance_exec(&code)
769
- 'yes' # ma sadly will have nil when i just throw
770
- end
793
+ end
794
+ 'yes' # ma sadly will have nil when i just throw
771
795
  end
772
796
  elsif code.is_a?(String)
773
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
797
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
774
798
  ma = catch Signal::Again do
775
799
  handlerwrapper.manipulate(mr,code,handlerwrapper.activity_result_value,handlerwrapper.activity_result_options)
776
800
  'yes' # ma sadly will have nil when i just throw
@@ -814,7 +838,7 @@ end # }}}
814
838
  handlerwrapper.inform_activity_failed se
815
839
  self.__weel_state = :stopping
816
840
  rescue => err
817
- handlerwrapper.inform_activity_failed err
841
+ @__weel_handlerwrapper::inform_handlerwrapper_error @__weel_handlerwrapper_args, err
818
842
  self.__weel_state = :stopping
819
843
  ensure
820
844
  Thread.current[:continue].clear if Thread.current[:continue] && Thread.current[:continue].is_a?(Continue)
@@ -915,6 +939,7 @@ end # }}}
915
939
  if newState == :stopping || newState == :finishing
916
940
  @__weel_status.nudge!
917
941
  __weel_recursive_continue(@__weel_main)
942
+ __weel_replay = false
918
943
  end
919
944
 
920
945
  @__weel_handlerwrapper::inform_state_change @__weel_handlerwrapper_args, @__weel_state
@@ -1067,6 +1092,11 @@ public
1067
1092
  end
1068
1093
  end # }}}
1069
1094
 
1095
+ def replay
1096
+ @dslr.__weel_replay = true
1097
+ start
1098
+ end
1099
+
1070
1100
  def sim # {{{
1071
1101
  stat = @dslr.__weel_state
1072
1102
  return nil unless stat == :ready || stat == :stopped
@@ -8,16 +8,24 @@ class TestHandlerWrapper < WEEL::HandlerWrapperBase
8
8
  $short_track << "E"
9
9
  raise(err)
10
10
  end
11
+ def self::inform_handlerwrapper_error(arguments,err)
12
+ $long_track += "HW ERROR: #{err}\n"
13
+ $short_track << "E"
14
+ end
11
15
 
12
- def initialize(args,endpoint=nil,position=nil,continue=nil)
16
+ def initialize(args,position=nil,continue=nil)
13
17
  @__myhandler_stopped = false
14
18
  @__myhandler_position = position
15
19
  @__myhandler_continue = continue
16
- @__myhandler_endpoint = endpoint
17
20
  @__myhandler_returnValue = nil
18
21
  @t = nil
19
22
  end
20
23
 
24
+ def prepare(readonly, endpoints, parameters, replay=false)
25
+ @__myhandler_endpoint = readonly.endpoints[endpoints]
26
+ parameters
27
+ end
28
+
21
29
  # executes a ws-call to the given endpoint with the given parameters. the call
22
30
  # can be executed asynchron, see finished_call & return_value
23
31
  def activity_handle(passthrough, parameters) #{{{
@@ -68,7 +76,7 @@ class TestHandlerWrapper < WEEL::HandlerWrapperBase
68
76
  # information about how to continue the call. This passthrough-value is given
69
77
  # to activity_handle if the workflow is configured to do so.
70
78
  def activity_passthrough_value #{{{
71
- "SOME passthrough"
79
+ nil
72
80
  end #}}}
73
81
 
74
82
  # Called if the execution of the actual activity_handle is not necessary anymore
@@ -14,14 +14,14 @@ module SimTestMixin #{{{
14
14
  def wf_assert(what,cond=true)
15
15
  if cond
16
16
  assert($long_track.include?(what),"Missing \"#{what}\":\n#{$long_track}")
17
- else
17
+ else
18
18
  assert(!$long_track.include?(what),"Missing \"#{what}\":\n#{$long_track}")
19
19
  end
20
20
  end
21
21
  def wf_sassert(what,cond=true)
22
22
  if cond
23
23
  assert($short_track.include?(what),"#{$short_track}\nNot Present \"#{what}\":\n#{$long_track}")
24
- else
24
+ else
25
25
  assert(!$short_track.include?(what),"#{$short_track}\nNot Present \"#{what}\":\n#{$long_track}")
26
26
  end
27
27
  end
@@ -30,7 +30,6 @@ module SimTestMixin #{{{
30
30
  end
31
31
  end #}}}
32
32
 
33
-
34
33
  module TestMixin #{{{
35
34
  def setup
36
35
  $long_track = ""
@@ -47,14 +46,14 @@ module TestMixin #{{{
47
46
  def wf_assert(what,cond=true)
48
47
  if cond
49
48
  assert($long_track.include?(what),"Missing \"#{what}\":\n#{$long_track}")
50
- else
49
+ else
51
50
  assert(!$long_track.include?(what),"Missing \"#{what}\":\n#{$long_track}")
52
51
  end
53
52
  end
54
53
  def wf_sassert(what,cond=true)
55
54
  if cond
56
55
  assert($short_track.include?(what),"#{$short_track}\nNot Present \"#{what}\":\n#{$long_track}")
57
- else
56
+ else
58
57
  assert(!$short_track.include?(what),"#{$short_track}\nNot Present \"#{what}\":\n#{$long_track}")
59
58
  end
60
59
  end
@@ -9,12 +9,12 @@ class TestWorkflow < WEEL
9
9
  endpoint :stop => 'stop it'
10
10
  endpoint :again => 'again'
11
11
  data :x => 'begin_'
12
-
12
+
13
13
  control flow do
14
14
  call :a1_1, :endpoint1 do |result|
15
15
  data.x += "#{result}"
16
16
  end
17
- parallel :wait => 2 do
17
+ parallel :wait do
18
18
  parallel_branch do
19
19
  call :a2_1_1, :endpoint1
20
20
  end
@@ -24,59 +24,59 @@ class TestChoose < Test::Unit::TestCase
24
24
  wf_assert("CALL a_3:",false)
25
25
  end
26
26
 
27
- def test_choose_otherwise
28
- @wf.description do
29
- choose do
30
- alternative false do
31
- call :a_1, :endpoint1
32
- end
33
- otherwise do
34
- call :a_2, :endpoint1
35
- end
36
- end
37
- end
38
- @wf.start.join
39
- wf_assert("CALL a_2: passthrough=[], endpoint=[http://www.heise.de], parameters=[{}]")
40
- wf_assert("CALL a_1:",false)
41
- end
27
+ # def test_choose_otherwise
28
+ # @wf.description do
29
+ # choose do
30
+ # alternative false do
31
+ # call :a_1, :endpoint1
32
+ # end
33
+ # otherwise do
34
+ # call :a_2, :endpoint1
35
+ # end
36
+ # end
37
+ # end
38
+ # @wf.start.join
39
+ # wf_assert("CALL a_2: passthrough=[], endpoint=[http://www.heise.de], parameters=[{}]")
40
+ # wf_assert("CALL a_1:",false)
41
+ # end
42
42
 
43
- def test_choose_nested
44
- @wf.description do
45
- choose do
46
- alternative true do
47
- choose do
48
- alternative false do
49
- call :a_1_1, :endpoint1
50
- end
51
- alternative true do
52
- choose do
53
- alternative false do
54
- call :a_1_1_1, :endpoint1
55
- end
56
- otherwise do
57
- call :a_1_1_2, :endpoint1
58
- end
59
- end
60
- end
61
- otherwise do
62
- call :a_1_3, :endpoint1
63
- end
64
- end
65
- end
66
- otherwise do
67
- call :a_2, :endpoint1
68
- end
69
- end
70
- end
71
- @wf.start.join
72
- wf_assert("CALL a_1_1_2: passthrough=[], endpoint=[http://www.heise.de], parameters=[{}]",true)
73
- wf_assert("CALL a_1_1:",false)
74
- wf_assert("CALL a_1_1_1:",false)
75
- wf_assert("CALL a_1_3:",false)
76
- wf_assert("CALL a_2:",false)
77
- end
43
+ # def test_choose_nested
44
+ # @wf.description do
45
+ # choose do
46
+ # alternative true do
47
+ # choose do
48
+ # alternative false do
49
+ # call :a_1_1, :endpoint1
50
+ # end
51
+ # alternative true do
52
+ # choose do
53
+ # alternative false do
54
+ # call :a_1_1_1, :endpoint1
55
+ # end
56
+ # otherwise do
57
+ # call :a_1_1_2, :endpoint1
58
+ # end
59
+ # end
60
+ # end
61
+ # otherwise do
62
+ # call :a_1_3, :endpoint1
63
+ # end
64
+ # end
65
+ # end
66
+ # otherwise do
67
+ # call :a_2, :endpoint1
68
+ # end
69
+ # end
70
+ # end
71
+ # @wf.start.join
72
+ # wf_assert("CALL a_1_1_2: passthrough=[], endpoint=[http://www.heise.de], parameters=[{}]",true)
73
+ # wf_assert("CALL a_1_1:",false)
74
+ # wf_assert("CALL a_1_1_1:",false)
75
+ # wf_assert("CALL a_1_3:",false)
76
+ # wf_assert("CALL a_2:",false)
77
+ # end
78
78
 
79
- def test_choose_searchmode
80
-
81
- end
79
+ # def test_choose_searchmode
80
+
81
+ # end
82
82
  end
@@ -4,11 +4,11 @@ require File.expand_path(::File.dirname(__FILE__) + '/../TestWorkflow')
4
4
  class TestState < Test::Unit::TestCase
5
5
  include TestMixin
6
6
 
7
- def test_check_state
8
- s = @wf.state
9
- assert(s.is_a?(Symbol), "state is not a symbol")
10
- assert(s == :ready, "state is not set to :ready, it is #{s}")
11
- end
7
+ # def test_check_state
8
+ # s = @wf.state
9
+ # assert(s.is_a?(Symbol), "state is not a symbol")
10
+ # assert(s == :ready, "state is not set to :ready, it is #{s}")
11
+ # end
12
12
 
13
13
  def test_check_stop_state
14
14
  @wf.start
@@ -18,51 +18,51 @@ class TestWorkflowControl < Test::Unit::TestCase
18
18
  assert(@wf.data[:x] == "begin_Handler_Dummy_Result_end", "Ending environment not correct, see result=#{@wf.data[:x].inspect}")
19
19
  end
20
20
 
21
- def test_stop
22
- @wf.description do
23
- call :a_test_1_1, :endpoint1
24
- call :a_test_1_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
25
- call :a_test_1_3, :endpoint1
26
- end
27
- @wf.search WEEL::Position.new(:a_test_1_1, :at)
28
- wf = @wf.start
29
- sleep(0.2)
30
- @wf.stop.join
31
- wf.join
32
- wf_assert("DONE a_test_1_1")
33
- wf_assert("STOPPED a_test_1_2")
34
- wf_assert("DONE a_test_1_2",false)
35
- wf_assert("CALL a_test_1_2:")
36
- assert(@wf.state == :stopped, "Stopped workflow has wrong state, #{@wf.state} instead of :stopped")
37
- assert(@wf.positions.is_a?(Array), "@wf.positions has wrong type, should be an array, it is: #{@wf.positions.inspect}")
38
- assert(@wf.positions[0].position == :a_test_1_2, "Stop-position has wrong value: #{@wf.positions[0].position} instead of :a_test_2_1")
39
- assert(@wf.positions[0].detail == :at, "Stop-Position is not :at")
40
- end
41
- def test_continue
42
- @wf.description do
43
- call :a_test_1_1, :endpoint1
44
- call :a_test_1_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
45
- call :a_test_1_3, :endpoint1
46
- end
47
- @wf.start
48
- sleep(0.2)
49
- @wf.stop.join
21
+ # def test_stop
22
+ # @wf.description do
23
+ # call :a_test_1_1, :endpoint1
24
+ # call :a_test_1_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
25
+ # call :a_test_1_3, :endpoint1
26
+ # end
27
+ # @wf.search WEEL::Position.new(:a_test_1_1, :at)
28
+ # wf = @wf.start
29
+ # sleep(0.2)
30
+ # @wf.stop.join
31
+ # wf.join
32
+ # wf_assert("DONE a_test_1_1")
33
+ # wf_assert("STOPPED a_test_1_2")
34
+ # wf_assert("DONE a_test_1_2",false)
35
+ # wf_assert("CALL a_test_1_2:")
36
+ # assert(@wf.state == :stopped, "Stopped workflow has wrong state, #{@wf.state} instead of :stopped")
37
+ # assert(@wf.positions.is_a?(Array), "@wf.positions has wrong type, should be an array, it is: #{@wf.positions.inspect}")
38
+ # assert(@wf.positions[0].position == :a_test_1_2, "Stop-position has wrong value: #{@wf.positions[0].position} instead of :a_test_2_1")
39
+ # assert(@wf.positions[0].detail == :at, "Stop-Position is not :at")
40
+ # end
41
+ # def test_continue
42
+ # @wf.description do
43
+ # call :a_test_1_1, :endpoint1
44
+ # call :a_test_1_2, :endpoint1, parameters: { :call => Proc.new{ sleep 0.5 } }
45
+ # call :a_test_1_3, :endpoint1
46
+ # end
47
+ # @wf.start
48
+ # sleep(0.2)
49
+ # @wf.stop.join
50
50
 
51
- @wf.search @wf.positions
51
+ # @wf.search @wf.positions
52
52
 
53
- @wf.start.join
54
- wf_sassert('|running|Ca_test_1_1Da_test_1_1Ca_test_1_2|stopping|Sa_test_1_2|stopped||running|Ca_test_1_2Da_test_1_2Ca_test_1_3Da_test_1_3|finished|')
55
- end
56
-
57
- def test_continue_after
58
- @wf.description do
59
- call :c_test_1_1, :endpoint1
60
- call :c_test_1_2, :endpoint1
61
- call :c_test_1_3, :endpoint1
62
- end
63
- @wf.search [WEEL::Position.new(:c_test_1_1, :after)]
64
- @wf.start.join
53
+ # @wf.start.join
54
+ # wf_sassert('|running|Ca_test_1_1Da_test_1_1Ca_test_1_2|stopping|Sa_test_1_2|stopped||running|Ca_test_1_2Da_test_1_2Ca_test_1_3Da_test_1_3|finished|')
55
+ # end
65
56
 
66
- wf_sassert('|running|Cc_test_1_2Dc_test_1_2Cc_test_1_3Dc_test_1_3|finished|')
67
- end
57
+ # def test_continue_after
58
+ # @wf.description do
59
+ # call :c_test_1_1, :endpoint1
60
+ # call :c_test_1_2, :endpoint1
61
+ # call :c_test_1_3, :endpoint1
62
+ # end
63
+ # @wf.search [WEEL::Position.new(:c_test_1_1, :after)]
64
+ # @wf.start.join
65
+
66
+ # wf_sassert('|running|Cc_test_1_2Dc_test_1_2Cc_test_1_3Dc_test_1_3|finished|')
67
+ # end
68
68
  end
@@ -6,7 +6,7 @@ class TestAdventureSearch < Test::Unit::TestCase
6
6
 
7
7
  def test_search_adventure
8
8
  @wf.data[:oee] = 0.25
9
- @wf.description = File.read(::File.dirname(__FILE__) + '/dsl1')
9
+ @wf.description = File.read(__dir__ + '/dsl1')
10
10
  @wf.search [WEEL::Position.new(:a2, :at), WEEL::Position.new(:a13, :at)]
11
11
  @wf.start.join
12
12
 
@@ -0,0 +1,39 @@
1
+ ruby basic/tc_choose.rb
2
+ ruby basic/tc_codereplace.rb
3
+ ruby basic/tc_data.rb
4
+ ruby basic/tc_endpoint.rb
5
+ ruby basic/tc_handler.rb
6
+ ruby basic/tc_parallel.rb
7
+ ruby basic/tc_search.rb
8
+ ruby basic/tc_state.rb
9
+ ruby basic/tc_wf_control.rb
10
+ ruby complexsearch/tc_search.rb
11
+ ruby complex/tc_generalsynchonizingmerge_loopsearch.rb
12
+ ruby complex/tc_parallel_stop.rb
13
+ ruby exec/tc_again.rb
14
+ ruby exec/tc_exec.rb
15
+ ruby simulation/dl.rb
16
+ ruby simulation/tt_permutationtester.rb
17
+ ruby simulation/tt_sim_activity.rb
18
+ ruby simulation/tt_sim_choose1.rb
19
+ ruby simulation/tt_sim_choose2.rb
20
+ ruby simulation/tt_sim_loop_parallel_choose.rb
21
+ ruby simulation/tt_sim_loop_parallel.rb
22
+ ruby simulation/tt_sim_loop.rb
23
+ ruby speed/tc_speed1.rb
24
+ ruby speed/tc_speed2.rb
25
+ ruby wfp_adv_branching/tc_generalizedjoin.rb
26
+ ruby wfp_adv_branching/tc_generalsynchronizingmerge.rb
27
+ ruby wfp_adv_branching/tc_localsynchronizingmerge.rb
28
+ ruby wfp_adv_branching/tc_multichoice_structuredsynchronizingmerge.rb
29
+ ruby wfp_adv_branching/tc_multimerge.rb
30
+ ruby wfp_adv_branching/tc_structured_discriminator.rb
31
+ ruby wfp_adv_branching/tc_structured_partial_join.rb
32
+ ruby wfp_adv_branching/tc_threadmerge.rb
33
+ ruby wfp_adv_branching/tc_threadsplit.rb
34
+ ruby wfp_basic/tc_exclusivechoice_simplemerge.rb
35
+ ruby wfp_basic/tc_parallelsplit_synchronization.rb
36
+ ruby wfp_basic/tc_sequence.rb
37
+ ruby wfp_iteration/tc_structuredloop.rb
38
+ ruby wfp_state_based/tc_deferredchoice.rb
39
+ ruby wfp_state_based/tc_interleavedparallelrouting.rb
@@ -1,17 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "weel"
3
- s.version = "1.99.78"
3
+ s.version = "1.99.84"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
- s.summary = "Preliminary release of the Workflow Execution Engine Library (WEEL)"
6
+ s.summary = "Workflow Execution Engine Library (WEEL)"
7
7
 
8
8
  s.description = "see http://cpee.org"
9
9
 
10
- s.required_ruby_version = '>=2.3.0'
10
+ s.required_ruby_version = '>=2.5.0'
11
11
 
12
- s.files = Dir['{example/**/*,lib/weel.rb}'] + %w(COPYING Changelog FEATURES INSTALL Rakefile weel.gemspec README AUTHORS)
12
+ s.files = Dir['{example/**/*,lib/weel.rb}'] + %w(COPYING Changelog FEATURES INSTALL Rakefile weel.gemspec README.md AUTHORS)
13
13
  s.require_path = 'lib'
14
- s.extra_rdoc_files = ['README']
14
+ s.extra_rdoc_files = ['README.md']
15
15
  s.test_files = Dir['{test/*,test/*/tc_*.rb}']
16
16
 
17
17
  s.authors = ['Juergen eTM Mangler','Gerhard Stuermer']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.78
4
+ version: 1.99.84
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-15 00:00:00.000000000 Z
12
+ date: 2020-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -30,14 +30,14 @@ email: juergen.mangler@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files:
33
- - README
33
+ - README.md
34
34
  files:
35
35
  - AUTHORS
36
36
  - COPYING
37
37
  - Changelog
38
38
  - FEATURES
39
39
  - INSTALL
40
- - README
40
+ - README.md
41
41
  - Rakefile
42
42
  - example/SimpleHandlerWrapper.rb
43
43
  - example/SimpleWorkflow.rb
@@ -65,6 +65,7 @@ files:
65
65
  - test/exec/tc_exec.rb
66
66
  - test/speed/tc_speed1.rb
67
67
  - test/speed/tc_speed2.rb
68
+ - test/test
68
69
  - test/wfp_adv_branching/tc_generalizedjoin.rb
69
70
  - test/wfp_adv_branching/tc_generalsynchronizingmerge.rb
70
71
  - test/wfp_adv_branching/tc_localsynchronizingmerge.rb
@@ -93,19 +94,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
94
  requirements:
94
95
  - - ">="
95
96
  - !ruby/object:Gem::Version
96
- version: 2.3.0
97
+ version: 2.5.0
97
98
  required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  requirements:
99
100
  - - ">="
100
101
  - !ruby/object:Gem::Version
101
102
  version: '0'
102
103
  requirements: []
103
- rubygems_version: 3.0.3
104
+ rubygems_version: 3.1.2
104
105
  signing_key:
105
106
  specification_version: 4
106
- summary: Preliminary release of the Workflow Execution Engine Library (WEEL)
107
+ summary: Workflow Execution Engine Library (WEEL)
107
108
  test_files:
108
109
  - test/TestHandlerWrapper.rb
110
+ - test/test
109
111
  - test/ContinueTest.rb
110
112
  - test/TestWorkflow.rb
111
113
  - test/TestMixin.rb
data/README DELETED
@@ -1,4 +0,0 @@
1
- All code in this package is provided under the LGPL-3 license.
2
- Please read the file COPYING.
3
-
4
- Tested for MRI >= 1.9.3