flor 0.18.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +3 -0
  3. data/CREDITS.md +1 -0
  4. data/LICENSE.txt +1 -1
  5. data/Makefile +1 -1
  6. data/README.md +15 -1
  7. data/flor.gemspec +1 -2
  8. data/lib/flor.rb +2 -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 +20 -16
  13. data/lib/flor/core/node.rb +1 -13
  14. data/lib/flor/core/procedure.rb +10 -1
  15. data/lib/flor/core/texecutor.rb +9 -2
  16. data/lib/flor/djan.rb +1 -0
  17. data/lib/flor/errors.rb +1 -0
  18. data/lib/flor/flor.rb +144 -15
  19. data/lib/flor/id.rb +1 -0
  20. data/lib/flor/log.rb +2 -1
  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 +1 -0
  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 +1 -0
  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 +4 -3
  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 +1 -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 +1 -0
  117. data/lib/flor/punit/c_map.rb +1 -0
  118. data/lib/flor/punit/cancel.rb +1 -0
  119. data/lib/flor/punit/concurrence.rb +1 -0
  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 +1 -0
  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 +1 -0
  129. data/lib/flor/punit/sleep.rb +1 -0
  130. data/lib/flor/punit/task.rb +1 -0
  131. data/lib/flor/punit/trace.rb +1 -0
  132. data/lib/flor/punit/trap.rb +10 -1
  133. data/lib/flor/to_string.rb +1 -0
  134. data/lib/flor/tools/env.rb +1 -0
  135. data/lib/flor/tools/shell.rb +1 -0
  136. data/lib/flor/tools/shell_out.rb +1 -0
  137. data/lib/flor/tt.rb +98 -0
  138. data/lib/flor/unit.rb +2 -0
  139. data/lib/flor/unit/caller.rb +152 -19
  140. data/lib/flor/unit/caller_jruby.rb +132 -0
  141. data/lib/flor/unit/dump.rb +36 -0
  142. data/lib/flor/unit/executor.rb +1 -0
  143. data/lib/flor/unit/ganger.rb +6 -12
  144. data/lib/flor/unit/hloader.rb +34 -7
  145. data/lib/flor/unit/hook.rb +3 -0
  146. data/lib/flor/unit/hooker.rb +32 -15
  147. data/lib/flor/unit/journal.rb +23 -0
  148. data/lib/flor/unit/loader.rb +102 -7
  149. data/lib/flor/unit/logger.rb +24 -5
  150. data/lib/flor/unit/models.rb +8 -1
  151. data/lib/flor/unit/models/execution.rb +51 -0
  152. data/lib/flor/unit/models/message.rb +1 -0
  153. data/lib/flor/unit/models/pointer.rb +1 -0
  154. data/lib/flor/unit/models/timer.rb +1 -0
  155. data/lib/flor/unit/models/trace.rb +1 -0
  156. data/lib/flor/unit/models/trap.rb +3 -2
  157. data/lib/flor/unit/scheduler.rb +35 -28
  158. data/lib/flor/unit/spooler.rb +1 -0
  159. data/lib/flor/unit/storage.rb +68 -44
  160. data/lib/flor/unit/taskers.rb +2 -1
  161. data/lib/flor/unit/waiter.rb +2 -1
  162. data/lib/flor/unit/wlist.rb +10 -8
  163. metadata +13 -10
@@ -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
 
@@ -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
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::On < Flor::Macro
3
4
  #
@@ -125,13 +126,13 @@ class Flor::Pro::On < Flor::Macro
125
126
  if att = find_catch # 22
126
127
  rewrite_as_catch_tree(att)
127
128
  else
128
- rewrite_as_trap_tree
129
+ rewrite_as_signal_trap_tree
129
130
  end
130
131
  end
131
132
 
132
133
  protected
133
134
 
134
- CATCHES = %w[ error cancel timeout ]
135
+ CATCHES = %w[ error cancel timeout ].freeze
135
136
 
136
137
  def find_catch
137
138
 
@@ -165,7 +166,7 @@ class Flor::Pro::On < Flor::Macro
165
166
  th
166
167
  end
167
168
 
168
- def rewrite_as_trap_tree
169
+ def rewrite_as_signal_trap_tree
169
170
 
170
171
  atts = att_children
171
172
  signame_i = atts.index { |at| at[1].size == 1 }
@@ -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
  #
@@ -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
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::TypeOf < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Until < Flor::Procedure
3
4
  #
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Flor::Pro::Abort < Flor::Procedure
4
+ #
5
+ # Cancels the current execution.
6
+ #
7
+ # Cancels all the root nodes at once. Is usually the equivalent of
8
+ # `cancel '0'` but sometimes the root nodes are gone...
9
+ #
10
+ # "kabort" is like "abort" but the cancel flavour is 'kill', so that
11
+ # cancel handlers are ignored.
12
+ #
13
+ # ```
14
+ # # ...
15
+ # cursor
16
+ # task 'prepare mandate'
17
+ # abort _ if f.outcome == 'reject'
18
+ # task 'sign mandate'
19
+ # # ...
20
+ # ```
21
+ #
22
+ # ## see also
23
+ #
24
+ # Cancel, kill
25
+
26
+ name 'abort', 'kabort'
27
+
28
+ def receive_last
29
+
30
+ fla = heap == 'kabort' ? 'kill' : 'cancel'
31
+
32
+ nodes = @execution['nodes']
33
+ nids = nodes.keys.dup
34
+
35
+ @execution['nodes'].values.each do |n|
36
+
37
+ #p n.select { |k, v| %w[ nid can parent cnodes ].include?(k) }
38
+ nid = n['nid']
39
+ pa = nodes[n['parent']]
40
+
41
+ nids.delete(nid) if pa && pa['cnodes'].include?(nid)
42
+ end
43
+ #p nids
44
+
45
+ wrap_cancel_nodes(nids, { 'flavour' => fla })
46
+ .each { |m| m['from'] = '9' }
47
+ # since '9' isn't the parent of any node
48
+ end
49
+ end
50
+
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Ccollect < Flor::Macro::Iterator
3
4
  #
@@ -1,5 +1,24 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Ceach < Flor::Macro::Iterator
4
+ #
5
+ # Concurrent "each".
6
+ #
7
+ # ```
8
+ # ceach [ alice bob charly ]
9
+ # task elt "prepare monthly report"
10
+ # ```
11
+ # which is equivalent to
12
+ # ```
13
+ # concurrence
14
+ # task 'alice' "prepare monthly report"
15
+ # task 'bob' "prepare monthly report"
16
+ # task 'charly' "prepare monthly report"
17
+ # ```
18
+ #
19
+ # ## see also
20
+ #
21
+ # For-each, c-map, and c-for-each.
3
22
 
4
23
  names %w[ ceach c-each ]
5
24
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/punit/c_iterator'
3
4
 
@@ -27,7 +28,7 @@ class Flor::Pro::CforEach < Flor::Pro::ConcurrentIterator
27
28
  #
28
29
  # ## see also
29
30
  #
30
- # For-each, cmap, and ceach.
31
+ # For-each, c-map, and c-each.
31
32
 
32
33
  name 'c-for-each'
33
34
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/punit/m_ram'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/punit/c_iterator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::Cancel < Flor::Procedure
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/punit/m_ram'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'flor/punit/schedule'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  class Flor::Pro::DoTrap < Flor::Macro
3
4
  #