flack 0.10.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d42fb9e277d3a8bf5bd978c8294c8d74986d9407
4
- data.tar.gz: a37a1d7b1937a25b74d9cb082077142ecb7481a4
3
+ metadata.gz: 8f2ca07e71c90fdd19c0875131c9cda08d3ae33d
4
+ data.tar.gz: 72c65daabff31d1bdbce5d57ef811f821b13ac1b
5
5
  SHA512:
6
- metadata.gz: 23e4d246558e0d857d98e972f3380c353d8cddea2aa3b5ab58cba4d10e69f9a7b8d9d63375545126cc97accca4974522ef5eb4dd36790dda573939fa2642c385
7
- data.tar.gz: e8f2e007509dc2ca43d6097383d8372eb876cbf19d3cf7bd41b16495afe33020fb3b208ac6ab7133e1a7f149627ae5657b0c12ee170fb544fe4cc77353f2f36b
6
+ metadata.gz: 3d0e6ec432387fd794524a69b056913512666db33f3b0faa2ab8e6ff3ffca5b058769314f8029d3ed9da6a6b2c71f5f698dba54935f99bbd90925b5fe8bad5a5
7
+ data.tar.gz: 907862b56c9841faac7e617373d3324a9cbc0d9743d2c6d68435912ec7816769ac50930c6d5272d0f4dfd273aa70c36e5d79d2e2e39a288e622468d0a3aa157f
@@ -2,6 +2,22 @@
2
2
  # flack CHANGELOG.md
3
3
 
4
4
 
5
+ ## flack 0.16.1 released 2019-02-05
6
+
7
+ - Depend on Sequel 5 (Sequel 4 and 5 seem OK)
8
+ - GET /executions/:domain
9
+ - GET /executions/:domain*
10
+ - GET /executions/:domain.*
11
+ - GET /messages/:point
12
+ - GET /messages/:exid/:point
13
+ - GET /messages/:exid
14
+ - GET /messages/:id
15
+ - GET /executions/:exid
16
+ - GET /executions/:id
17
+
18
+
19
+ ## flack 0.10.0 released 2017-03-03
20
+
5
21
  ## flack 0.10.0 released 2017-03-03
6
22
 
7
23
  - Flack::App#shutdown (@unit.shutdown)
data/Makefile CHANGED
@@ -6,6 +6,9 @@ NAME = \
6
6
  VERSION = \
7
7
  $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version")
8
8
 
9
+ PORT = 7007
10
+ PID_FILE = tmp/$(NAME).pid
11
+
9
12
  count_lines:
10
13
  find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
11
14
  cl: count_lines
@@ -41,11 +44,29 @@ migrate:
41
44
  ## flack tasks
42
45
 
43
46
  serve:
44
- bundle exec rackup -p 7007
47
+ bundle exec rackup -p $(PORT)
45
48
  s: serve
46
49
 
47
50
  curl:
48
- curl -s http://127.0.0.1:7007/ | \
51
+ curl -s http://127.0.0.1:$(PORT)/ | \
49
52
  $(RUBY) -e "require 'json'; puts JSON.pretty_generate(JSON.load(STDIN.read))"
50
53
  c: curl
51
54
 
55
+ start:
56
+ @if [ ! -f $(PID_FILE) ]; then \
57
+ bundle exec rackup -p $(PORT) -P $(PID_FILE) -D; \
58
+ sleep 1; \
59
+ echo "listening on $(PORT), pid `cat $(PID_FILE)`"; \
60
+ else \
61
+ echo "already running at `cat $(PID_FILE)`"; \
62
+ fi
63
+
64
+ stop:
65
+ @if [ -f $(PID_FILE) ]; then \
66
+ echo "stopping flack pid `cat $(PID_FILE)`"; \
67
+ kill `cat $(PID_FILE)`; \
68
+ fi
69
+
70
+ restart:
71
+ @if [ -f $(PID_FILE) ]; then make -s stop; fi; make -s start
72
+
data/README.md CHANGED
@@ -6,10 +6,23 @@
6
6
 
