flor 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/CREDITS.md +21 -0
- data/LICENSE.txt +4 -1
- data/Makefile +4 -0
- data/README.md +8 -0
- data/flor.gemspec +10 -10
- data/lib/flor.rb +2 -2
- data/lib/flor/changes.rb +3 -3
- data/lib/flor/colours.rb +14 -8
- data/lib/flor/conf.rb +63 -58
- data/lib/flor/core.rb +4 -4
- data/lib/flor/core/executor.rb +65 -29
- data/lib/flor/core/node.rb +37 -20
- data/lib/flor/core/procedure.rb +182 -40
- data/lib/flor/core/texecutor.rb +125 -52
- data/lib/flor/djan.rb +111 -82
- data/lib/flor/dollar.rb +31 -30
- data/lib/flor/flor.rb +314 -237
- data/lib/flor/id.rb +7 -2
- data/lib/flor/log.rb +250 -245
- data/lib/flor/parser.rb +72 -38
- data/lib/flor/pcore/_arr.rb +10 -10
- data/lib/flor/pcore/_att.rb +49 -14
- data/lib/flor/pcore/_coll.rb +18 -0
- data/lib/flor/pcore/_obj.rb +23 -7
- data/lib/flor/pcore/_pat_.rb +1 -1
- data/lib/flor/pcore/_pat_guard.rb +8 -0
- data/lib/flor/pcore/_pat_obj.rb +3 -3
- data/lib/flor/pcore/_pat_or.rb +4 -0
- data/lib/flor/pcore/_pat_regex.rb +24 -0
- data/lib/flor/pcore/_skip.rb +4 -0
- data/lib/flor/pcore/_val.rb +0 -1
- data/lib/flor/pcore/all.rb +111 -0
- data/lib/flor/pcore/any.rb +83 -0
- data/lib/flor/pcore/arith.rb +35 -6
- data/lib/flor/pcore/break.rb +39 -1
- data/lib/flor/pcore/case.rb +82 -4
- data/lib/flor/pcore/cmp.rb +7 -7
- data/lib/flor/pcore/collect.rb +50 -0
- data/lib/flor/pcore/cond.rb +17 -3
- data/lib/flor/pcore/cursor.rb +8 -2
- data/lib/flor/pcore/detect.rb +45 -0
- data/lib/flor/pcore/each.rb +52 -0
- data/lib/flor/pcore/empty.rb +60 -0
- data/lib/flor/pcore/filter.rb +94 -0
- data/lib/flor/pcore/find.rb +67 -0
- data/lib/flor/pcore/for_each.rb +65 -0
- data/lib/flor/pcore/includes.rb +32 -0
- data/lib/flor/pcore/inject.rb +55 -0
- data/lib/flor/pcore/iterator.rb +151 -0
- data/lib/flor/pcore/keys.rb +60 -0
- data/lib/flor/pcore/length.rb +34 -7
- data/lib/flor/pcore/logo.rb +18 -0
- data/lib/flor/pcore/loop.rb +4 -0
- data/lib/flor/pcore/map.rb +77 -46
- data/lib/flor/pcore/match.rb +8 -2
- data/lib/flor/pcore/matchr.rb +4 -5
- data/lib/flor/pcore/move.rb +3 -3
- data/lib/flor/pcore/noeval.rb +13 -0
- data/lib/flor/pcore/not.rb +16 -0
- data/lib/flor/pcore/on.rb +172 -0
- data/lib/flor/pcore/on_cancel.rb +54 -0
- data/lib/flor/pcore/on_error.rb +68 -0
- data/lib/flor/pcore/rand.rb +2 -2
- data/lib/flor/pcore/range.rb +2 -1
- data/lib/flor/pcore/reduce.rb +124 -0
- data/lib/flor/pcore/reverse.rb +46 -0
- data/lib/flor/pcore/select.rb +72 -0
- data/lib/flor/pcore/set.rb +8 -0
- data/lib/flor/pcore/stall.rb +10 -0
- data/lib/flor/pcore/to_array.rb +61 -0
- data/lib/flor/pcore/until.rb +34 -0
- data/lib/flor/punit/cancel.rb +30 -5
- data/lib/flor/punit/ccollect.rb +11 -0
- data/lib/flor/punit/cmap.rb +10 -5
- data/lib/flor/punit/concurrence.rb +42 -51
- data/lib/flor/punit/cron.rb +33 -0
- data/lib/flor/punit/do_trap.rb +42 -0
- data/lib/flor/punit/every.rb +48 -13
- data/lib/flor/punit/graft.rb +3 -3
- data/lib/flor/punit/on_timeout.rb +38 -0
- data/lib/flor/punit/schedule.rb +69 -6
- data/lib/flor/punit/signal.rb +54 -0
- data/lib/flor/punit/sleep.rb +1 -1
- data/lib/flor/punit/task.rb +4 -1
- data/lib/flor/punit/trap.rb +188 -13
- data/lib/flor/tools/shell.rb +408 -62
- data/lib/flor/tools/shell_out.rb +31 -0
- data/lib/flor/unit.rb +1 -1
- data/lib/flor/unit/caller.rb +177 -0
- data/lib/flor/unit/executor.rb +1 -0
- data/lib/flor/unit/ganger.rb +15 -21
- data/lib/flor/unit/hook.rb +1 -1
- data/lib/flor/unit/hooker.rb +22 -10
- data/lib/flor/unit/loader.rb +22 -22
- data/lib/flor/unit/logger.rb +63 -36
- data/lib/flor/unit/models.rb +6 -1
- data/lib/flor/unit/models/execution.rb +12 -1
- data/lib/flor/unit/models/message.rb +7 -0
- data/lib/flor/unit/models/trap.rb +31 -17
- data/lib/flor/unit/scheduler.rb +18 -10
- data/lib/flor/unit/storage.rb +83 -23
- data/lib/flor/unit/waiter.rb +1 -2
- metadata +96 -52
- data/lib/flor/deep.rb +0 -144
- data/lib/flor/punit/on.rb +0 -57
- data/lib/flor/unit/runner.rb +0 -84
- data/match.md +0 -22
data/lib/flor/punit/on.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
class Flor::Pro::On < Flor::Macro
|
3
|
-
#
|
4
|
-
# Traps a signal by name
|
5
|
-
#
|
6
|
-
# Turns
|
7
|
-
# ```
|
8
|
-
# on 'approve'
|
9
|
-
# task 'bob' mission: 'gather signatures'
|
10
|
-
# ```
|
11
|
-
# into
|
12
|
-
# ```
|
13
|
-
# trap point: 'signal', name: 'approve'
|
14
|
-
# set sig 'signal'
|
15
|
-
# def msg
|
16
|
-
# task 'bob' mission: 'gather signatures'
|
17
|
-
# ```
|
18
|
-
#
|
19
|
-
|
20
|
-
name 'on'
|
21
|
-
|
22
|
-
def rewrite_tree
|
23
|
-
|
24
|
-
atts = att_children
|
25
|
-
signame_i = atts.index { |at| at[1].size == 1 }
|
26
|
-
|
27
|
-
fail ArgumentError.new(
|
28
|
-
"signal name not found in #{tree.inspect}"
|
29
|
-
) unless signame_i
|
30
|
-
|
31
|
-
tname = atts[signame_i]
|
32
|
-
tname = Flor.dup(tname[1][0])
|
33
|
-
atts.delete_at(signame_i)
|
34
|
-
|
35
|
-
l = tree[2]
|
36
|
-
|
37
|
-
th = [ 'trap', [], l, *tree[3] ]
|
38
|
-
th[1] << [ '_att', [ [ 'point', [], l ], [ '_sqs', 'signal', l ] ], l ]
|
39
|
-
th[1] << [ '_att', [ [ 'name', [], l ], tname ], l ]
|
40
|
-
th[1] << [ '_att', [ [ 'payload', [], l ], [ '_sqs', 'event', l ] ], l ]
|
41
|
-
atts.each { |ac| th[1] << Flor.dup(ac) }
|
42
|
-
|
43
|
-
th[1] << [ 'set', [
|
44
|
-
[ '_att', [ [ 'sig', [], l ] ], l ],
|
45
|
-
tname
|
46
|
-
], l ]
|
47
|
-
|
48
|
-
td = [ 'def', [], l ]
|
49
|
-
td[1] << [ '_att', [ [ 'msg', [], l ] ], l ]
|
50
|
-
non_att_children.each { |nac| td[1] << Flor.dup(nac) }
|
51
|
-
|
52
|
-
th[1] << td
|
53
|
-
|
54
|
-
th
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
data/lib/flor/unit/runner.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
|
2
|
-
module Flor
|
3
|
-
|
4
|
-
class Runner
|
5
|
-
|
6
|
-
# NB: tasker configuration entries start with "rnr_"
|
7
|
-
|
8
|
-
def initialize(unit)
|
9
|
-
|
10
|
-
@unit = unit
|
11
|
-
end
|
12
|
-
|
13
|
-
def shutdown
|
14
|
-
end
|
15
|
-
|
16
|
-
def run(service, conf, message)
|
17
|
-
|
18
|
-
return ruby_run(service, conf, message) if conf['class'] || conf['module']
|
19
|
-
return cmd_run(service, conf, message) if conf['cmd']
|
20
|
-
|
21
|
-
fail ArgumentError.new("don't know how to run item at #{conf['_path']}")
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
def fjoin(root, path)
|
27
|
-
|
28
|
-
root == '.' ? path : File.join(root, path)
|
29
|
-
end
|
30
|
-
|
31
|
-
def ruby_run(service, conf, message)
|
32
|
-
|
33
|
-
root = File.dirname(conf['_path'])
|
34
|
-
|
35
|
-
Flor.h_fetch_a(conf, 'require').each { |pa|
|
36
|
-
fail ArgumentError.new('".." not allowed in paths') if pa =~ /\.\./
|
37
|
-
require(fjoin(root, pa)) }
|
38
|
-
Flor.h_fetch_a(conf, 'load').each { |pa|
|
39
|
-
fail ArgumentError.new('".." not allowed in paths') if pa =~ /\.\./
|
40
|
-
load(fjoin(root, pa)) }
|
41
|
-
|
42
|
-
k = Flor.const_lookup(conf['class'] || conf['module'])
|
43
|
-
|
44
|
-
o =
|
45
|
-
if k.class == Module
|
46
|
-
k
|
47
|
-
else
|
48
|
-
case k.instance_method(:initialize).arity
|
49
|
-
when 1 then k.new(service)
|
50
|
-
when 2 then k.new(service, conf)
|
51
|
-
when 3 then k.new(service, conf, message)
|
52
|
-
when -1 then k.new({
|
53
|
-
service: service, configuration: conf, message: message })
|
54
|
-
else k.new
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
p = message['point']
|
59
|
-
m = :on
|
60
|
-
m = "on_#{p}" if ! o.respond_to?(m)
|
61
|
-
m = p if ! o.respond_to?(m)
|
62
|
-
m = :cancel if m == 'detask' && ! o.respond_to?(m)
|
63
|
-
|
64
|
-
fail(
|
65
|
-
"#{k.class.to_s.downcase} #{k} doesn't respond to on, on_#{p} or #{p}"
|
66
|
-
) if ! o.respond_to?(m)
|
67
|
-
|
68
|
-
case o.method(m).arity
|
69
|
-
when 1 then o.send(m, message)
|
70
|
-
when 2 then o.send(m, conf, message)
|
71
|
-
when 3 then o.send(m, executor, conf, message)
|
72
|
-
when -1 then o.send(m, {
|
73
|
-
service: service, configuration: conf, message: message })
|
74
|
-
else o.send(m)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def cmd_run(service, conf, message)
|
79
|
-
|
80
|
-
fail NotImplementedError
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
data/match.md
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
|
2
|
-
```
|
3
|
-
match f.data
|
4
|
-
{ temperature: t }; register_temperature t
|
5
|
-
{ humidity: h }; register_humidity h
|
6
|
-
{ luminosity: l, period: 'am' }; register_morning_luminosity l
|
7
|
-
{ luminosity: l }; register_pm_luminosity l
|
8
|
-
```
|
9
|
-
|
10
|
-
or
|
11
|
-
|
12
|
-
```
|
13
|
-
cond
|
14
|
-
f.data.temperature; register_temperature f.data.temperature
|
15
|
-
f.data.humidity; register_humidity f.data.humidity
|
16
|
-
and \
|
17
|
-
luminosity
|
18
|
-
== period 'am'
|
19
|
-
register_morning_luminosity f.data.luminosity
|
20
|
-
f.data.luminosity; register_pm_luminosity f.data.luminosity
|
21
|
-
```
|
22
|
-
|