flor 0.17.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +48 -0
  3. data/CREDITS.md +1 -0
  4. data/LICENSE.txt +1 -1
  5. data/Makefile +1 -1
  6. data/README.md +34 -2
  7. data/flor.gemspec +8 -9
  8. data/lib/flor.rb +3 -2
  9. data/lib/flor/colours.rb +5 -3
  10. data/lib/flor/conf.rb +1 -0
  11. data/lib/flor/core.rb +9 -8
  12. data/lib/flor/core/executor.rb +25 -22
  13. data/lib/flor/core/node.rb +1 -13
  14. data/lib/flor/core/procedure.rb +57 -12
  15. data/lib/flor/core/texecutor.rb +35 -3
  16. data/lib/flor/djan.rb +1 -0
  17. data/lib/flor/errors.rb +1 -0
  18. data/lib/flor/flor.rb +173 -29
  19. data/lib/flor/id.rb +5 -1
  20. data/lib/flor/log.rb +20 -8
  21. data/lib/flor/migrations/0001_tables.rb +1 -0
  22. data/lib/flor/migrations/0002_cunit_and_munit.rb +1 -0
  23. data/lib/flor/migrations/0003_timer_onid_bnid.rb +1 -0
  24. data/lib/flor/migrations/0004_trap_bnid.rb +1 -0
  25. data/lib/flor/migrations/0005_pointer_content.rb +1 -0
  26. data/lib/flor/parser.rb +19 -11
  27. data/lib/flor/pcore/_apply.rb +1 -0
  28. data/lib/flor/pcore/_arr.rb +1 -0
  29. data/lib/flor/pcore/_atom.rb +1 -0
  30. data/lib/flor/pcore/_att.rb +1 -0
  31. data/lib/flor/pcore/_coll.rb +1 -0
  32. data/lib/flor/pcore/_dmute.rb +5 -1
  33. data/lib/flor/pcore/_dol.rb +1 -0
  34. data/lib/flor/pcore/_dqs.rb +1 -0
  35. data/lib/flor/pcore/_dump.rb +1 -0
  36. data/lib/flor/pcore/_err.rb +1 -0
  37. data/lib/flor/pcore/_head.rb +1 -0
  38. data/lib/flor/pcore/_obj.rb +1 -0
  39. data/lib/flor/pcore/_pat_.rb +1 -0
  40. data/lib/flor/pcore/_pat_arr.rb +1 -0
  41. data/lib/flor/pcore/_pat_guard.rb +1 -0
  42. data/lib/flor/pcore/_pat_obj.rb +1 -0
  43. data/lib/flor/pcore/_pat_or.rb +1 -0
  44. data/lib/flor/pcore/_pat_regex.rb +1 -0
  45. data/lib/flor/pcore/_ref.rb +1 -0
  46. data/lib/flor/pcore/_rxs.rb +1 -0
  47. data/lib/flor/pcore/_skip.rb +1 -0
  48. data/lib/flor/pcore/_val.rb +1 -0
  49. data/lib/flor/pcore/all.rb +1 -0
  50. data/lib/flor/pcore/andor.rb +1 -0
  51. data/lib/flor/pcore/any.rb +1 -0
  52. data/lib/flor/pcore/apply.rb +1 -0
  53. data/lib/flor/pcore/arith.rb +1 -0
  54. data/lib/flor/pcore/array_qmark.rb +1 -0
  55. data/lib/flor/pcore/break.rb +13 -1
  56. data/lib/flor/pcore/case.rb +1 -0
  57. data/lib/flor/pcore/cmp.rb +1 -0
  58. data/lib/flor/pcore/collect.rb +2 -1
  59. data/lib/flor/pcore/cond.rb +1 -0
  60. data/lib/flor/pcore/cursor.rb +45 -3
  61. data/lib/flor/pcore/define.rb +1 -0
  62. data/lib/flor/pcore/detect.rb +1 -0
  63. data/lib/flor/pcore/do_return.rb +1 -0
  64. data/lib/flor/pcore/each.rb +1 -0
  65. data/lib/flor/pcore/echo.rb +1 -0
  66. data/lib/flor/pcore/empty.rb +1 -0
  67. data/lib/flor/pcore/fail.rb +1 -0
  68. data/lib/flor/pcore/filter.rb +1 -0
  69. data/lib/flor/pcore/find.rb +1 -0
  70. data/lib/flor/pcore/flatten.rb +1 -0
  71. data/lib/flor/pcore/for_each.rb +1 -0
  72. data/lib/flor/pcore/if.rb +1 -0
  73. data/lib/flor/pcore/includes.rb +1 -0
  74. data/lib/flor/pcore/inject.rb +1 -0
  75. data/lib/flor/pcore/iterator.rb +1 -0
  76. data/lib/flor/pcore/keys.rb +1 -0
  77. data/lib/flor/pcore/length.rb +1 -0
  78. data/lib/flor/pcore/loop.rb +1 -0
  79. data/lib/flor/pcore/map.rb +1 -0
  80. data/lib/flor/pcore/match.rb +1 -0
  81. data/lib/flor/pcore/matchr.rb +1 -0
  82. data/lib/flor/pcore/max.rb +1 -0
  83. data/lib/flor/pcore/merge.rb +1 -0
  84. data/lib/flor/pcore/move.rb +1 -0
  85. data/lib/flor/pcore/noeval.rb +1 -0
  86. data/lib/flor/pcore/noret.rb +1 -0
  87. data/lib/flor/pcore/not.rb +1 -0
  88. data/lib/flor/pcore/on.rb +34 -9
  89. data/lib/flor/pcore/on_cancel.rb +1 -0
  90. data/lib/flor/pcore/on_error.rb +1 -0
  91. data/lib/flor/pcore/push.rb +1 -0
  92. data/lib/flor/pcore/rand.rb +1 -0
  93. data/lib/flor/pcore/range.rb +1 -0
  94. data/lib/flor/pcore/reduce.rb +1 -0
  95. data/lib/flor/pcore/return.rb +1 -0
  96. data/lib/flor/pcore/reverse.rb +1 -0
  97. data/lib/flor/pcore/select.rb +1 -0
  98. data/lib/flor/pcore/sequence.rb +49 -0
  99. data/lib/flor/pcore/set.rb +1 -0
  100. data/lib/flor/pcore/shuffle.rb +1 -0
  101. data/lib/flor/pcore/slice.rb +1 -0
  102. data/lib/flor/pcore/sort.rb +1 -0
  103. data/lib/flor/pcore/sort_by.rb +1 -0
  104. data/lib/flor/pcore/split.rb +1 -0
  105. data/lib/flor/pcore/stall.rb +1 -0
  106. data/lib/flor/pcore/strings.rb +1 -0
  107. data/lib/flor/pcore/timestamp.rb +1 -0
  108. data/lib/flor/pcore/to_array.rb +1 -0
  109. data/lib/flor/pcore/twig.rb +1 -0
  110. data/lib/flor/pcore/type_of.rb +1 -0
  111. data/lib/flor/pcore/until.rb +1 -0
  112. data/lib/flor/punit/abort.rb +50 -0
  113. data/lib/flor/punit/c_collect.rb +1 -0
  114. data/lib/flor/punit/c_each.rb +19 -0
  115. data/lib/flor/punit/c_for_each.rb +2 -1
  116. data/lib/flor/punit/c_iterator.rb +2 -1
  117. data/lib/flor/punit/c_map.rb +1 -0
  118. data/lib/flor/punit/cancel.rb +10 -1
  119. data/lib/flor/punit/concurrence.rb +7 -5
  120. data/lib/flor/punit/cron.rb +1 -0
  121. data/lib/flor/punit/do_trap.rb +1 -0
  122. data/lib/flor/punit/every.rb +1 -0
  123. data/lib/flor/punit/graft.rb +1 -0
  124. data/lib/flor/punit/{m_ram.rb → m_receive_and_merge.rb} +5 -4
  125. data/lib/flor/punit/on_timeout.rb +1 -0
  126. data/lib/flor/punit/part.rb +1 -0
  127. data/lib/flor/punit/schedule.rb +1 -0
  128. data/lib/flor/punit/signal.rb +30 -5
  129. data/lib/flor/punit/sleep.rb +1 -0
  130. data/lib/flor/punit/task.rb +9 -2
  131. data/lib/flor/punit/trace.rb +1 -0
  132. data/lib/flor/punit/trap.rb +41 -1
  133. data/lib/flor/to_string.rb +1 -0
  134. data/lib/flor/tools/env.rb +1 -0
  135. data/lib/flor/tools/firb.rb +33 -0
  136. data/lib/flor/tools/shell.rb +13 -3
  137. data/lib/flor/tools/shell_out.rb +1 -0
  138. data/lib/flor/tt.rb +98 -0
  139. data/lib/flor/unit.rb +3 -0
  140. data/lib/flor/unit/caller.rb +158 -23
  141. data/lib/flor/unit/caller_jruby.rb +133 -0
  142. data/lib/flor/unit/dump.rb +36 -0
  143. data/lib/flor/unit/executor.rb +28 -18
  144. data/lib/flor/unit/ganger.rb +30 -18
  145. data/lib/flor/unit/gangers.rb +125 -0
  146. data/lib/flor/unit/hloader.rb +34 -7
  147. data/lib/flor/unit/hook.rb +3 -0
  148. data/lib/flor/unit/hooker.rb +32 -15
  149. data/lib/flor/unit/journal.rb +23 -0
  150. data/lib/flor/unit/loader.rb +142 -15
  151. data/lib/flor/unit/logger.rb +35 -7
  152. data/lib/flor/unit/models.rb +48 -10
  153. data/lib/flor/unit/models/execution.rb +51 -0
  154. data/lib/flor/unit/models/message.rb +6 -0
  155. data/lib/flor/unit/models/pointer.rb +1 -0
  156. data/lib/flor/unit/models/timer.rb +1 -0
  157. data/lib/flor/unit/models/trace.rb +1 -0
  158. data/lib/flor/unit/models/trap.rb +15 -6
  159. data/lib/flor/unit/scheduler.rb +211 -61
  160. data/lib/flor/unit/spooler.rb +1 -0
  161. data/lib/flor/unit/storage.rb +117 -73
  162. data/lib/flor/unit/taskers.rb +115 -1
  163. data/lib/flor/unit/waiter.rb +22 -17
  164. data/lib/flor/unit/wlist.rb +19 -8
  165. metadata +26 -45
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Define < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::DoReturn < Flor::Macro
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Echo < Flor::Procedure
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Empty < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Fail < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Flatten < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
data/lib/flor/pcore/if.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::If < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Includes < Flor::Procedure
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Iterator < Flor::Procedure
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Keys < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Length < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Loop < Flor::Pro::Cursor
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Map < Flor::Pro::Iterator
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Match < Flor::Pro::Case
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Matchr < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Max < Flor::Procedure
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Merge < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Move < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::NoEval < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::NoRet < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Not < Flor::Procedure
3
4
  #
