flor 0.12.0 → 0.13.0

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.
@@ -2,6 +2,12 @@
2
2
  # flor CHANGELOG.md
3
3
 
4
4
 
5
+ ## flor 0.13.0 released 2017-04-24
6
+
7
+ - Simplify "trace" implementation
8
+ - Simplify "task" implementation
9
+
10
+
5
11
  ## flor 0.12.0 released 2017-04-14
6
12
 
7
13
  - Implementation of 'flank' and application to "trap" and "schedule"
@@ -12,7 +12,7 @@ require 'raabro'
12
12
 
13
13
  module Flor
14
14
 
15
- VERSION = '0.12.0'
15
+ VERSION = '0.13.0'
16
16
  end
17
17
 
18
18
  require 'flor/colours'
@@ -605,6 +605,7 @@ class Flor::Procedure < Flor::Node
605
605
  close_node
606
606
 
607
607
  do_wrap_cancel_children ||
608
+ pop_on_receive_last ||
608
609
  wrap_cancelled
609
610
  end
610
611
 
@@ -125,14 +125,12 @@ module Flor
125
125
  o.puts "#{_c.dg}| #{opts.inspect}#{_c.rs}" if opts.any?
126
126
 
127
127
  if src.is_a?(String)
128
- src.split("\n").select { |l| l.strip.length > 0 }.each do |line|
129
- o.puts "#{_c.dg}| #{_c.yl}#{line}#{_c.rs}"
130
- end
128
+ src.split("\n")
129
+ .select { |l| l.strip.length > 0 && l.match(/\A\s*[^#]/) }
130
+ .each { |l| o.puts "#{_c.dg}| #{_c.yl}#{l}#{_c.rs}" }
131
131
  else
132
- ss = Flor.to_pretty_s(src).split("\n")
133
- ss.each do |line|
134
- o.puts "#{_c.dg}| #{_c.yl}#{line}#{_c.rs}"
135
- end
132
+ Flor.to_pretty_s(src).split("\n")
133
+ .each { |l| o.puts "#{_c.dg}| #{_c.yl}#{l}#{_c.rs}" }
136
134
  end
137
135
 
138
136
  o.puts "#{_c.dg}.#{_c.rs}"
@@ -309,7 +309,12 @@ module Flor
309
309
 
310
310
  t = [ atts[i][0][0] == 'if' ? 'if' : 'unless', [], @line ]
311
311
  t[1].concat(atts[i + 1..-1].collect(&:first))
312
- t[1].push([ @head, cn[0, i], @line ])
312
+
313
+ cn0i = cn[0, i]; if Flor.is_tree?(@head) && cn0i == []
314
+ t[1].push(@head)
315
+ else
316
+ t[1].push([ @head, cn0i, @line ])
317
+ end
313
318
 
314
319
  t
315
320
  end
@@ -21,6 +21,28 @@ class Flor::Pro::Cursor < Flor::Procedure
21
21
  # task 'bravo'
22
22
  # task 'charly'
23
23
  # ```
24
+ #
25
+ # ## continue
26
+ #
27
+ # Cursor also understands `continue`. It's useful to rewind a cursor:
28
+ # ```
29
+ # cursor
30
+ # sales_team "fill in customer details"
31
+ # ops_team "attribute account number"
32
+ # continue _ if f.ops_decision == 'reject'
33
+ # create_account
34
+ # ```
35
+ #
36
+ # ## move
37
+ #
38
+ # Cursor accepts move orders, as in:
39
+ # ```
40
+ # cursor
41
+ # do-this
42
+ # move to: 'do-that-other-thing'
43
+ # do-that _ # got skipped
44
+ # do-that-other-thing _
45
+ # ```
24
46
 
25
47
  name 'cursor'
26
48
 
@@ -73,49 +95,18 @@ class Flor::Pro::Cursor < Flor::Procedure
73
95
 
74
96
  def cancel
75
97
 
76
- fla = @message['flavour']
77
-
78
- # busy = @node['on_receive_last']
79
- #
80
- # close_node
81
- #
82
- # @node['on_receive_last'] =
83
- # if fla == 'continue'
84
- # @node['subs'] << counter_next('subs')
85
- # execute_child(first_non_att_child_id, @node['subs'].last, 'orl' => fla)
86
- # elsif fla == 'move'
87
- # @node['subs'] << counter_next('subs')
88
- # execute_child(move_target_child_id, @node['subs'].last, 'orl' => fla)
89
- # else # 'break'
90
- # nil
91
- # end
92
- #
93
- # return [] if busy
94
- # # <------- that implies that upon a sound reply,
95
- # # @node['on_receive_last'] is set to nil!
96
- # # @node['status'] is cleaned...
97
- #
98
- # super.tap { |ms| pp ms }
99
-
100
- #if nid == '0_1_0'
101
- # puts "\\" * 80
102
- # puts caller[0, 7]
103
- #end
104
-
105
- if fla == 'continue'
106
-
107
- @node['on_receive_last'] =
108
- wrap(
109
- 'nid' => nid, 'from' => "#{nid}_#{children.size + 1}",
110
- 'orl' => fla,
111
- 'payload' => Flor.dup(message['payload']))
98
+ if %w[ continue move ].include?(fla = @message['flavour'])
112
99
 
113
- elsif fla == 'move'
100
+ cid =
101
+ fla == 'move' ?
102
+ move_target_child_id :
103
+ first_non_att_child_id
114
104
 
115
- @node['subs'] << counter_next('subs')
105
+ @node['subs'] <<
106
+ counter_next('subs')
116
107
 
117
108
  @node['on_receive_last'] =
118
- execute_child(move_target_child_id, @node['subs'].last, 'orl' => fla)
109
+ execute_child(cid, @node['subs'].last, 'orl' => fla)
119
110
 
120
111
  else
121
112
 
@@ -0,0 +1,23 @@
1
+
2
+ class Flor::Pro::Echo < Flor::Procedure
3
+
4
+ name 'echo'
5
+
6
+ def receive_last_att
7
+
8
+ case ret = payload['ret']
9
+ when String then puts(ret)
10
+ else pp(ret)
11
+ end
12
+
13
+ super
14
+ end
15
+
16
+ def receive_last
17
+
18
+ payload['ret'] = node_payload_ret
19
+
20
+ wrap
21
+ end
22
+ end
23
+
@@ -7,8 +7,8 @@ class Flor::Pro::Move < Flor::Procedure
7
7
  # cursor
8
8
  # do-this
9
9
  # move to: 'do-that-other-thing'
10
- # do-that # got skipped
11
- # do-that-other-thing
10
+ # do-that _ # got skipped
11
+ # do-that-other-thing _
12
12
  # ```
13
13
 
14
14
  name 'move'
@@ -77,9 +77,7 @@ class Flor::Pro::Until < Flor::Procedure
77
77
 
78
78
  def cancel
79
79
 
80
- fla = @message['flavour']
81
-
82
- if fla == 'continue'
80
+ if @message['flavour'] == 'continue'
83
81
 
84
82
  pl = node_payload.copy_current
85
83
  pl = pl.merge!(payload.copy_current)
@@ -8,7 +8,7 @@ class Flor::Pro::Task < Flor::Procedure
8
8
  @node['atts'] = []
9
9
  end
10
10
 
11
- def do_receive
11
+ def receive
12
12
 
13
13
  return wrap_reply('payload' => determine_reply_payload) \
14
14
  if point == 'receive' && from == nil
@@ -17,6 +17,8 @@ class Flor::Pro::Task < Flor::Procedure
17
17
  # which goes to #receive or #receive_when_status
18
18
  end
19
19
 
20
+ alias receive_when_closed receive_from_child_when_closed
21
+
20
22
  def receive_last_att
21
23
 
22
24
  # task 'clean up' by: 'alan'
@@ -50,6 +52,8 @@ class Flor::Pro::Task < Flor::Procedure
50
52
 
51
53
  def cancel
52
54
 
55
+ close_node
56
+
53
57
  attl, attd = determine_atts
54
58
 
55
59
  wrap(
@@ -5,14 +5,10 @@ class Flor::Pro::Trace < Flor::Procedure
5
5
 
6
6
  def receive
7
7
 
8
- if @message['point'] == 'receive'
8
+ t = lookup_tree(@message['from'])
9
9
 
10
- t = lookup_tree(@message['from'])
11
-
12
- if t.first == '_att' && t[1].size == 1
13
- @executor.unit.storage.trace(exid, nid, 'trace', payload['ret'])
14
- end
15
- end
10
+ @executor.unit.storage.trace(exid, nid, 'trace', payload['ret']) \
11
+ if point == 'receive' && (t[0] != '_att' || t[1].size == 1)
16
12
 
17
13
  super
18
14
  end
@@ -21,7 +17,7 @@ class Flor::Pro::Trace < Flor::Procedure
21
17
 
22
18
  payload['ret'] = node_payload_ret
23
19
 
24
- wrap
20
+ super
25
21
  end
26
22
  end
27
23
 
@@ -269,6 +269,7 @@ module Flor
269
269
 
270
270
  queue(*prepare_message('cancel', [ exid, *as, { re_apply: true } ]))
271
271
  end
272
+ alias reapply re_apply
272
273
 
273
274
  def schedule(message)
274
275
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-13 00:00:00.000000000 Z
12
+ date: 2017-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: munemo
@@ -151,6 +151,7 @@ files:
151
151
  - lib/flor/pcore/cond.rb
152
152
  - lib/flor/pcore/cursor.rb
153
153
  - lib/flor/pcore/define.rb
154
+ - lib/flor/pcore/echo.rb
154
155
  - lib/flor/pcore/fail.rb
155
156
  - lib/flor/pcore/if.rb
156
157
  - lib/flor/pcore/loop.rb