flor 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 352d4347077550a9e577689e8b1f11ad90b7efb0d6fa14e99a228b634852c55f
4
- data.tar.gz: 81015d54353ff68b48108e09fdfc8933cae2b20ed48ccba1679bebc1b67258da
3
+ metadata.gz: b28e7de7c950544c32279d8a63917911ae9d12be4154a1bcc0539c8ae343b6d6
4
+ data.tar.gz: 1838e6d66710983c5adce4dc19b799bed0a34bf5427ee8156c516749d740e703
5
5
  SHA512:
6
- metadata.gz: c322beec0f868fbf72c79678227cbf2a2fea34611fe340b1fdd680a7d6b1f5a09246af1a78f6923977a061772ef22fc8d20d2d13a0bad2145991f296b4cfd143
7
- data.tar.gz: 3c3e2ce6a88acbaeeab0bb9d89f8c22e5dfd8fb1a81491f0d54983d21d692e3cd93262c842ed8dbc00e021b2fee1d5f3e3e791d8af72bfc6667c472d712d3541
6
+ metadata.gz: f75fd74bd118784e7cf3285bff5f55d4e97c67f4666332712dc9b878c267690247468372ec3970d6cff570f90f235b31ae182279aec87f77d442d7cfa1c6536a
7
+ data.tar.gz: 8c4b251c6bd1cc514580aae6430dcc70489ca046940e8a9e23104260f48be0a5049ac70310bcecfa3fdb62d00a8e603c644e177ab1db080e38bea04c1c538fa7
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## flor 1.6.0 released 2023-01-13
6
+
7
+ * Add #fei to Message, Pointer, Timer, Trace and Trap models
8
+ * Allow for // comments in Flor language
9
+ * Call post_task when tasker hands back task
10
+
11
+
5
12
  ## flor 1.5.0 released 2021-11-24
6
13
 
7
14
  * Add storage callbacks `on(:pointers, :any) { do_that }`
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2015-2021, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2015-2023, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
data/Makefile CHANGED
@@ -1,10 +1,10 @@
1
1
 
2
2
  ## gem tasks ##
3
3
 
4
- NAME = \
5
- $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.name")
6
- VERSION = \
7
- $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version")
4
+ NAME != \
5
+ ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.name"
6
+ VERSION != \
7
+ ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version"
8
8
 
9
9
  count_lines:
10
10
  find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
data/README.md CHANGED
@@ -47,7 +47,7 @@ require 'flor/unit'
47
47
  # uncomment to see the flor activity
48
48
 
49
49
  sto_uri = 'sqlite://flor_qs.db'
50
- sto_uri = 'jdbc:sqlite://flor_qs.db' if RUBY_PLATFORM.match(/java/)
50
+ sto_uri = 'jdbc:sqlite://flor_qs.db' if RUBY_PLATFORM.match?(/java/)
51
51
 
52
52
  flor = Flor::Unit.new(loader: Flor::HashLoader, sto_uri: sto_uri)
53
53
  # instantiate flor unit
data/lib/flor/colours.rb CHANGED
@@ -27,7 +27,7 @@ module Flor
27
27
  class Colours
28
28
 
29
29
  Flor::COLS.each do |k, v|
