weel 1.99.80 → 1.99.88
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 +4 -4
- data/README.md +35 -0
- data/lib/weel.rb +116 -80
- data/test/TestHandlerWrapper.rb +11 -3
- data/test/TestMixin.rb +4 -5
- data/test/TestWorkflow.rb +2 -2
- data/test/basic/tc_choose.rb +53 -53
- data/test/basic/tc_state.rb +5 -5
- data/test/basic/tc_wf_control.rb +44 -44
- data/test/complexsearch/tc_search.rb +1 -1
- data/test/test +39 -0
- data/weel.gemspec +5 -5
- metadata +9 -7
- data/README +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26837244dc867c672c8999f93f835092edbe37c02a61d1aad43b0e9b4e9566bf
|
4
|
+
data.tar.gz: b929d66dc9050ad20a130412d219de79715e27b9bed2e2df9c0b67cbe4621471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1e2c147083f56c6b2e1229414e118fe2387ed54cab963ae418c8e8b2142bfb7b70fced4fb1d731bc95e2093848fe79011242171c1cdcb469b3ffbe5880b3550
|
7
|
+
data.tar.gz: 59b6025af6e055145637abb28e988693e09c23771cf7f2747fd850dafe635db6c72f512a727320e0ff42fa4ba9218aee2ff30d9e816051a6cbb143b71eab4e01
|
data/README.md
ADDED
@@ -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
|
+
```
|
data/lib/weel.rb
CHANGED
@@ -40,33 +40,48 @@ class WEEL
|
|
40
40
|
class Salvage < Exception; end
|
41
41
|
end # }}}
|
42
42
|
|
43
|
-
class ReadStructure # {{{
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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.include?(m)
|
50
64
|
begin
|
51
|
-
Marshal.load(Marshal.dump(
|
65
|
+
tmp = Marshal.load(Marshal.dump(@additional[m]))
|
66
|
+
if tmp.is_a? Hash
|
67
|
+
ReadHash.new(tmp)
|
68
|
+
else
|
69
|
+
tmp
|
70
|
+
end
|
52
71
|
rescue
|
53
|
-
|
72
|
+
m.to_s rescue nil
|
54
73
|
end
|
55
74
|
end
|
56
75
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
def endpoints
|
65
|
-
ReadHash.new(@__weel_endpoints)
|
66
|
-
end
|
67
|
-
end # }}}
|
76
|
+
def data
|
77
|
+
ReadHash.new(@__weel_data)
|
78
|
+
end
|
79
|
+
def endpoints
|
80
|
+
ReadHash.new(@__weel_endpoints)
|
81
|
+
end
|
82
|
+
end # }}}
|
68
83
|
class ManipulateStructure # {{{
|
69
|
-
def initialize(data,endpoints,status)
|
84
|
+
def initialize(data,endpoints,status,additional)
|
70
85
|
@__weel_data = data
|
71
86
|
@__weel_data_orig = @__weel_data.transform_values{|val| Marshal.dump(val) } rescue nil
|
72
87
|
@__weel_endpoints = endpoints
|
@@ -77,6 +92,22 @@ end # }}}
|
|
77
92
|
@touched_data = []
|
78
93
|
@changed_endpoints = []
|
79
94
|
@touched_endpoints = []
|
95
|
+
@additional = additional
|
96
|
+
end
|
97
|
+
|
98
|
+
def method_missing(m,*args,&block)
|
99
|
+
if @additional.include?(m)
|
100
|
+
begin
|
101
|
+
tmp = Marshal.load(Marshal.dump(@additional[m]))
|
102
|
+
if tmp.is_a? Hash
|
103
|
+
ReadHash.new(tmp)
|
104
|
+
else
|
105
|
+
tmp
|
106
|
+
end
|
107
|
+
rescue
|
108
|
+
m.to_s rescue nil
|
109
|
+
end
|
110
|
+
end
|
80
111
|
end
|
81
112
|
|
82
113
|
def changed_data
|
@@ -209,17 +240,18 @@ end # }}}
|
|
209
240
|
def self::inform_state_change(arguments,newstate); end
|
210
241
|
def self::inform_syntax_error(arguments,err,code); end
|
211
242
|
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
|
243
|
+
def self::inform_position_change(arguments,ipc={}); end
|
214
244
|
|
215
|
-
def initialize(arguments,
|
245
|
+
def initialize(arguments,position=nil,continue=nil); end
|
216
246
|
|
217
247
|
def prepare(readonly, endpoints, parameters, replay=false); parameters; end
|
248
|
+
def additional; {}; end
|
218
249
|
|
219
250
|
def activity_handle(passthrough, parameters); end
|
220
251
|
def activity_manipulate_handle(parameters); end
|
221
252
|
|
222
253
|
def activity_result_value; end
|
254
|
+
def activity_result_options; end
|
223
255
|
|
224
256
|
def activity_stop; end
|
225
257
|
def activity_passthrough_value; end
|
@@ -256,7 +288,7 @@ end # }}}
|
|
256
288
|
end
|
257
289
|
def as_json(*)
|
258
290
|
jsn = { 'position' => @position }
|
259
|
-
jsn['
|
291
|
+
jsn['passthrough'] = @passthrough if @passthrough
|
260
292
|
jsn
|
261
293
|
end
|
262
294
|
def to_s
|
@@ -288,7 +320,7 @@ end # }}}
|
|
288
320
|
end
|
289
321
|
end #}}}
|
290
322
|
|
291
|
-
def self::search(weel_search)# {{{
|
323
|
+
def self::search(*weel_search)# {{{
|
292
324
|
define_method :initialize_search do
|
293
325
|
self.search weel_search
|
294
326
|
end
|
@@ -364,8 +396,8 @@ end # }}}
|
|
364
396
|
# Parallel DSL-Construct
|
365
397
|
# Defines Workflow paths that can be executed parallel.
|
366
398
|
# May contain multiple branches (parallel_branch)
|
367
|
-
def parallel(type=nil)# {{{
|
368
|
-
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
|
399
|
+
def parallel(type=nil,&block)# {{{
|
400
|
+
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
|
369
401
|
|
370
402
|
Thread.current[:branches] = []
|
371
403
|
Thread.current[:branch_finished_count] = 0
|
@@ -374,7 +406,7 @@ end # }}}
|
|
374
406
|
|
375
407
|
hw, pos = __weel_sim_start(:parallel) if __weel_sim
|
376
408
|
|
377
|
-
__weel_protect_yield(&
|
409
|
+
__weel_protect_yield(&block)
|
378
410
|
|
379
411
|
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)
|
380
412
|
1.upto Thread.current[:branches].size do
|
@@ -387,10 +419,10 @@ end # }}}
|
|
387
419
|
if Thread.current[:branch_search] == false
|
388
420
|
thread[:branch_search] = false
|
389
421
|
end
|
390
|
-
thread[:start_event].
|
422
|
+
thread[:start_event]&.continue # sometimes start event might not even exist yet (i.e. race condition)
|
391
423
|
end
|
392
424
|
|
393
|
-
Thread.current[:branch_event].wait
|
425
|
+
Thread.current[:branch_event].wait unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
|
394
426
|
|
395
427
|
__weel_sim_stop(:parallel,hw,pos) if __weel_sim
|
396
428
|
|
@@ -410,7 +442,7 @@ end # }}}
|
|
410
442
|
end # }}}
|
411
443
|
|
412
444
|
# Defines a branch of a parallel-Construct
|
413
|
-
def parallel_branch(*vars)# {{{
|
445
|
+
def parallel_branch(*vars,&block)# {{{
|
414
446
|
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
415
447
|
branch_parent = Thread.current
|
416
448
|
|
@@ -436,14 +468,16 @@ end # }}}
|
|
436
468
|
Thread.current[:alternative_mode] = [branch_parent[:alternative_mode].last]
|
437
469
|
end
|
438
470
|
branch_parent[:branch_event].continue
|
439
|
-
Thread.current[:start_event].wait
|
471
|
+
Thread.current[:start_event].wait unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
|
440
472
|
|
441
473
|
if __weel_sim
|
442
474
|
handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args
|
443
475
|
handlerwrapper.simulate(:parallel_branch,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos)
|
444
476
|
end
|
445
477
|
|
446
|
-
|
478
|
+
unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
479
|
+
__weel_protect_yield(*local, &block)
|
480
|
+
end
|
447
481
|
|
448
482
|
__weel_sim_stop(:parallel_branch,handlerwrapper,current_branch_sim_pos) if __weel_sim
|
449
483
|
|
@@ -454,7 +488,7 @@ end # }}}
|
|
454
488
|
branch_parent[:branch_event].continue
|
455
489
|
end
|
456
490
|
end
|
457
|
-
|
491
|
+
unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
|
458
492
|
if Thread.current[:branch_position]
|
459
493
|
@__weel_positions.delete Thread.current[:branch_position]
|
460
494
|
begin
|
@@ -471,14 +505,14 @@ end # }}}
|
|
471
505
|
# Choose DSL-Construct
|
472
506
|
# Defines a choice in the Workflow path.
|
473
507
|
# May contain multiple execution alternatives
|
474
|
-
def choose(mode=:inclusive) # {{{
|
508
|
+
def choose(mode=:inclusive,&block) # {{{
|
475
509
|
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
476
510
|
Thread.current[:alternative_executed] ||= []
|
477
511
|
Thread.current[:alternative_mode] ||= []
|
478
512
|
Thread.current[:alternative_executed] << false
|
479
513
|
Thread.current[:alternative_mode] << mode
|
480
514
|
hw, pos = __weel_sim_start(:choose,:mode => Thread.current[:alternative_mode].last) if __weel_sim
|
481
|
-
__weel_protect_yield(&
|
515
|
+
__weel_protect_yield(&block)
|
482
516
|
__weel_sim_stop(:choose,hw,pos,:mode => Thread.current[:alternative_mode].last) if __weel_sim
|
483
517
|
Thread.current[:alternative_executed].pop
|
484
518
|
Thread.current[:alternative_mode].pop
|
@@ -488,7 +522,7 @@ end # }}}
|
|
488
522
|
# Defines a possible choice of a choose-Construct
|
489
523
|
# Block is executed if condition == true or
|
490
524
|
# searchmode is active (to find the starting position)
|
491
|
-
def alternative(condition,args={})# {{{
|
525
|
+
def alternative(condition,args={},&block)# {{{
|
492
526
|
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
493
527
|
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
|
494
528
|
Thread.current[:mutex] ||= Mutex.new
|
@@ -499,18 +533,18 @@ end # }}}
|
|
499
533
|
end
|
500
534
|
Thread.current[:alternative_executed][-1] = true if condition
|
501
535
|
end
|
502
|
-
__weel_protect_yield(&
|
536
|
+
__weel_protect_yield(&block) if __weel_is_in_search_mode || __weel_sim || condition
|
503
537
|
__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
|
504
538
|
end # }}}
|
505
|
-
def otherwise(args={}) # {{{
|
539
|
+
def otherwise(args={},&block) # {{{
|
506
540
|
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
507
541
|
hw, pos = __weel_sim_start(:otherwise,args.merge(:mode => Thread.current[:alternative_mode].last)) if __weel_sim
|
508
|
-
__weel_protect_yield(&
|
542
|
+
__weel_protect_yield(&block) if __weel_is_in_search_mode || __weel_sim || !Thread.current[:alternative_executed].last
|
509
543
|
__weel_sim_stop(:otherwise,hw,pos,args.merge(:mode => Thread.current[:alternative_mode].last)) if __weel_sim
|
510
544
|
end # }}}
|
511
545
|
|
512
546
|
# Defines a critical block (=Mutex)
|
513
|
-
def critical(id)# {{{
|
547
|
+
def critical(id,&block)# {{{
|
514
548
|
@__weel_critical ||= Mutex.new
|
515
549
|
semaphore = nil
|
516
550
|
@__weel_critical.synchronize do
|
@@ -519,19 +553,19 @@ end # }}}
|
|
519
553
|
@__weel_critical_sections[id] = semaphore if id
|
520
554
|
end
|
521
555
|
semaphore.synchronize do
|
522
|
-
__weel_protect_yield(&
|
556
|
+
__weel_protect_yield(&block)
|
523
557
|
end
|
524
558
|
end # }}}
|
525
559
|
|
526
560
|
# Defines a Cycle (loop/iteration)
|
527
|
-
def loop(condition,args={})# {{{
|
561
|
+
def loop(condition,args={},&block)# {{{
|
528
562
|
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)
|
529
563
|
raise "condition must be called pre_test{} or post_test{}"
|
530
564
|
end
|
531
565
|
return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
|
532
566
|
if __weel_is_in_search_mode
|
533
567
|
catch :escape do
|
534
|
-
__weel_protect_yield(&
|
568
|
+
__weel_protect_yield(&block)
|
535
569
|
end
|
536
570
|
if __weel_is_in_search_mode
|
537
571
|
return
|
@@ -545,7 +579,7 @@ end # }}}
|
|
545
579
|
cond = condition[0].is_a?(Proc) ? true : condition[0]
|
546
580
|
hw, pos = __weel_sim_start(:loop,args.merge(:testing=>condition[1],:condition=>cond))
|
547
581
|
catch :escape do
|
548
|
-
__weel_protect_yield(&
|
582
|
+
__weel_protect_yield(&block)
|
549
583
|
end
|
550
584
|
__weel_sim_stop(:loop,hw,pos,args.merge(:testing=>condition[1],:condition=>cond))
|
551
585
|
return
|
@@ -554,11 +588,11 @@ end # }}}
|
|
554
588
|
case condition[1]
|
555
589
|
when :pre_test
|
556
590
|
while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
|
557
|
-
__weel_protect_yield(&
|
591
|
+
__weel_protect_yield(&block)
|
558
592
|
end
|
559
593
|
when :post_test
|
560
594
|
begin
|
561
|
-
__weel_protect_yield(&
|
595
|
+
__weel_protect_yield(&block)
|
562
596
|
end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
|
563
597
|
end
|
564
598
|
end
|
@@ -620,7 +654,7 @@ end # }}}
|
|
620
654
|
def __weel_eval_condition(condition) #{{{
|
621
655
|
begin
|
622
656
|
handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args unless condition.is_a?(Proc)
|
623
|
-
condition.is_a?(Proc) ? condition.call : handlerwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints),condition)
|
657
|
+
condition.is_a?(Proc) ? condition.call : handlerwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional),condition)
|
624
658
|
rescue NameError => err # don't look into it, or it will explode
|
625
659
|
# if you access $! here, BOOOM
|
626
660
|
self.__weel_state = :stopping
|
@@ -635,24 +669,26 @@ end # }}}
|
|
635
669
|
|
636
670
|
def __weel_progress(searchmode, position, skip=false) #{{{
|
637
671
|
ipc = {}
|
638
|
-
if
|
639
|
-
|
640
|
-
ipc[:
|
641
|
-
|
642
|
-
|
643
|
-
@__weel_positions.delete Thread.current[:branch_parent][:branch_position]
|
644
|
-
ipc[:unmark] ||= []
|
645
|
-
ipc[:unmark] << Thread.current[:branch_parent][:branch_position] rescue nil
|
646
|
-
Thread.current[:branch_parent][:branch_position] = nil
|
647
|
-
end
|
648
|
-
if Thread.current[:branch_position]
|
649
|
-
@__weel_positions.delete Thread.current[:branch_position]
|
650
|
-
ipc[:unmark] ||= []
|
651
|
-
ipc[:unmark] << Thread.current[:branch_position] rescue nil
|
652
|
-
end
|
653
|
-
wp = WEEL::Position.new(position, skip ? :after : :at, nil)
|
654
|
-
ipc[skip ? :after : :at] = [wp]
|
672
|
+
if Thread.current[:branch_parent] && Thread.current[:branch_parent][:branch_position]
|
673
|
+
@__weel_positions.delete Thread.current[:branch_parent][:branch_position]
|
674
|
+
ipc[:unmark] ||= []
|
675
|
+
ipc[:unmark] << Thread.current[:branch_parent][:branch_position] rescue nil
|
676
|
+
Thread.current[:branch_parent][:branch_position] = nil
|
655
677
|
end
|
678
|
+
if Thread.current[:branch_position]
|
679
|
+
@__weel_positions.delete Thread.current[:branch_position]
|
680
|
+
ipc[:unmark] ||= []
|
681
|
+
ipc[:unmark] << Thread.current[:branch_position] rescue nil
|
682
|
+
end
|
683
|
+
wp = WEEL::Position.new(position, skip ? :after : :at, nil)
|
684
|
+
ipc[skip ? :after : :at] = [wp]
|
685
|
+
|
686
|
+
@__weel_search_positions.each do |k,ele| # some may still be in active search but lets unmark them for good measure
|
687
|
+
ipc[:unmark] ||= []
|
688
|
+
ipc[:unmark] << ele
|
689
|
+
true
|
690
|
+
end
|
691
|
+
|
656
692
|
@__weel_positions << wp
|
657
693
|
Thread.current[:branch_position] = wp
|
658
694
|
|
@@ -689,10 +725,10 @@ end # }}}
|
|
689
725
|
handlerwrapper.activity_manipulate_handle(parameters)
|
690
726
|
handlerwrapper.inform_activity_manipulate
|
691
727
|
if finalize.is_a?(Proc)
|
692
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
|
728
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
|
693
729
|
mr.instance_eval(&finalize)
|
694
730
|
elsif finalize.is_a?(String)
|
695
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
|
731
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
|
696
732
|
handlerwrapper.manipulate(mr,finalize)
|
697
733
|
end
|
698
734
|
handlerwrapper.inform_manipulate_change(
|
@@ -709,10 +745,10 @@ end # }}}
|
|
709
745
|
when :call
|
710
746
|
begin
|
711
747
|
again = catch Signal::Again do
|
712
|
-
rs = ReadStructure.new(@__weel_data,@__weel_endpoints)
|
748
|
+
rs = ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional)
|
713
749
|
if prepare
|
714
750
|
if prepare.is_a?(Proc)
|
715
|
-
rs.instance_exec
|
751
|
+
rs.instance_exec(&prepare)
|
716
752
|
elsif prepare.is_a?(String)
|
717
753
|
rs.instance_eval prepare
|
718
754
|
end
|
@@ -759,18 +795,18 @@ end # }}}
|
|
759
795
|
if code.is_a?(Proc) || code.is_a?(String)
|
760
796
|
handlerwrapper.inform_activity_manipulate
|
761
797
|
if code.is_a?(Proc)
|
762
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
798
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
|
799
|
+
ma = catch Signal::Again do
|
800
|
+
case code.arity
|
801
|
+
when 1; mr.instance_exec(handlerwrapper.activity_result_value,&code)
|
802
|
+
when 2; mr.instance_exec(handlerwrapper.activity_result_value,&code)
|
803
|
+
else
|
768
804
|
mr.instance_exec(&code)
|
769
|
-
|
770
|
-
|
805
|
+
end
|
806
|
+
'yes' # ma sadly will have nil when i just throw
|
771
807
|
end
|
772
808
|
elsif code.is_a?(String)
|
773
|
-
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
|
809
|
+
mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
|
774
810
|
ma = catch Signal::Again do
|
775
811
|
handlerwrapper.manipulate(mr,code,handlerwrapper.activity_result_value,handlerwrapper.activity_result_options)
|
776
812
|
'yes' # ma sadly will have nil when i just throw
|
@@ -876,7 +912,7 @@ end # }}}
|
|
876
912
|
branch = branch[:branch_parent]
|
877
913
|
branch[:branch_search] = false
|
878
914
|
end
|
879
|
-
@__weel_search_positions[position].detail == :after
|
915
|
+
@__weel_search_positions[position].detail == :after
|
880
916
|
else
|
881
917
|
branch[:branch_search] = true
|
882
918
|
end
|
data/test/TestHandlerWrapper.rb
CHANGED
@@ -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,
|
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
|
-
|
79
|
+
nil
|
72
80
|
end #}}}
|
73
81
|
|
74
82
|
# Called if the execution of the actual activity_handle is not necessary anymore
|
data/test/TestMixin.rb
CHANGED
@@ -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
|
data/test/TestWorkflow.rb
CHANGED
@@ -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
|
17
|
+
parallel :wait do
|
18
18
|
parallel_branch do
|
19
19
|
call :a2_1_1, :endpoint1
|
20
20
|
end
|
data/test/basic/tc_choose.rb
CHANGED
@@ -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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
data/test/basic/tc_state.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
10
|
-
|
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
|
data/test/basic/tc_wf_control.rb
CHANGED
@@ -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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
def test_continue
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
51
|
+
# @wf.search @wf.positions
|
52
52
|
|
53
|
-
|
54
|
-
|
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
|
-
|
67
|
-
|
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(
|
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
|
|
data/test/test
ADDED
@@ -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
|
data/weel.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "weel"
|
3
|
-
s.version = "1.99.
|
3
|
+
s.version = "1.99.88"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3.0"
|
6
|
-
s.summary = "
|
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.
|
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.
|
4
|
+
version: 1.99.88
|
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:
|
12
|
+
date: 2020-09-23 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.
|
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.
|
104
|
+
rubygems_version: 3.1.2
|
104
105
|
signing_key:
|
105
106
|
specification_version: 4
|
106
|
-
summary:
|
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