7
7
  Flack is a Rack app for the [flor](https://github.com/floraison/flor) workflow engine.
8
8
 
9
+
10
+ ## test ride
11
+
12
+ ```sh
13
+ make migrate
14
+ make start
15
+ open http://localhost:7007/
16
+ ```
17
+
18
+ Warning: this serves an API, not some fancy web interface.
19
+
20
+
9
21
  ## api
10
22
 
11
23
  Based on HAL ([spec](http://stateless.co/hal_specification.html) and [draft](https://tools.ietf.org/html/draft-kelly-json-hal-08)).
12
24
 
25
+
13
26
  ## license
14
27
 
15
28
  MIT, see [LICENSE.txt](LICENSE.txt)
@@ -21,16 +21,20 @@ A web front-end to the flor workflow engine
21
21
 
22
22
  #s.files = `git ls-files`.split("\n")
23
23
  s.files = Dir[
24
+ 'README.{md,txt}',
25
+ 'CHANGELOG.{md,txt}', 'CREDITS.{md,txt}', 'LICENSE.{md,txt}',
24
26
  'Makefile',
25
27
  'lib/**/*.rb', #'spec/**/*.rb', 'test/**/*.rb',
26
- '*.gemspec', '*.txt', '*.rdoc', '*.md'
28
+ "#{s.name}.gemspec",
27
29
  ]
28
30
 
29
- flor_version = s.version.to_s.split('.').take(2).join('.')
30
- s.add_runtime_dependency 'flor', "~> #{flor_version}"
31
+ #flor_version = s.version.to_s.split('.').take(2).join('.')
32
+ #s.add_runtime_dependency 'flor', "~> #{flor_version}"
33
+ s.add_runtime_dependency 'flor'
31
34
 
32
35
  s.add_runtime_dependency 'rack', '~> 1.6'
33
- s.add_runtime_dependency 'sequel', '~> 4'
36
+ s.add_runtime_dependency 'sequel', '~> 5'
37
+ s.add_runtime_dependency 'httpclient', '~> 2.8'
34
38
 
35
39
  s.add_development_dependency 'rspec', '~> 3'
36
40
 
@@ -1,26 +1,3 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
1
 
25
2
  require 'rack'
26
3
 
@@ -29,7 +6,7 @@ require 'flor/unit'
29
6
 
30
7
  module Flack
31
8
 
32
- VERSION = '0.10.0'
9
+ VERSION = '0.16.1'
33
10
  end
34
11
 
35
12
  require 'flack/app'
@@ -1,26 +1,3 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
1
 
25
2
  require 'flack/app/helpers'
26
3
  #
@@ -28,6 +5,7 @@ require 'flack/app/index'
28
5
  require 'flack/app/static'
29
6
  require 'flack/app/message'
30
7
  require 'flack/app/executions'
8
+ require 'flack/app/messages'
31
9
 
32
10
 
33
11
  class Flack::App
@@ -81,7 +59,7 @@ class Flack::App
81
59
  match = true
82
60
  args = []
83
61
 
84
- for i in 0..flack_path_info.length - 1
62
+ for i in 0..(flack_path_info.length - 1)
85
63
 
86
64
  break unless match
87
65
 
@@ -95,8 +73,10 @@ class Flack::App
95
73
  args << pi.to_i
96
74
  elsif mi == 's'
97
75
  args << pi
76
+ elsif mi.is_a?(Regexp)
77
+ match = pi.match(mi)
98
78
  else
99
- match = pi == mi
79
+ match = (pi == mi)
100
80
  end
101
81
  end
102
82
 
@@ -119,7 +99,13 @@ class Flack::App
119
99
  .collect(&:to_s)
120
100
  .select { |m| m.match(/\A(get|head|put|post|delete)_.+\z/) }
121
101
  .select { |m| instance_method(m).arity == 1 }
122
- .collect { |m| s = m.split('_'); [ m, s.shift.upcase, s ] }
102
+ .collect { |m|
103
+ s = m.split('_')
104
+ if s.length == 3 && s[2] == 'suffix'
105
+ [ m, s.shift.upcase, [ /\.#{s[0]}\z/ ] ]
106
+ else
107
+ [ m, s.shift.upcase, s ]
108
+ end }
123
109
  .collect(&:freeze).freeze
124
110
  end
125
111
 
@@ -1,42 +1,80 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
1
 
26
2
  # /executions/*
27
3
  #
28
4
  class Flack::App
29
5
 
6
+ # GET /executions
7
+ #
30
8
  def get_executions(env)
31
9
 
32
10
  # TODO implement paging
11
+ env['flack.rel'] = 'flack:executions'
12
+
33
13
  respond(env, @unit.executions.all)
34
14
  end
35
15
 
16
+ # GET /executions/<id>
17
+ #
36
18
  def get_executions_i(env)
37
19
 
38
- # TODO
39
- debug_respond(env)
20
+ env['flack.rel'] = 'flack:executions/id'
21
+
22
+ if exe = @unit.executions[env['flack.args'][0]]
23
+ respond(env, exe)
24
+ else
25
+ respond_not_found(env)
26
+ end
27
+ end
28
+
29
+ # GET /executions/<exid>
30
+ # GET /executions/<domain>
31
+ # GET /executions/<domain>*
32
+ # GET /executions/<domain>.*
33
+ #
34
+ def get_executions_s(env)
35
+
36
+ arg = env['flack.args'][0]
37
+
38
+ if arg.count('-') == 0
39
+ get_executions_by_domain(env, arg)
40
+ else
41
+ get_executions_by_exid(env, arg)
42
+ end
43
+ end
44
+
45
+ protected
46
+
47
+ def get_executions_by_exid(env, exid)
48
+
49
+ env['flack.rel'] = 'flack:executions/exid'
50
+
51
+ if exe = @unit.executions[exid: exid]
52
+ respond(env, exe)
53
+ else
54
+ respond_not_found(env)
55
+ end
56
+ end
57
+
58
+ def get_executions_by_domain(env, dom)
59
+
60
+ q = @unit.executions
61
+
62
+ if m = dom.match(/\A([^*]+)\*+\z/)
63
+ if m[1][-1, 1] == '.'
64
+ env['flack.rel'] = 'flack:executions/domain-dot-star'
65
+ q = q.where(Sequel.like(:domain, "#{m[1]}%"))
66
+ else
67
+ env['flack.rel'] = 'flack:executions/domain-star'
68
+ q = q.where(
69
+ Sequel[{ domain: m[1] }] |
70
+ Sequel.like(:domain, "#{m[1]}.%"))
71
+ end
72
+ else
73
+ env['flack.rel'] = 'flack:executions/domain'
74
+ q = q.where(domain: dom)
75
+ end
76
+
77
+ respond(env, q.all)
40
78
  end
41
79
  end
42
80
 
@@ -1,27 +1,3 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
1
 
26
2
  # helpers
27
3
  #
@@ -38,7 +14,7 @@ class Flack::App
38
14
 
39
15
  o.is_a?(Array) &&
40
16
  o.length == 3 &&
41
- o[0].is_a?(Fixnum) &&
17
+ o[0].is_a?(Integer) &&
42
18
  o[1].is_a?(Hash) &&
43
19
  o[2].is_a?(Array)
44
20
  end
@@ -98,7 +74,13 @@ class Flack::App
98
74
  def serialize_array(env, data, opts)
99
75
 
100
76
  { '_links' => links(env),
101
- '_embedded' => data.collect { |e| serialize(env, e, opts) } }
77
+ '_embedded' => {
78
+ key(env) => data.collect { |e| serialize(env, e, opts) } } }
79
+ end
80
+
81
+ def key(env)
82
+
83
+ env['flack.rel'] || 'flack:unspecified-rel'
102
84
  end
103
85
 
104
86
  def determine_root_uri(env)
@@ -122,7 +104,15 @@ class Flack::App
122
104
 
123
105
  def link(env, h, type)
124
106
 
125
- h["flack:#{type}"] = { href: rel(env, "/#{type}") }
107
+ l = { href: rel(env, "/#{type}") }
108
+ l[:templated] = true if type.index('{')
109
+
110
+ rel_right_part = type
111
+ .gsub(/[{}]/, '')
112
+ .gsub(/\./, '-dot')
113
+ .gsub(/\*/, '-star')
114
+
115
+ h["flack:#{rel_right_part}"] = l
126
116
  end
127
117
 
128
118
  def links(env)
@@ -139,7 +129,18 @@ class Flack::App
139
129
  href: 'https://github.com/floraison/flack/blob/master/doc/rels.md#{rel}',
140
130
  templated: true }]
141
131
 
142
- link(env, h, :executions)
132
+ link(env, h, 'executions')
133
+ link(env, h, 'executions/{domain}')
134
+ link(env, h, 'executions/{domain}*')
135
+ link(env, h, 'executions/{domain}.*')
136
+ link(env, h, 'executions/{exid}')
137
+ link(env, h, 'executions/{id}')
138
+
139
+ link(env, h, 'messages')
140
+ link(env, h, 'messages/{point}')
141
+ link(env, h, 'messages/{exid}/{point}')
142
+ link(env, h, 'messages/{exid}')
143
+ link(env, h, 'messages/{id}')
143
144
 
144
145
  h
145
146
  end
@@ -1,27 +1,3 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
1
 
26
2
  # /
27
3
  #
@@ -1,27 +1,3 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
1
 
26
2
  # /message
27
3
  #
@@ -30,14 +6,13 @@ class Flack::App
30
6
  def post_message(env)
31
7
 
32
8
  msg = JSON.load(env['rack.input'].read)
33
- #pp msg
34
9
 
35
10
  pt = msg['point']
36
11
 
37
12
  return respond_bad_request(env, 'missing msg point') \
38
13
  unless pt
39
14
  return respond_bad_request(env, "bad msg point #{pt.inspect}") \
40
- unless %w[ launch cancel ].include?(pt)
15
+ unless %w[ launch cancel reply ].include?(pt)
41
16
 
42
17
  r = self.send("queue_#{pt}", env, msg, { point: pt })
43
18
 
@@ -48,16 +23,18 @@ class Flack::App
48
23
 
49
24
  def queue_launch(env, msg, ret)
50
25
 
51
- dom = msg['domain']
26
+ dom = msg['domain'] || 'domain0'
52
27
  src = msg['tree'] || msg['name']
28
+ vars = msg['vars'] || {}
29
+ fields = msg['fields'] || {}
53
30
 
54
- return respond_bad_request(env, 'missing domain') \
55
- unless dom
56
31
  return respond_bad_request(env, 'missing "tree" or "name" in launch msg') \
57
32
  unless src
58
33
 
59
34
  opts = {}
60
35
  opts[:domain] = dom
36
+ opts[:vars] = vars
37
+ opts[:fields] = fields
61
38
 
62
39
  r = @unit.launch(src, opts)
63
40
 
@@ -86,7 +63,35 @@ class Flack::App
86
63
  return respond_not_found(env, 'missing execution node') \
87
64
  unless exe.nodes[nid]
88
65
 
89
- ret['xxx'] = @unit.queue({ 'point' => 'cancel', 'exid' => exid, 'nid' => nid })
66
+ ret['xxx'] = @unit.queue({ 'point' => 'cancel', 'exid' => exid, 'nid' => nid }) # FIXME change me
67
+
68
+ ret['_status'] = 202
69
+ ret['_location'] = rel(env, '/executions/' + exid)
70
+ ret['_links'] = { 'flack:execution' => { 'href' => ret['_location'] } }
71
+
72
+ ret
73
+ end
74
+
75
+ def queue_reply(env, msg, ret)
76
+
77
+ exid = msg['exid']
78
+ nid = msg['nid']
79
+ payload = msg['payload'] || {}
80
+
81
+ return respond_bad_request(env, 'missing exid') \
82
+ unless exid
83
+
84
+ return respond_bad_request(env, 'missing nid') \
85
+ unless nid
86
+
87
+ exe = @unit.executions[exid: exid]
88
+
89
+ return respond_not_found(env, 'missing execution') \
90
+ unless exe
91
+ return respond_not_found(env, 'missing execution node') \
92
+ unless exe.nodes[nid]
93
+
94
+ ret['xxx'] = @unit.queue({ 'point' => 'return', 'exid' => exid, 'nid' => nid, 'payload' => payload}) # FIXME change me
90
95
 
91
96
  ret['_status'] = 202
92
97
  ret['_location'] = rel(env, '/executions/' + exid)
@@ -0,0 +1,68 @@
1
+
2
+ # /messages/*
3
+ #
4
+ class Flack::App
5
+
6
+ # GET /messages
7
+ def get_messages(env)
8
+
9
+ # TODO implement paging
10
+ env['flack.rel'] = 'flack:messages'
11
+
12
+ respond(env, @unit.messages.all)
13
+ end
14
+
15
+ # GET /messages/<id>
16
+ def get_messages_i(env)
17
+
18
+ env['flack.rel'] = 'flack:messages'
19
+
20
+ if exe = @unit.messages[env['flack.args'][0]]
21
+ respond(env, exe)
22
+ else
23
+ respond_not_found(env)
24
+ end
25
+ end
26
+
27
+ # GET /messages/<exid>
28
+ def get_messages_s(env)
29
+
30
+ # TODO implement paging
31
+ arg = env['flack.args'][0]
32
+
33
+ if Flor.point?(arg)
34
+ get_messages_by_point(env, arg)
35
+ else
36
+ get_messages_by_exid(env, arg)
37
+ end
38
+ end
39
+
40
+ # GET /messages/<exid>/<point>
41
+ def get_messages_s_s(env)
42
+
43
+ env['flack.rel'] = 'flack:messages/exid/point'
44
+
45
+ exid, point = env['flack.args']
46
+
47
+ respond(
48
+ env,
49
+ @unit.messages.where(exid: exid, point: point).all)
50
+ end
51
+
52
+ protected
53
+
54
+ def get_messages_by_exid(env, exid)
55
+
56
+ env['flack.rel'] = 'flack:messages/exid'
57
+
58
+ respond(env, @unit.messages.where(exid: exid).all)
59
+ end
60
+
61
+ def get_messages_by_point(env, point)
62
+
63
+ env['flack.rel'] = 'flack:messages/point'
64
+
65
+ respond(env, @unit.messages.where(point: point).all)
66
+ end
67
+ end
68
+
@@ -1,40 +1,22 @@
1
- #--
2
- # Copyright (c) 2016-2017, John Mettraux, jmettraux+flor@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
-
25
1
 
26
- # /static/+
2
+ # /*.html
3
+ # /*.css
4
+ # /*.js
27
5
  #
28
6
  class Flack::App
29
7
 
30
- RACK_FILE = Rack::File.new(
8
+ STATIC_FILE = Rack::File.new(
31
9
  File.absolute_path(
32
10
  File.join(
33
- File.dirname(__FILE__), '..')))
11
+ File.dirname(__FILE__), '..', 'static')))
34
12
 