30
- if v.match(/\A\d/)
30
+ if v.match(/\A\d/) # Ruby 2.3 doesn't have String#match?
31
31
  class_eval(%{
32
32
  def #{k}(s=nil)
33
33
  s ? "[#{v}m" + s + "" : "[#{v}m"
@@ -42,7 +42,7 @@ module Flor
42
42
  class NoColours
43
43
 
44
44
  Flor::COLS.each do |k, v|
45
- if v.match(/\A\d/)
45
+ if v.match(/\A\d/) # Ruby 2.3 doesn't have String#match?
46
46
  class_eval("def #{k}(s=''); s; end")
47
47
  else
48
48
  class_eval("alias #{k} #{v}")
data/lib/flor/flor.rb CHANGED
@@ -199,7 +199,7 @@ module Flor
199
199
  def is_array_of_messages?(o)
200
200
 
201
201
  o.is_a?(Array) &&
202
- o.all? { |e| is_message?(o) }
202
+ o.all? { |e| is_message?(e) }
203
203
  end
204
204
 
205
205
  def h_fetch(h, *keys)
data/lib/flor/parser.rb CHANGED
@@ -6,6 +6,9 @@ module Flor
6
6
 
7
7
  #Raabro.pp(Flor::Parser.parse(input, debug: 2), colours: true)
8
8
  #Raabro.pp(Flor::Parser.parse(input, debug: 3), colours: true)
9
+ #
10
+ # turn one or the other when debugging the parser...
11
+
9
12
  opts = fname if fname.is_a?(Hash) && opts.empty?
10
13
 
11
14
  if r = Flor::Parser.parse(input, opts)
@@ -49,7 +52,7 @@ module Flor
49
52
  def semicolon(i); str(nil, i, ';'); end
50
53
  def comma(i); str(nil, i, ','); end
51
54
  def dquote(i); str(nil, i, '"'); end
52
- def slash(i); str(nil, i, '/'); end
55
+ def slash(i); rex(nil, i, /\/(?!\/)/); end
53
56
  def dollar(i); str(nil, i, '$'); end
54
57
  def pipepipe(i); str(nil, i, '||'); end
55
58
 
@@ -95,7 +98,11 @@ module Flor
95
98
  seq(nil, i, :dot, :rf_symbol)
96
99
  end
97
100
  def rf_index(i); alt(nil, i, :rf_dot_idx, :rf_sqa_idx); end
98
- def rf_symbol(i); rex(:refsym, i, /[^.:;| \b\f\n\r\t"',()\[\]{}#\\]+/); end
101
+ #
102
+ def rf_symbol(i)
103
+ rex(:refsym, i, /([^.:;| \b\f\n\r\t"',()\[\]{}#\\\/]|\/(?!\/))+/)
104
+ # anything but... a slash is ok, but not a double slash...
105
+ end
99
106
  #
100
107
  def reference(i); seq(:ref, i, :rf_symbol, :rf_index, '*'); end
101
108
 
@@ -165,7 +172,7 @@ module Flor
165
172
  }x)
166
173
  end
167
174
 
168
- def comment(i); rex(nil, i, /#[^\r\n]*/); end
175
+ def comment(i); rex(nil, i, /(#|\/\/)[^\r\n]*/); end
169
176
 
170
177
  def eol(i); seq(nil, i, :wstar, :comment, '?', :rnstar); end
171
178
  def eol_wstar(i); seq(nil, i, :wstar, :comment, '?', :rnstar, :wstar); end
@@ -210,7 +217,7 @@ module Flor
210
217
  # %w[ equ == != <> ], %w[ lgt < > <= >= ], %w[ sum + - ], %w[ prd * / % ],
211
218
 
212
219
  def ssmod(i); str(:sop, i, /%/); end
213
- def ssprd(i); rex(:sop, i, /[\*\/]/); end
220
+ def ssprd(i); rex(:sop, i, /(\*|\/(?!\/))/); end
214
221
  def sssum(i); rex(:sop, i, /[+-]/); end
215
222
  def sslgt(i); rex(:sop, i, /(<=?|>=?)/); end
216
223
  def ssequ(i); rex(:sop, i, /(==?|!=|<>)/); end
@@ -110,10 +110,16 @@ module Flor
110
110
  pt = message['point']
111
111
 
112
112
  ms = [ "call_#{pt}", "on_#{pt}", :on_message, :on, pt ]
113
- ms = ms + [ :on_cancel, :cancel ] if pt == 'detask'
113
+ case pt
114
+ when 'detask' then ms = ms + [ :on_cancel, :cancel ]
115
+ when 'return' then ms = [ :on_return, :return, :post_task ] # /!\
116
+ end
114
117
 
115
118
  m = ms.find { |mm| o.respond_to?(mm) }
116
119
 
120
+ return [ message ] if pt == 'return' && ! m
121
+ # don't call if :post_task not present
122
+
117
123
  fail(
118
124
  "#{k.class.to_s.downcase} #{k} doesn't respond to " +
119
125
  ms[0..-2].collect { |e| "##{e}" }.join(', ') + ", or ##{ms[-1]}"
@@ -316,10 +322,12 @@ module Flor
316
322
 
317
323
  def to_messages(o)
318
324
 
319
- case o
320
- when Hash then [ o ]
321
- when Array then o
322
- else []
325
+ if Flor.is_array_of_messages?(o)
326
+ o
327
+ elsif Flor.is_message?(o)
328
+ [ o ]
329
+ else
330
+ []
323
331
  end
324
332
  end
325
333
 
@@ -48,7 +48,7 @@ module Flor
48
48
 
49
49
  protected
50
50
 
51
- CLOSING_POINTS = %w[ task terminated ceased ]
51
+ CLOSING_POINTS = %w[ task terminated ceased ].freeze
52
52
  #
53
53
  # point for messages that, after consumption, are conserved
54
54
  # in the execution's "closing_messages" array
@@ -160,14 +160,18 @@ module Flor
160
160
  def return(message)
161
161
 
162
162
  n = @execution['nodes'][message['nid']] || {}
163
- m = n['message'] || {}
164
- c = m['cause']
163
+ c = (n['message'] || {})['cause']
165
164
 
166
- rm = message.dup
167
- rm['point'] = 'receive'
168
- rm['cause'] = c if c # preserve 'cause' for routing
165
+ ms =
166
+ if n['task']
167
+ @unit.ganger.task(self, message)
168
+ else
169
+ [ message.dup ]
170
+ end
169
171
 
170
- [ rm ]
172
+ ms.each { |m|
173
+ m['point'] = 'receive'
174
+ m['cause'] = c if c }
171
175
  end
172
176
 
173
177
  def schedule(message)
@@ -47,16 +47,14 @@ module Flor
47
47
  def task(executor, message)
48
48
 
49
49
  domain = message['exid'].split('-', 2).first
50
- tname = message['tasker']
50
+ #tname = message['tasker']
51
+ tname = determine_tasker_name(executor, message)
51
52
 
52
53
  tconf =
53
54
  ( ! message['routed'] &&
54
55
  (@unit.loader.tasker(domain, 'ganger', message) ||
55
56
  @unit.loader.tasker(domain, 'tasker', message))) ||
56
57
  @unit.loader.tasker(domain, tname, message)
57
- #puts "=" * 80
58
- #pp tconf
59
- #puts "=" * 80
60
58
 
61
59
  fail ArgumentError.new(
62
60
  "tasker #{tname.inspect} not found"
@@ -66,6 +64,7 @@ module Flor
66
64
 
67
65
  points = [ nil, message['point'] ]
68
66
  points << 'detask' if points.include?('cancel')
67
+ points << 'task' if points.include?('return')
69
68
 
70
69
  tconf = tconf.find { |h| points.include?(h['point']) }
71
70
  end
@@ -154,6 +153,17 @@ module Flor
154
153
 
155
154
  vars
156
155
  end
156
+
157
+ def determine_tasker_name(executor, message)
158
+
159
+ tname = message['tasker']
160
+
161
+ return tname if tname
162
+
163
+ n = executor.node(message)
164
+
165
+ n['task']['tasker']
166
+ end
157
167
  end
158
168
  end
159
169
 
@@ -24,6 +24,8 @@ module Flor
24
24
  def nid; data['nid']; end
25
25
  def tasker; data['tasker']; end
26
26
  alias payload data
27
+
28
+ def fei; [ exid, nid ].join('-') rescue nil; end
27
29
  end
28
30
  end
29
31
 
@@ -29,6 +29,8 @@ module Flor
29
29
  # # we don't care, pointers are cleaned anyway when the flow dies
30
30
  #end
31
31
 
32
+ def fei; [ exid, nid ].join('-'); end
33
+
32
34
  # If the pointer is a "var" pointer, returns the full value
33
35
  # for the variable, as found in the execution's node "0".
34
36
  #
@@ -27,6 +27,8 @@ module Flor
27
27
  # index [ :exid, :nid ]
28
28
  #end
29
29
 
30
+ def fei; [ exid, nid ].join('-'); end
31
+
30
32
  def to_trigger_message
31
33
 
32
34
  d = self.data(false)
@@ -17,6 +17,8 @@ module Flor
17
17
  #
18
18
  # index :exid
19
19
  #end
20
+
21
+ def fei; [ exid, nid ].join('-') rescue nil; end
20
22
  end
21
23
  end
22
24
 
@@ -34,6 +34,8 @@ module Flor
34
34
  # index [ :exid, :nid ]
35
35
  #end
36
36
 
37
+ def fei; [ exid, nid ].join('-') rescue nil; end
38
+
37
39
  def to_hook
38
40
 
39
41
  opts = {}
@@ -908,11 +908,11 @@ module Flor
908
908
  fail ArgumentError.new("no 'sto_uri' conf, cannot connect to db") \
909
909
  unless uri
910
910
 
911
- return Kernel.const_get(uri) \
912
- if uri.is_a?(String) && uri.match(/\A[A-Z]+\z/)
913
- # for cases where uri == 'DB'
914
-
915
- Sequel.connect(uri)
911
+ begin
912
+ Kernel.const_get(uri)
913
+ rescue NameError
914
+ Sequel.connect(uri)
915
+ end
916
916
  end
917
917
 
918
918
  def connect
@@ -169,9 +169,12 @@ module Flor
169
169
 
170
170
  pt = @message['point']
171
171
 
172
- ms = [ "post_#{pt}" ]; ms << :post_cancel if pt == 'detask'
172
+ #ms = [ "post_#{pt}" ]; ms << :post_cancel if pt == 'detask'
173
+ #call_one_of(ms)
173
174
  #
174
- call_one_of(ms)
175
+ # :post_task is called by, well, the caller
176
+ #
177
+ call_one_of([ :post_detask, :post_cancel ]) if pt == 'detask'
175
178
 
176
179
  msg = derive_message(message)
177
180
 
data/lib/flor.rb CHANGED
@@ -16,7 +16,7 @@ require 'dense'
16
16
 
17
17
  module Flor
18
18
 
19
- VERSION = '1.5.0'
19
+ VERSION = '1.6.0'
20
20
  end
21
21
 
22
22
  require 'flor/colours'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-24 00:00:00.000000000 Z
11
+ date: 2023-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: munemo
@@ -290,7 +290,7 @@ metadata:
290
290
  mailing_list_uri: https://groups.google.com/forum/#!forum/floraison
291
291
  homepage_uri: https://github.com/floraison/flor
292
292
  source_code_uri: https://github.com/floraison/flor
293
- post_install_message:
293
+ post_install_message:
294
294
  rdoc_options: []
295
295
  require_paths:
296
296
  - lib
@@ -305,8 +305,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0'
307
307
  requirements: []
308
- rubygems_version: 3.0.3
309
- signing_key:
308
+ rubygems_version: 3.1.6
309
+ signing_key:
310
310
  specification_version: 4
311
311
  summary: A Ruby workflow engine
312
312
  test_files: []