pult 0.0.7 → 0.0.8
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 +4 -4
- data/CHANGELOG.md +2 -2
- data/lib/init/req-proj.rb +0 -1
- data/lib/init/struct.rb +1 -3
- data/lib/pult/api/drawer.rb +96 -37
- data/lib/pult/api.rb +6 -2
- data/lib/pult/version.rb +1 -1
- metadata +2 -3
- data/lib/pult/api/drawer/helper.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96037cdff4cfc27b119180d4d7945ecd6c822c5d866fbd01f1e324dabd1dcbb8
|
4
|
+
data.tar.gz: 8e8eb4befec919c2dc4df105e27d10ae9015268abc254d00c7d840c4d51a4935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55bfef5c6532e1a3ab763209873dfbecaf44c057cd48c65e21a139da50281392f16715129d6979b2830b9705b35bf20e736bcc9b89aaeb48e2e2f425b48d952d
|
7
|
+
data.tar.gz: 5e43c50166fa7ef2e360d6a516851838a3e7308bc5f193636595ae1a9b7d88004e5ad293eb8c99a130a4c045c36c6c49c32999a0e31137a72b34c94fbcec1b63
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Done
|
2
2
|
|
3
|
-
- Ruby/Http interface to yml tasks
|
3
|
+
- Ruby/Http interface to yml tasks. Playground to 0.0.7
|
4
4
|
|
5
5
|
# Fixes and updates
|
6
6
|
|
7
7
|
- Fix and refactoring API
|
8
|
-
- Add Swagger
|
8
|
+
- Add JSON Swagger documentation for API
|
9
9
|
- Ruby version req
|
data/lib/init/req-proj.rb
CHANGED
data/lib/init/struct.rb
CHANGED
data/lib/pult/api/drawer.rb
CHANGED
@@ -1,64 +1,123 @@
|
|
1
1
|
class Pult::Api::Drawer
|
2
2
|
|
3
|
-
format :json
|
4
|
-
|
5
3
|
PREFIX = ENV['PULT_API_PREFIX'] || 'api'
|
6
4
|
|
5
|
+
format :json
|
6
|
+
|
7
7
|
prefix PREFIX
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
UI = {
|
10
|
+
red: ->(s){'<span style="color: red;">'+ s +'</span>'},
|
11
|
+
|
12
|
+
icon: {
|
13
|
+
job: '<b>‣ RUN JOB</b>',
|
14
|
+
run: '<b>‣ RUN</b>',
|
15
|
+
sep: ' | ',
|
16
|
+
},
|
17
|
+
|
18
|
+
title: {
|
19
|
+
get: ->{"#{@@injection}#{@@action_title}"},
|
20
|
+
post: ->{"#{@@injection}#{@@action_title} #{@@icon}"},
|
21
|
+
},
|
22
|
+
|
23
|
+
detail: {
|
24
|
+
get: ->{"#{@@injection}#{@@action_title}<br>#{@@command}"},
|
25
|
+
post: ->{"#{@@injection}#{@@action_title}<br>#{UI[:red].(@@command)}"}
|
26
|
+
}
|
27
|
+
}
|
11
28
|
|
12
|
-
|
13
|
-
|
29
|
+
helpers do
|
30
|
+
def path
|
31
|
+
route.pattern.origin
|
14
32
|
end
|
15
33
|
|
16
|
-
|
17
|
-
|
34
|
+
def action_get
|
35
|
+
/^\/(?<path>.+)$/ =~ path.sub(/^\/#{PREFIX}/, '')
|
36
|
+
@@panel._apply_path!(path, params)
|
37
|
+
end
|
18
38
|
|
19
|
-
|
39
|
+
def action_post
|
40
|
+
/^\/(?<path>.+)$/ =~ path.sub(/^\/#{PREFIX}/, '')
|
41
|
+
@@panel._apply_path!("#{path}!", params)
|
42
|
+
end
|
43
|
+
end
|
20
44
|
|
21
45
|
Runner = Pult::Panel::Injector::Runner
|
22
46
|
|
23
|
-
|
47
|
+
@@self = self
|
48
|
+
|
49
|
+
def self.draw! panel
|
50
|
+
@@panel = panel
|
24
51
|
|
25
|
-
|
52
|
+
for app in @@panel._apps
|
26
53
|
|
27
|
-
|
28
|
-
action_url = action.gsub '.', '/'
|
54
|
+
resource app do
|
29
55
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
action
|
34
|
-
end
|
35
|
-
end
|
56
|
+
flat_app = @@panel[app]._to_flat.merge!(@@panel[app])
|
57
|
+
|
58
|
+
for action in flat_app._actions.sort.reverse
|
59
|
+
action_url = action.gsub '.', '/'
|
36
60
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
61
|
+
for injection in Runner.read_injections.sort
|
62
|
+
@@self.info_get flat_app, action, injection
|
63
|
+
get("#{action_url}_#{injection}") { action_get }
|
64
|
+
end
|
65
|
+
|
66
|
+
for injection in Runner.run_injections.sort
|
67
|
+
@@self.info_post flat_app, action, injection
|
68
|
+
post("#{action_url}_#{injection}") { action_post }
|
69
|
+
end
|
70
|
+
|
71
|
+
@@self.info_get flat_app, action
|
72
|
+
get(action_url) { action_get }
|
73
|
+
|
74
|
+
@@self.info_post flat_app, action
|
75
|
+
post(action_url) { action_post }
|
41
76
|
end
|
42
|
-
end
|
43
77
|
|
44
|
-
|
45
|
-
|
46
|
-
action route
|
47
|
-
end
|
78
|
+
for action in flat_app._actions.sort.reverse
|
79
|
+
action_url = action.gsub '.', '/'
|
48
80
|
|
49
|
-
|
50
|
-
|
51
|
-
|
81
|
+
@@self.info_post flat_app, action, job: true
|
82
|
+
post("#{action_url}_job") { action_post }
|
83
|
+
end
|
52
84
|
end
|
53
85
|
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.info flat_app, action, injection, job, type:
|
89
|
+
@@action = action
|
90
|
+
@@action_title = flat_app._action_title(action)
|
91
|
+
@@command = flat_app[action].to_s
|
92
|
+
@@icon = job ? UI[:icon][:job] : UI[:icon][:run]
|
93
|
+
@@injection = injection&.sub!('_', '') ? "#{injection}#{UI[:icon][:sep]}" : ''
|
94
|
+
|
95
|
+
desc(UI[:title][type].call){ detail(UI[:detail][type].call) }
|
96
|
+
|
97
|
+
parameters if type == :post
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.parameters
|
101
|
+
params do
|
102
|
+
optional :screen, type: String
|
54
103
|
|
55
|
-
|
56
|
-
|
104
|
+
@@command.scan(/(?<=\$)[^\s()]+/).each do |param|
|
105
|
+
description = { type: String }
|
57
106
|
|
58
|
-
|
59
|
-
|
60
|
-
|
107
|
+
if ! (default = `echo -n $#{param}`).blank?
|
108
|
+
description.merge! default: default
|
109
|
+
end
|
110
|
+
|
111
|
+
requires param.to_sym, description
|
61
112
|
end
|
62
113
|
end
|
63
|
-
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.info_get flat_app, action, injection=nil, job: nil
|
117
|
+
info flat_app, action, injection, job, type: :get
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.info_post flat_app, action, injection=nil, job: nil
|
121
|
+
info flat_app, action, injection, job, type: :post
|
122
|
+
end
|
64
123
|
end
|
data/lib/pult/api.rb
CHANGED
data/lib/pult/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pult
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dmitryck
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -147,7 +147,6 @@ files:
|
|
147
147
|
- lib/pult.rb
|
148
148
|
- lib/pult/api.rb
|
149
149
|
- lib/pult/api/drawer.rb
|
150
|
-
- lib/pult/api/drawer/helper.rb
|
151
150
|
- lib/pult/api/server.rb
|
152
151
|
- lib/pult/cli.rb
|
153
152
|
- lib/pult/executor.rb
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module Pult::Api::Drawer::Helper
|
2
|
-
|
3
|
-
def self.included base
|
4
|
-
@@base = base
|
5
|
-
|
6
|
-
Grape::API::Instance.extend ClassMethods
|
7
|
-
|
8
|
-
base.helpers do
|
9
|
-
def path
|
10
|
-
route.pattern.origin
|
11
|
-
end
|
12
|
-
|
13
|
-
def panel
|
14
|
-
@@base.class_variable_get :@@panel
|
15
|
-
end
|
16
|
-
|
17
|
-
def action route
|
18
|
-
/^\/(?<path>.+)$/ =~ path.sub(/^\/#{@@base::PREFIX}/, '')
|
19
|
-
panel._apply_path!(path, params)
|
20
|
-
end
|
21
|
-
|
22
|
-
def action! route
|
23
|
-
/^\/(?<path>.+)$/ =~ path.sub(/^\/#{@@base::PREFIX}/, '')
|
24
|
-
panel._apply_path!("#{path}!", params)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
module ClassMethods
|
30
|
-
UI = {
|
31
|
-
red: ->(s){'<span style="color: red;">'+ s +'</span>'},
|
32
|
-
icon: {
|
33
|
-
job: '<b>‣ RUN JOB</b>',
|
34
|
-
run: '<b>‣ RUN</b>',
|
35
|
-
sep: ' | ',
|
36
|
-
},
|
37
|
-
title: {
|
38
|
-
get: ->{"#{@@injection}#{@@action_title}"},
|
39
|
-
post: ->{"#{@@injection}#{@@action_title} #{@@icon}"},
|
40
|
-
},
|
41
|
-
detail: {
|
42
|
-
get: ->{"#{@@injection}#{@@action_title}<br>#{@@command}"},
|
43
|
-
post: ->{"#{@@injection}#{@@action_title}<br>#{UI[:red].(@@command)}"}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
def info flat_app, action, injection, job, type:
|
48
|
-
@@action = action
|
49
|
-
@@action_title = flat_app._action_title(action)
|
50
|
-
@@command = flat_app[action].to_s
|
51
|
-
@@icon = job ? UI[:icon][:job] : UI[:icon][:run]
|
52
|
-
@@injection = injection&.sub!('_', '') ? "#{injection}#{UI[:icon][:sep]}" : ''
|
53
|
-
|
54
|
-
desc(UI[:title][type].call){ detail(UI[:detail][type].call) }
|
55
|
-
|
56
|
-
parameters if type == :post
|
57
|
-
end
|
58
|
-
|
59
|
-
def parameters
|
60
|
-
params do
|
61
|
-
optional :screen, type: String
|
62
|
-
|
63
|
-
@@command.scan(/(?<=\$)[^\s()]+/).each do |param|
|
64
|
-
description = { type: String }
|
65
|
-
|
66
|
-
if ! (default = `echo -n $#{param}`).blank?
|
67
|
-
description.merge! default: default
|
68
|
-
end
|
69
|
-
|
70
|
-
requires param.to_sym, description
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def info_get flat_app, action, injection=nil, job: nil
|
76
|
-
info flat_app, action, injection, job, type: :get
|
77
|
-
end
|
78
|
-
|
79
|
-
def info_post flat_app, action, injection=nil, job: nil
|
80
|
-
info flat_app, action, injection, job, type: :post
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|