35
- def get_static_plus(env)
13
+ def serve_file(env)
36
14
 
37
- RACK_FILE.call(env)
15
+ STATIC_FILE.call(env)
38
16
  end
17
+
18
+ alias get_html_suffix serve_file
19
+ alias get_css_suffix serve_file
20
+ alias get_js_suffix serve_file
39
21
  end
40
22
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.10'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4'
47
+ version: '5'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httpclient
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.8'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '4'
68
+ version: '2.8'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -77,8 +91,6 @@ files:
77
91
  - LICENSE.txt
78
92
  - Makefile
79
93
  - README.md
80
- - env.txt
81
- - env2.txt
82
94
  - flack.gemspec
83
95
  - lib/flack.rb
84
96
  - lib/flack/app.rb
@@ -86,8 +98,8 @@ files:
86
98
  - lib/flack/app/helpers.rb
87
99
  - lib/flack/app/index.rb
88
100
  - lib/flack/app/message.rb
101
+ - lib/flack/app/messages.rb
89
102
  - lib/flack/app/static.rb
90
- - t.txt
91
103
  homepage: http://github.com/floraison
92
104
  licenses:
93
105
  - MIT
@@ -108,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
120
  version: '0'
109
121
  requirements: []
110
122
  rubyforge_project:
111
- rubygems_version: 2.4.5.2
123
+ rubygems_version: 2.6.14.1
112
124
  signing_key:
