flack 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +1 -1
- data/Makefile +4 -4
- data/README.md +11 -0
- data/lib/flack/app/executions.rb +16 -7
- data/lib/flack/app/helpers.rb +32 -8
- data/lib/flack/app/message.rb +4 -2
- data/lib/flack/app/messages.rb +2 -0
- data/lib/flack/app/pointers.rb +17 -8
- data/lib/flack/app.rb +5 -0
- data/lib/flack.rb +2 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3568a0f9f164613704ec78d2db777847180a5e6871dc77078aac09469506eed
|
4
|
+
data.tar.gz: f52a6ed6b32a249a98c5ac43d4d4178ea01a727995d6238efa458822502f9a81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 001a5dbaaebef7d8265b7a717da42972b1417eb1fc503e7ecc180c0320145038275a0ae7f6d51aa3fa6941757995147e96399844fbee04e648326d0008927fd3
|
7
|
+
data.tar.gz: cd6cd3d2952b87e8bd009b1bd6212889221a99a7e422a9865cab27398e567c290e7730f45a424e7c12c9c1d6ad30c08a9008a63337c0872e34f8d1d838189a4e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
# CHANGELOG.md
|
3
3
|
|
4
4
|
|
5
|
+
## flack 1.3.0 released 2023-03-29
|
6
|
+
|
7
|
+
- GET /pointers?count=true
|
8
|
+
- GET /executions?count=true
|
9
|
+
- GET /pointers?exid=net.ntt.finance-
|
10
|
+
- GET /pointers?dexid=20230310
|
11
|
+
- GET /executions?exid=net.ntt.finance-
|
12
|
+
- GET /executions?dexid=20230310
|
13
|
+
- Add Flack.on_unit_created(unit) callback
|
14
|
+
|
15
|
+
|
16
|
+
## flack 1.2.2 released 2021-04-08
|
17
|
+
|
18
|
+
- let #rel fall back on PATH_INFO if no REQUEST_PATH
|
19
|
+
|
20
|
+
|
5
21
|
## flack 1.2.1 released 2021-04-08
|
6
22
|
|
7
23
|
- Respond with a proper 500 error when necessary (and dump to $stderr)
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Copyright (c) 2016-
|
2
|
+
Copyright (c) 2016-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
|
-
|
6
|
-
VERSION
|
7
|
-
|
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
|
PORT = 7007
|
10
10
|
PID_FILE = tmp/$(NAME).pid
|
data/README.md
CHANGED
@@ -23,6 +23,17 @@ Warning: this serves an API, not some fancy web interface.
|
|
23
23
|
Based on HAL ([spec](http://stateless.co/hal_specification.html) and [draft](https://tools.ietf.org/html/draft-kelly-json-hal-08)), [URI Template](https://tools.ietf.org/html/rfc6570), and [CURIE](https://www.w3.org/TR/curie/).
|
24
24
|
|
25
25
|
|
26
|
+
## in a rack app
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
map '/flack' do
|
30
|
+
|
31
|
+
run Flack::App.new('flor/')
|
32
|
+
# starts a flack app whose flor unit uses the tree at flor/
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
|
26
37
|
## license
|
27
38
|
|
28
39
|
MIT, see [LICENSE.txt](LICENSE.txt)
|
data/lib/flack/app/executions.rb
CHANGED
@@ -5,20 +5,31 @@
|
|
5
5
|
class Flack::App
|
6
6
|
|
7
7
|
# GET /executions
|
8
|
+
# GET /executions?exid=<exid_prefix>
|
9
|
+
# GET /executions?dexid=<date_exid_prefix>
|
8
10
|
#
|
9
11
|
def get_executions(env)
|
10
12
|
|
11
13
|
# TODO implement paging
|
12
14
|
env['flack.rel'] = 'flack:executions'
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
statuses = query_values(env, 'statuses', 'status')
|
17
|
+
exid = query_value(env, 'exid')
|
18
|
+
dexid = query_value(env, 'dexid')
|
17
19
|
|
18
20
|
q = @unit.executions
|
21
|
+
#
|
19
22
|
q = q.where(status: statuses) if statuses
|
23
|
+
q = q.where(Sequel.like(:exid, "#{exid}%")) if exid
|
24
|
+
q = q.where(Sequel.like(:exid, "%-#{dexid}%")) if dexid
|
25
|
+
#
|
26
|
+
q = q.order(:exid)
|
20
27
|
|
21
|
-
|
28
|
+
if query_value(env, 'count')
|
29
|
+
respond(env, { count: q.count })
|
30
|
+
else
|
31
|
+
respond(env, q.all)
|
32
|
+
end
|
22
33
|
end
|
23
34
|
|
24
35
|
# GET /executions/<id>
|
@@ -98,9 +109,7 @@ class Flack::App
|
|
98
109
|
|
99
110
|
def get_executions_by_domain(env, dom)
|
100
111
|
|
101
|
-
|
102
|
-
statuses = qs['status']
|
103
|
-
statuses = nil if statuses == []
|
112
|
+
statuses = query_values(env, 'statuses', 'status')
|
104
113
|
|
105
114
|
q = @unit.executions
|
106
115
|
|
data/lib/flack/app/helpers.rb
CHANGED
@@ -126,14 +126,14 @@ class Flack::App
|
|
126
126
|
|
127
127
|
h = {}
|
128
128
|
|
129
|
-
h['self'] = {
|
130
|
-
|
129
|
+
h['self'] = { href: rel(env, env['REQUEST_PATH'] || env['PATH_INFO']) }
|
130
|
+
|
131
131
|
m = env['REQUEST_METHOD']
|
132
132
|
h['self'][:method] = m unless %w[ GET HEAD ].include?(m)
|
133
133
|
|
134
134
|
h['curies'] = CURIES
|
135
135
|
|
136
|
-
link(env, h, 'executions{?status}')
|
136
|
+
link(env, h, 'executions{?status,exid,dexid,count}')
|
137
137
|
link(env, h, 'executions/{domain}{?status}')
|
138
138
|
link(env, h, 'executions/{domain}*{?status}')
|
139
139
|
link(env, h, 'executions/{domain}.*{?status}')
|
@@ -146,11 +146,11 @@ class Flack::App
|
|
146
146
|
link(env, h, 'messages/{exid}')
|
147
147
|
link(env, h, 'messages/{id}')
|
148
148
|
|
149
|
-
link(env, h, 'pointers{?
|
150
|
-
link(env, h, 'pointers/{exid}{?
|
151
|
-
link(env, h, 'pointers/{domain}{?
|
152
|
-
link(env, h, 'pointers/{domain}*{?
|
153
|
-
link(env, h, 'pointers/{domain}.*{?
|
149
|
+
link(env, h, 'pointers{?types,exid,dexid,count}')
|
150
|
+
link(env, h, 'pointers/{exid}{?types}')
|
151
|
+
link(env, h, 'pointers/{domain}{?types}')
|
152
|
+
link(env, h, 'pointers/{domain}*{?types}')
|
153
|
+
link(env, h, 'pointers/{domain}.*{?types}')
|
154
154
|
|
155
155
|
h
|
156
156
|
end
|
@@ -189,5 +189,29 @@ class Flack::App
|
|
189
189
|
|
190
190
|
respond(env, {}, code: 500, error: error)
|
191
191
|
end
|
192
|
+
|
193
|
+
def query_value(env, *keys)
|
194
|
+
|
195
|
+
query = (env['__query'] ||= CGI.parse(env['QUERY_STRING'] || ''))
|
196
|
+
|
197
|
+
r = keys.collect { |k| query[k] }.compact.first
|
198
|
+
r ? r.first : r
|
199
|
+
end
|
200
|
+
|
201
|
+
def query_values(env, *keys)
|
202
|
+
|
203
|
+
query = (env['__query'] ||= CGI.parse(env['QUERY_STRING'] || ''))
|
204
|
+
|
205
|
+
r = keys
|
206
|
+
.collect { |k| query[k] }
|
207
|
+
.select { |v| v != [] }
|
208
|
+
.first
|
209
|
+
return nil unless r
|
210
|
+
|
211
|
+
r = r.first.split(',').select { |e| e.length > 0 }
|
212
|
+
return nil if r == []
|
213
|
+
|
214
|
+
r
|
215
|
+
end
|
192
216
|
end
|
193
217
|
|
data/lib/flack/app/message.rb
CHANGED
@@ -64,7 +64,8 @@ class Flack::App
|
|
64
64
|
return respond_not_found(env, 'missing execution node') \
|
65
65
|
unless exe.nodes[nid]
|
66
66
|
|
67
|
-
ret['
|
67
|
+
ret['queued'] = @unit.queue({
|
68
|
+
'point' => 'cancel', 'exid' => exid, 'nid' => nid })
|
68
69
|
|
69
70
|
ret['_status'] = 202
|
70
71
|
ret['_location'] = rel(env, '/executions/' + exid)
|
@@ -92,7 +93,8 @@ class Flack::App
|
|
92
93
|
return respond_not_found(env, 'missing execution node') \
|
93
94
|
unless exe.nodes[nid]
|
94
95
|
|
95
|
-
ret['
|
96
|
+
ret['queued'] = @unit.queue({
|
97
|
+
'point' => 'return', 'exid' => exid, 'nid' => nid, 'payload' => payload})
|
96
98
|
|
97
99
|
ret['_status'] = 202
|
98
100
|
ret['_location'] = rel(env, '/executions/' + exid)
|
data/lib/flack/app/messages.rb
CHANGED
data/lib/flack/app/pointers.rb
CHANGED
@@ -5,20 +5,32 @@
|
|
5
5
|
class Flack::App
|
6
6
|
|
7
7
|
# GET /pointers
|
8
|
+
# GET /pointers?exid=<exid_prefix>
|
9
|
+
# GET /pointers?dexid=<date_exid_prefix>
|
8
10
|
#
|
9
11
|
def get_pointers(env)
|
10
12
|
|
11
13
|
# TODO implement paging
|
12
14
|
env['flack.rel'] = 'flack:pointers'
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
types = query_values(env, 'types', 'type')
|
17
|
+
|
18
|
+
exid = query_value(env, 'exid')
|
19
|
+
dexid = query_value(env, 'dexid')
|
17
20
|
|
18
21
|
q = @unit.pointers
|
22
|
+
#
|
19
23
|
q = q.where(type: types) if types
|
24
|
+
q = q.where(Sequel.like(:exid, "#{exid}%")) if exid
|
25
|
+
q = q.where(Sequel.like(:exid, "%-#{dexid}%")) if dexid
|
26
|
+
#
|
27
|
+
q = q.order(:exid)
|
20
28
|
|
21
|
-
|
29
|
+
if query_value(env, 'count')
|
30
|
+
respond(env, { count: q.count })
|
31
|
+
else
|
32
|
+
respond(env, q.all)
|
33
|
+
end
|
22
34
|
end
|
23
35
|
|
24
36
|
# GET /pointers/<exid>
|
@@ -30,10 +42,7 @@ class Flack::App
|
|
30
42
|
|
31
43
|
arg = env['flack.args'][0]
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
types = qs['types'].collect { |e| e.split(',') }.flatten
|
36
|
-
types = nil if types == []
|
45
|
+
types = query_values(env, 'types', 'type')
|
37
46
|
|
38
47
|
if arg.count('-') == 0
|
39
48
|
get_pointers_by_domain(env, arg, types)
|
data/lib/flack/app.rb
CHANGED
@@ -29,6 +29,8 @@ class Flack::App
|
|
29
29
|
|
30
30
|
self.class.unit = @unit
|
31
31
|
|
32
|
+
Flack.on_unit_created(@unit) if Flack.respond_to?(:on_unit_created)
|
33
|
+
|
32
34
|
@unit
|
33
35
|
end
|
34
36
|
|
@@ -97,8 +99,11 @@ class Flack::App
|
|
97
99
|
|
98
100
|
$stderr.puts '=' * 80
|
99
101
|
$stderr.puts Time.now.to_s
|
102
|
+
$stderr.puts '-' * 80
|
100
103
|
$stderr.puts err.inspect
|
101
104
|
$stderr.puts err.backtrace
|
105
|
+
$stderr.puts '-' * 80
|
106
|
+
PP.pp(env, $stderr)
|
102
107
|
$stderr.puts ('=' * 79) + '.'
|
103
108
|
|
104
109
|
respond_internal_server_error(env, err)
|
data/lib/flack.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.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:
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flor
|
@@ -83,7 +83,7 @@ homepage: https://github.com/floraison/flack
|
|
83
83
|
licenses:
|
84
84
|
- MIT
|
85
85
|
metadata: {}
|
86
|
-
post_install_message:
|
86
|
+
post_install_message:
|
87
87
|
rdoc_options: []
|
88
88
|
require_paths:
|
89
89
|
- lib
|
@@ -98,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.33
|
102
|
+
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: a web front-end to the flor workflow engine
|
105
105
|
test_files: []
|