data/lib/flor/pcore/on.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::On < Flor::Macro
3
4
  #
@@ -100,6 +101,20 @@ class Flor::Pro::On < Flor::Macro
100
101
  # If it were, it would trap the signal named "timeout".
101
102
  #
102
103
  #
104
+ # ## blocking mode
105
+ #
106
+ # When "on" is given no code block, it will block.
107
+ # ```
108
+ # sequence
109
+ # # ...
110
+ # on 'green' # execution (branch) blocks here until signal 'green' comes
111
+ # # ...
112
+ # ```
113
+ #
114
+ # Behind the scenes, it simply rewrites the "on" to a "trap" without a
115
+ # function, a blocking trap.
116
+ #
117
+ #
103
118
  # ## see also
104
119
  #
105
120
  # Trap and signal.
@@ -111,13 +126,13 @@ class Flor::Pro::On < Flor::Macro
111
126
  if att = find_catch # 22
112
127
  rewrite_as_catch_tree(att)
113
128
  else
114
- rewrite_as_trap_tree
129
+ rewrite_as_signal_trap_tree
115
130
  end
116
131
  end
117
132
 
118
133
  protected
119
134
 
120
- CATCHES = %w[ error cancel timeout ]
135
+ CATCHES = %w[ error cancel timeout ].freeze
121
136
 