113
125
  specification_version: 4
114
126
  summary: a web front-end to the flor workflow engine
data/env.txt DELETED
@@ -1,38 +0,0 @@
1
-
2
- GATEWAY_INTERFACE: "CGI/1.1"
3
- PATH_INFO: "/debug/77"
4
- QUERY_STRING: "a=b&c=d"
5
- REMOTE_ADDR: "::1"
6
- REMOTE_HOST: "localhost"
7
- REQUEST_METHOD: "GET"
8
- REQUEST_URI: "http://localhost:7007/debug/77?a=b&c=d"
9
- SCRIPT_NAME: ""
10
- SERVER_NAME: "localhost"
11
- SERVER_PORT: "7007"
12
- SERVER_PROTOCOL: "HTTP/1.1"
13
- SERVER_SOFTWARE: "WEBrick/1.3.1 (Ruby/1.9.3/2014-05-14)"
14
- HTTP_HOST: "localhost:7007"
15
- HTTP_CONNECTION: "keep-alive"
16
- HTTP_UPGRADE_INSECURE_REQUESTS: "1"
17
- HTTP_USER_AGENT: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
18
- HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
19
- HTTP_ACCEPT_ENCODING: "gzip, deflate, sdch"
20
- HTTP_ACCEPT_LANGUAGE: "ja,en-US;q=0.8,en;q=0.6,fr;q=0.4,de;q=0.2,it;q=0.2,zh-TW;q=0.2,zh;q=0.2"
21
- HTTP_COOKIE: "sg_dev=2ebdd63d694602c96834d5a261fc471732a2a44c37f40d6446c5cab1b724a263"
22
- rack.version: [1, 3]
23
- rack.input: #<Rack::Lint::InputWrapper:0x007fb27b230048 @input=#<StringIO:0x007fb27b238b30>>
24
- rack.errors: #<Rack::Lint::ErrorWrapper:0x007fb27b22fee0 @error=#<IO:<STDERR>>>
25
- rack.multithread: true
26
- rack.multiprocess: false
27
- rack.run_once: false
28
- rack.url_scheme: "http"
29
- rack.hijack?: true
30
- rack.hijack: #<Proc:0x007fb27b230ae8@/Users/jmettraux/.gem/ruby/1.9.3/gems/rack-1.6.4/lib/rack/lint.rb:525>
31
- rack.hijack_io: nil
32
- HTTP_VERSION: "HTTP/1.1"
33
- REQUEST_PATH: "/debug/77"
34
- rack.tempfiles: []
35
- flack.path_info: ["debug", "77"]
36
- flack.args: [77]
37
- flack.query_string: {"a"=>"b", "c"=>"d"}
38
-
data/env2.txt DELETED
@@ -1,33 +0,0 @@
1
- GATEWAY_INTERFACE:CGI/1.1
2
- PATH_INFO:/debug
3
- QUERY_STRING:
4
- REMOTE_ADDR:127.0.0.1
5
- REMOTE_HOST:localhost
6
- REQUEST_METHOD:GET
7
- REQUEST_URI:http://127.0.0.1:7007/flack/debug
8
- SCRIPT_NAME:/flack
9
- SERVER_NAME:127.0.0.1
10
- SERVER_PORT:7007
11
- SERVER_PROTOCOL:HTTP/1.1
12
- SERVER_SOFTWARE:WEBrick/1.3.1 (Ruby/1.9.3/2014-05-14)
13
- HTTP_HOST:127.0.0.1:7007
14
- HTTP_USER_AGENT:curl/7.43.0
15
- HTTP_ACCEPT:*/*
16
- rack.version:[1
17
- 3]
18
- rack.input:#<Rack::Lint::InputWrapper:0x007ff6baa373a8>
19
- rack.errors:#<Rack::Lint::ErrorWrapper:0x007ff6baa37290>
20
- rack.multithread:true
21
- rack.multiprocess:false
22
- rack.run_once:false
23
- rack.url_scheme:http
24
- rack.hijack?:true
25
- rack.hijack:#<Proc:0x007ff6baa38208@/Users/jmettraux/.gem/ruby/1.9.3/gems/rack-1.6.4/lib/rack/lint.rb:525>
26
- rack.hijack_io:null
27
- HTTP_VERSION:HTTP/1.1
28
- REQUEST_PATH:/flack/debug
29
- rack.tempfiles:[]
30
- flack.path_info:[debug]
31
- flack.args:[]
32
- flack.query_string:{}
33
- flack.root_uri:http://127.0.0.1:7007
data/t.txt DELETED
@@ -1,7 +0,0 @@
1
-
2
- https://git.io/viDSd
3
- https://goo.gl/xuOZcu
4
- http://tiny.cc/flack
5
-
6
- http://lambda.io/flack
7
-