pult 0.0.16 → 0.0.17
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 +10 -0
- data/README.md +7 -3
- data/lib/init/const.rb +7 -4
- data/lib/init/req-proj.rb +3 -0
- data/lib/init/struct.rb +4 -0
- data/lib/pult/panel.rb +11 -46
- data/lib/pult/panel/app.rb +36 -14
- data/lib/pult/panel/provider.rb +9 -0
- data/lib/pult/panel/provider/pult.rb +21 -0
- data/lib/pult/panel/provider/rake.rb +49 -0
- data/lib/pult/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9f1bcde4e6702f684b1d23bbb99e759027b39de1eac7b04d3a85d55ac16d2fc
|
4
|
+
data.tar.gz: b6ff29cc06748be7f82502506c0f897805a4455d9ac644fe54e6b74a944981b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea18e532c25a0866376ff008d931dd8c2ae63a3df35e6eddadaa758767aed0402bc2b441bfb28cc354500150f21df1bdb4ec98f9918d38a8c5769ff0f4480e1
|
7
|
+
data.tar.gz: 5da5043e7e5acaf42daccb519efbafe58502b75e35b945d5bd9d226781fa6d7c2122318937248fcafb8ed953143cc6aea4f9fa0a07bcc3fc2a2f1052a0c2e7d1
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.0.16] - 2019-22-09
|
8
|
+
### Status
|
9
|
+
- Dev version
|
10
|
+
|
11
|
+
### Updates
|
12
|
+
- Providers pattern for comliping panel hash
|
13
|
+
- `pult` provider added for `.pult.yml` (was, but not in pattern)
|
14
|
+
- `rake` provider added for rake tasks (**new**!)
|
15
|
+
- `PULT_RAKEPATH` env is `r` by default (prefix in API)
|
16
|
+
|
7
17
|
## [0.0.16] - 2019-19-09
|
8
18
|
### Status
|
9
19
|
- Dev version
|
data/README.md
CHANGED
@@ -6,6 +6,10 @@ Development progress can be reached at [CHANGELOG](./CHANGELOG.md)
|
|
6
6
|
|
7
7
|
Ruby *>= 2.3.0* require
|
8
8
|
|
9
|
+
```diff
|
10
|
+
- **TODO**: Refactor README (new concept, new feature)
|
11
|
+
```
|
12
|
+
|
9
13
|
# What is Pult?
|
10
14
|
|
11
15
|
Universal API service for manage your appications and system tasks via Ruby or HTTP.
|
@@ -39,11 +43,11 @@ Manage many applications is the feature of Pult. But to understand the concept a
|
|
39
43
|
|
40
44
|
### 1.1. Configure app actions via pult.yml
|
41
45
|
|
42
|
-
Put
|
46
|
+
Put `.pult.yml` into root of your app folder `<app>/.pult.yml` and create any actions you need for manage app:
|
43
47
|
```yaml
|
44
|
-
|
45
|
-
|
48
|
+
---
|
46
49
|
appname:
|
50
|
+
# actions is a simple linux shell commands
|
47
51
|
test: 'sleep 20 && echo 123'
|
48
52
|
|
49
53
|
# can combine actions of the same level
|
data/lib/init/const.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Pult
|
2
2
|
|
3
|
-
|
4
|
-
FILE = ENV['PULT_FILE'] || '.pult.yml'
|
3
|
+
FILE = ENV['PULT_FILE']
|
5
4
|
|
6
|
-
|
5
|
+
ROOT = ENV['PULT_ROOT'] || Dir.pwd
|
7
6
|
|
8
|
-
|
7
|
+
PORT = ENV['PULT_PORT'] || 7070
|
8
|
+
|
9
|
+
MULTIACT = ENV['PULT_MULTIACT'] || 'join' # 'clone'
|
10
|
+
|
11
|
+
RAKEPATH = ENV['PULT_RAKEPATH']
|
9
12
|
end
|
data/lib/init/req-proj.rb
CHANGED
@@ -9,6 +9,9 @@ require_relative '../pult/executor'
|
|
9
9
|
require_relative '../pult/executor/screener'
|
10
10
|
require_relative '../pult/executor/terminator'
|
11
11
|
|
12
|
+
require_relative '../pult/panel/provider'
|
13
|
+
require_relative '../pult/panel/provider/pult'
|
14
|
+
require_relative '../pult/panel/provider/rake'
|
12
15
|
require_relative '../pult/panel/dot_accessible'
|
13
16
|
require_relative '../pult/panel/injector'
|
14
17
|
require_relative '../pult/panel'
|
data/lib/init/struct.rb
CHANGED
data/lib/pult/panel.rb
CHANGED
@@ -6,70 +6,35 @@ class Pult::Panel
|
|
6
6
|
attr_accessor :_file
|
7
7
|
|
8
8
|
def initialize auto: true
|
9
|
+
@_file = Provider::Pult::FILE
|
9
10
|
@_root = Pult::ROOT
|
10
|
-
@_file = Pult::FILE
|
11
11
|
|
12
12
|
init! if auto && allow_init?
|
13
13
|
end
|
14
14
|
|
15
15
|
def init!
|
16
|
-
|
17
|
-
to_panel!
|
18
|
-
else
|
19
|
-
raise StandardError, 'Init is not allowed!'
|
20
|
-
end
|
16
|
+
allow_init? ? \
|
17
|
+
to_panel! : raise(StandardError, 'Init is not allowed!')
|
21
18
|
end
|
22
19
|
|
23
20
|
private
|
24
21
|
|
25
|
-
def allow_init?
|
26
|
-
true_abs_path?(@_file) || (!!@_root && !!@_file)
|
27
|
-
end
|
28
|
-
|
29
|
-
def true_abs_path? path
|
30
|
-
path[0] == '/' && File.exists(path)
|
31
|
-
end
|
32
|
-
|
33
22
|
def to_panel!
|
34
|
-
compile_from_pult_files!
|
35
|
-
|
36
23
|
class_eval { include DotAccessible }
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
make_apps!
|
41
|
-
end
|
42
|
-
|
43
|
-
def make_apps!
|
44
|
-
@_apps = []
|
45
|
-
|
46
|
-
for app_name in keys
|
47
|
-
app = self[app_name]
|
25
|
+
Provider::Pult.mixin! self
|
26
|
+
Provider::Rake.mixin! self
|
48
27
|
|
49
|
-
|
28
|
+
Injector.inject! self
|
50
29
|
|
51
|
-
|
52
|
-
end
|
30
|
+
App.make_apps! self
|
53
31
|
end
|
54
32
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
Dir[scan].each do |pult_file|
|
59
|
-
pult_hash = YAML.load_file(pult_file)
|
60
|
-
|
61
|
-
dir! pult_hash, pult_file
|
62
|
-
|
63
|
-
merge! pult_hash
|
64
|
-
end
|
33
|
+
def allow_init?
|
34
|
+
true_abs_path?(@_file) || (!!@_root && !!@_file)
|
65
35
|
end
|
66
36
|
|
67
|
-
def
|
68
|
-
|
69
|
-
dir = Pathname.new(path).dirname.to_s
|
70
|
-
|
71
|
-
config = (hash[app]['config'] ||= {})
|
72
|
-
|
73
|
-
config['dir'] ||= dir
|
37
|
+
def true_abs_path? path
|
38
|
+
path[0] == '/' && File.exists(path)
|
74
39
|
end
|
75
40
|
end
|
data/lib/pult/panel/app.rb
CHANGED
@@ -1,22 +1,44 @@
|
|
1
1
|
module Pult::Panel::App
|
2
2
|
|
3
|
-
def self.
|
4
|
-
|
3
|
+
def self.config_dir! app_hash, path
|
4
|
+
app_name = app_hash.keys.first
|
5
5
|
|
6
|
-
|
6
|
+
dir = Pathname.new(path).dirname.to_s
|
7
7
|
|
8
|
-
|
8
|
+
config = (app_hash[app_name]['config'] ||= {})
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
config['dir'] ||= dir
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.make_apps! panel
|
14
|
+
panel.instance_variable_set(:@_apps, [])
|
15
|
+
|
16
|
+
for app_name in panel.keys
|
17
|
+
hash = panel[app_name]
|
18
|
+
|
19
|
+
panel._apps << app_name
|
20
|
+
|
21
|
+
to_app! hash, panel, app_name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.to_app! app_hash, panel, app_name
|
26
|
+
multi_action! app_hash
|
27
|
+
|
28
|
+
app_hash.class_eval { include DotAccessible }
|
29
|
+
|
30
|
+
Injector.inject! app_hash, panel, app_name
|
31
|
+
|
32
|
+
app_hash.values.each do |target|
|
33
|
+
to_app!(target, panel, app_name) if target.is_a?(Hash)
|
12
34
|
end
|
13
35
|
|
14
|
-
|
36
|
+
app_hash
|
15
37
|
end
|
16
38
|
|
17
|
-
def self.multi_action!
|
18
|
-
|
19
|
-
value =
|
39
|
+
def self.multi_action! app_hash
|
40
|
+
app_hash.keys.each do |key|
|
41
|
+
value = app_hash[key]
|
20
42
|
|
21
43
|
case value.class.name
|
22
44
|
|
@@ -27,13 +49,13 @@ module Pult::Panel::App
|
|
27
49
|
case Pult::MULTIACT
|
28
50
|
|
29
51
|
when 'clone'
|
30
|
-
clone
|
52
|
+
clone app_hash
|
31
53
|
complex = {}
|
32
|
-
value.each{ |elm| complex[elm] =
|
33
|
-
|
54
|
+
value.each{ |elm| complex[elm] = app_hash[elm] }
|
55
|
+
app_hash[key] = complex
|
34
56
|
|
35
57
|
when 'join'
|
36
|
-
|
58
|
+
app_hash[key] = '$(' + value.join(') && $(') + ')'
|
37
59
|
end
|
38
60
|
end
|
39
61
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Pult::Panel::Provider::Pult
|
2
|
+
|
3
|
+
FILE = Pult::FILE || '.pult.yml'
|
4
|
+
|
5
|
+
def self.mixin! panel
|
6
|
+
pult_files = Pult::Panel::Provider.files(panel._file, panel._root)
|
7
|
+
|
8
|
+
Dir[pult_files].each do |pult_file|
|
9
|
+
|
10
|
+
hash = pult_hash pult_file
|
11
|
+
|
12
|
+
Pult::Panel::App.config_dir! hash, pult_file
|
13
|
+
|
14
|
+
panel.merge! hash
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.pult_hash file
|
19
|
+
YAML.load_file(file)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pult::Panel::Provider::Rake
|
2
|
+
|
3
|
+
FILE = 'Rakefile'
|
4
|
+
COMMAND = 'rake'
|
5
|
+
|
6
|
+
PATH = Pult::RAKEPATH || 'r'
|
7
|
+
|
8
|
+
def self.mixin! panel
|
9
|
+
rake_files = Pult::Panel::Provider.files(FILE, panel._root)
|
10
|
+
|
11
|
+
Dir[rake_files].each do |rake_file|
|
12
|
+
|
13
|
+
hash = pult_hash rake_file
|
14
|
+
|
15
|
+
Pult::Panel::App.config_dir! hash, rake_file
|
16
|
+
|
17
|
+
panel.merge! hash
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.pult_hash file
|
22
|
+
hash = {}
|
23
|
+
tasks = self.tasks(file)
|
24
|
+
|
25
|
+
for task in tasks
|
26
|
+
count = task.count(':')
|
27
|
+
|
28
|
+
n = -1
|
29
|
+
task.split(':').reduce(hash) do |h, t|
|
30
|
+
(n += 1) && n == count ? h[t] = "#{COMMAND} #{task}" : h[t] = {}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
{ PATH => hash }
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.tasks file
|
38
|
+
app_dir = Pathname.new(file).dirname.to_s
|
39
|
+
|
40
|
+
runner = Pult::Executor.run! "#{COMMAND} --tasks", app_dir
|
41
|
+
|
42
|
+
tasks = runner[:stdout].split(/\n/).map do |s|
|
43
|
+
s.sub(/^#{COMMAND} (\S+).*/, '\1')
|
44
|
+
end
|
45
|
+
|
46
|
+
# temp ignore params
|
47
|
+
tasks.map{ |t| t.sub /\[.+/, '' }
|
48
|
+
end
|
49
|
+
end
|
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.17
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,9 @@ files:
|
|
164
164
|
- lib/pult/panel/dot_accessible.rb
|
165
165
|
- lib/pult/panel/executor.rb
|
166
166
|
- lib/pult/panel/injector.rb
|
167
|
+
- lib/pult/panel/provider.rb
|
168
|
+
- lib/pult/panel/provider/pult.rb
|
169
|
+
- lib/pult/panel/provider/rake.rb
|
167
170
|
- lib/pult/panel/runner/dot_accessible.rb
|
168
171
|
- lib/pult/panel/runner/injector.rb
|
169
172
|
- lib/pult/version.rb
|