flack 1.2.2 → 1.3.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: 4d9d0e0a4f23254de0991624be2ebe850285978344df762944402b3f08d1a87c
4
- data.tar.gz: 13d2b858935b6f847723ec950382292ed85687079fad81463ea9bbe3636ea04c
3
+ metadata.gz: f3568a0f9f164613704ec78d2db777847180a5e6871dc77078aac09469506eed
4
+ data.tar.gz: f52a6ed6b32a249a98c5ac43d4d4178ea01a727995d6238efa458822502f9a81
5
5
  SHA512:
6
- metadata.gz: 82bfd2f08ae2f6025d0e658f34c67606bdc580c22a6a8e260b7e6bec57fcf27373eb693a577ec4b81fa180c2adeb8c7f1bff73694842b2a8fdfb9daa279db5c4
7
- data.tar.gz: 53dbb0a6a7ca8f1b79b988c328345bb865646ba6ae5aad3a3f26f1ddf59b80215b7b76fe8da4dea2bcdf6eb27da2a27912951de4e768cb363fe8ad82de9446d0
6
+ metadata.gz: 001a5dbaaebef7d8265b7a717da42972b1417eb1fc503e7ecc180c0320145038275a0ae7f6d51aa3fa6941757995147e96399844fbee04e648326d0008927fd3
7
+ data.tar.gz: cd6cd3d2952b87e8bd009b1bd6212889221a99a7e422a9865cab27398e567c290e7730f45a424e7c12c9c1d6ad30c08a9008a63337c0872e34f8d1d838189a4e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
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
+
5
16
  ## flack 1.2.2 released 2021-04-08
6
17
 
7
18
  - let #rel fall back on PATH_INFO if no REQUEST_PATH
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
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
- $(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
  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)
@@ -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
- qs = CGI.parse(env['QUERY_STRING'] || '')
15
- statuses = qs['status']
16
- statuses = nil if statuses == []
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
- respond(env, q.all)
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
- qs = CGI.parse(env['QUERY_STRING'] || '')
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
 
@@ -133,7 +133,7 @@ class Flack::App
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{?type}')
150
- link(env, h, 'pointers/{exid}{?type}')
151
- link(env, h, 'pointers/{domain}{?type}')
152
- link(env, h, 'pointers/{domain}*{?type}')
153
- link(env, h, 'pointers/{domain}.*{?type}')
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
 
@@ -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['xxx'] = @unit.queue({ 'point' => 'cancel', 'exid' => exid, 'nid' => nid }) # FIXME change me
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['xxx'] = @unit.queue({ 'point' => 'return', 'exid' => exid, 'nid' => nid, 'payload' => payload}) # FIXME change me
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)
@@ -10,6 +10,8 @@ class Flack::App
10
10
  # TODO implement paging
11
11
  env['flack.rel'] = 'flack:messages'
12
12
 
13
+ # TODO {?exid,dexid,count} like for /executions and /pointers
14
+
13
15
  respond(env, @unit.messages.all)
14
16
  end
15
17
 
@@ -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
- qs = CGI.parse(env['QUERY_STRING'] || '')
15
- types = qs['types'].collect { |e| e.split(',') }.flatten
16
- types = nil if types == []
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
- respond(env, q.all)
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
- qs = CGI.parse(env['QUERY_STRING'] || '')
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
 
data/lib/flack.rb CHANGED
@@ -9,7 +9,7 @@ require 'flor/unit'
9
9
 
10
10
  module Flack
11
11
 
12
- VERSION = '1.2.2'
12
+ VERSION = '1.3.0'
13
13
  end
14
14
 
15
15
  require 'flack/app'
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.2.2
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: 2021-04-08 00:00:00.000000000 Z
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.0.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: []