122
137
  def find_catch
123
138
 
@@ -151,7 +166,7 @@ class Flor::Pro::On < Flor::Macro
151
166
  th
152
167
  end
153
168
 
154
- def rewrite_as_trap_tree
169
+ def rewrite_as_signal_trap_tree
155
170
 
156
171
  atts = att_children
157
172
  signame_i = atts.index { |at| at[1].size == 1 }
@@ -166,16 +181,26 @@ class Flor::Pro::On < Flor::Macro
166
181
  l = tree[2]
167
182
 
168
183
  th = [ 'trap', [], l, *tree[3] ]
184
+
169
185
  th[1] << [ '_att', [ [ 'point', [], l ], [ '_sqs', 'signal', l ] ], l ]
170
186
  th[1] << [ '_att', [ [ 'name', [], l ], tname ], l ]
171
- th[1] << [ '_att', [ [ 'payload', [], l ], [ '_sqs', 'event', l ] ], l ]
172
- atts.each { |ac| th[1] << Flor.dup(ac) }
173
187
 
174
- td = [ 'def', [], l ]
175
- td[1] << [ '_att', [ [ 'msg', [], l ] ], l ]
176
- non_att_children.each { |nac| td[1] << Flor.dup(nac) }
188
+ att_names = []
189
+ atts.each { |at|
190
+ att_names << at[1][0][0]
191
+ th[1] << Flor.dup(at) }
177
192
 
178
- th[1] << td
193
+ th[1] << [ '_att', [ [ 'payload', [], l ], [ '_sqs', 'event', l ] ], l ] \
194
+ unless att_names.include?('payload')
195
+
196
+ if (nac = non_att_children).any?
197
+
198
+ td = [ 'def', [], l ]
199
+ td[1] << [ '_att', [ [ 'msg', [], l ] ], l ]
200
+ non_att_children.each { |nac| td[1] << Flor.dup(nac) }
201
+
202
+ th[1] << td
203
+ end
179
204
 
180
205
  th
181
206
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::OnCancel < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::OnError < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Push < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Rand < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Range < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Reduce < Flor::Pro::Iterator
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Return < Flor::Procedure
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Reverse < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/pcore/iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Sequence < Flor::Procedure
3
4
  #
@@ -9,14 +10,62 @@ class Flor::Pro::Sequence < Flor::Procedure
9
10
  # task 'bravo' if f.amount > 2000
10
11
  # task 'charly'
11
12
  # ```
13
+ #
14
+ # Giving a string as attribute result to "sequence" lets it interpret
15
+ # that string as a tag name, as in:
16
+ # ```
17
+ # sequence 'phase one'
18
+ # alice 'gather customer requirements'
19
+ # bob 'establish offer'
20
+ # sequence 'phase two'
21
+ # alice 'present offer to customer'
22
+ # bob 'sign contract'
23
+ # ```
24
+ # It is equivalent to:
25
+ # ```
26
+ # sequence tag: 'phase one'
27
+ # alice 'gather customer requirements'
28
+ # bob 'establish offer'
29
+ # sequence tag: 'phase two'
30
+ # alice 'present offer to customer'
31
+ # bob 'sign contract'
32
+ # ```
33
+ # Learn more about [tags](../tags.md).
34
+ #
35
+ # Please note that it sets only 1 tag, and if there are already tags
36
+ # sets (`sequence tags: [ 'a' 'b' ] "this won't become a tag"`), it won't set
37
+ # further tags.
38
+ #
39
+ # ## see also
40
+ #
41
+ # Concurrence, loop
12
42
 
13
43
  names %w[ sequence begin ]
14
44
 
45
+ def receive_att
46
+
47
+ ms = []
48
+
49
+ ms = enter_tag \
50
+ if @node['tags'].nil? && payload_ret.is_a?(String) && from_unkeyed_att?
51
+
52
+ ms + super
53
+ end
54
+
15
55
  def cancel_when_closed
16
56
 
17
57
  return cancel if node_status_flavour == 'on-error'
18
58
 
19
59
  []
20
60
  end
61
+
62
+ protected
63
+
64
+ def enter_tag
65
+
66
+ @node['tags'] = tags = [ payload_ret ]
67
+
68
+ wrap('point' => 'entered', 'nid' => nid, 'tags' => tags)
69
+ end
21
70
  end
22
71
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Set < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Shuffle < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Slice < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Sort < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::SortBy < Flor::Pro::Iterator
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Split < Flor::Procedure
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Stall < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Strings < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::TimeStamp < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::ToArray < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Twig < Flor::Procedure
3
4