pult 0.0.2 → 0.0.7

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: fd367496b6d462a76af84c19e96ad15319fce3fae5f67d34670d66db4660a118
4
- data.tar.gz: 84058482ed79fcad8f7967d98a35b9cd9483e19ac6b618e7c992127fc051f58e
3
+ metadata.gz: 7a1f2626325d559bee139156bf965999bc5f25c7bcc1982ee89d74542092873f
4
+ data.tar.gz: 2746f3c883cbf0c5bfb5f8501f2b56d558d283702443bf122560d3f0f1624f1d
5
5
  SHA512:
6
- metadata.gz: 2704d2fc2c0a748d2a03ae6a045654370da7ff5bee9bf9f5c6a30e63927353c572dd03c5a84b631f02d5986ae02bdbe70b27ca295ffc3bfa9198343604a177c0
7
- data.tar.gz: 861c1ab8c9846dfd9586f163f23fa1f2fd6190578a804acd5afd9763bfe63ce9ec9ec4c5d153692bd585025b4e9527f34a00035ffe62db324885c2e0b0264877
6
+ metadata.gz: d981f88ef4ed8e86f20ec8d20e908b0596111fa9e0dda770ee66b9953554b4669162d1cc8f024d8285364af452d15550f22f2636277423e3abd84d453efe847a
7
+ data.tar.gz: '08fbc15c24149cd6fdf616d60cfe769fe263585aca4dd663dbc3d4bc888ad44c9120b214adf7b2a2104f456f112ee38f3c092ac5bbd63ffb9c49e0366e411057'
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Done
2
+
3
+ - Ruby/Http interface to yml tasks (only development mode, just playground)
4
+
5
+ # Fixes and updates
6
+
7
+ - Fix and refactoring API
8
+ - Add Swagger doc rendering
9
+ - Ruby version req
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pult (0.1.0)
4
+ pult (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -34,6 +34,8 @@ GEM
34
34
  rack (>= 1.3.0)
35
35
  rack-accept
36
36
  virtus (>= 1.0.0)
37
+ grape-swagger (0.33.0)
38
+ grape (>= 0.16.2)
37
39
  i18n (1.6.0)
38
40
  concurrent-ruby (~> 1.0)
39
41
  ice_nine (0.11.2)
@@ -62,8 +64,10 @@ DEPENDENCIES
62
64
  activesupport (~> 5.2)
63
65
  bundler (~> 2.0)
64
66
  grape (~> 1.2)
67
+ grape-swagger (~> 0.33)
65
68
  minitest (~> 5.0)
66
69
  pult!
70
+ rack (~> 2.0)
67
71
  rake (~> 10.0)
68
72
 
69
73
  BUNDLED WITH
data/lib/init/req-lib.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'active_job'
2
2
  require 'grape'
3
+ require 'grape-swagger'
3
4
  require 'open3'
5
+ require 'rack'
4
6
  require 'yaml'
data/lib/init/req-proj.rb CHANGED
@@ -1,12 +1,20 @@
1
1
  require_relative '../pult/version'
2
+
2
3
  require_relative '../pult/cli'
3
- require_relative '../pult/executor'
4
+
5
+ require_relative '../pult/api'
6
+ require_relative '../pult/api/drawer/helper'
7
+ require_relative '../pult/api/drawer'
8
+ require_relative '../pult/api/server'
9
+
4
10
  require_relative '../pult/executor/enver'
11
+ require_relative '../pult/executor'
5
12
  require_relative '../pult/executor/screener'
6
13
  require_relative '../pult/executor/terminator'
14
+
15
+ require_relative '../pult/panel/dot_accessible'
7
16
  require_relative '../pult/panel'
8
17
  require_relative '../pult/panel/executor'
9
- require_relative '../pult/panel/dot_accessible'
10
18
  require_relative '../pult/panel/injector/app'
11
19
  require_relative '../pult/panel/injector/panel'
12
20
  require_relative '../pult/panel/injector/runner'
data/lib/init/struct.rb CHANGED
@@ -1,18 +1,27 @@
1
1
  module Pult
2
+ class Error < StandardError; end
3
+
2
4
  class Cli; end
3
5
 
6
+ module Api
7
+ class Drawer < Grape::API
8
+ module Helper; end
9
+ end
10
+ module Server; end
11
+ end
12
+
4
13
  class Executor
5
- class Job < ActiveJob::Base; end
6
14
  module Enver; end
15
+ class Job < ActiveJob::Base; end
7
16
  class Screener; end
8
17
  class Terminator; end
9
18
  end
10
19
 
11
20
  class Panel < Hash
21
+ module DotAccessible; end
12
22
  module Executor
13
23
  class Job < ActiveJob::Base; end
14
24
  end
15
- module DotAccessible; end
16
25
  module Injector
17
26
  module App; end
18
27
  module Panel; end
data/lib/pult.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require_relative 'init/boot'
2
2
 
3
3
  module Pult
4
- class Error < StandardError; end
5
- # Your code goes here...
4
+
5
+ def self.new *args
6
+ Panel.new *args
7
+ end
6
8
  end
data/lib/pult/api.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Pult::Api
2
+
3
+ def self.init! panel
4
+ Drawer.draw! panel
5
+ end
6
+
7
+ def self.server! *args
8
+ Server.run! *args, api: Drawer
9
+ end
10
+ end
@@ -0,0 +1,64 @@
1
+ class Pult::Api::Drawer
2
+
3
+ format :json
4
+
5
+ PREFIX = ENV['PULT_API_PREFIX'] || 'api'
6
+
7
+ prefix PREFIX
8
+
9
+ def self.draw! panel
10
+ @@panel = panel
11
+
12
+ for @@app in @@panel._apps
13
+ resource @@app, & ACTIONS
14
+ end
15
+
16
+ add_swagger_documentation
17
+ end
18
+
19
+ include Helper
20
+
21
+ Runner = Pult::Panel::Injector::Runner
22
+
23
+ ACTIONS = proc {
24
+
25
+ flat_app = @@panel[@@app]._to_flat.merge!(@@panel[@@app])
26
+
27
+ for action in flat_app._actions.sort.reverse
28
+ action_url = action.gsub '.', '/'
29
+
30
+ for injection in Runner.read_injections.sort
31
+ info_get flat_app, action, injection
32
+ get "#{action_url}_#{injection}" do
33
+ action route
34
+ end
35
+ end
36
+
37
+ for injection in Runner.run_injections.sort
38
+ info_post flat_app, action, injection
39
+ post "#{action_url}_#{injection}" do
40
+ action route
41
+ end
42
+ end
43
+
44
+ info_get flat_app, action
45
+ get action_url do
46
+ action route
47
+ end
48
+
49
+ info_post flat_app, action
50
+ post action_url do
51
+ action! route
52
+ end
53
+ end
54
+
55
+ for action in flat_app._actions.sort.reverse
56
+ action_url = action.gsub '.', '/'
57
+
58
+ info_post flat_app, action, job: true
59
+ post "#{action_url}_job" do
60
+ action! route
61
+ end
62
+ end
63
+ }
64
+ end
@@ -0,0 +1,83 @@
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>&#8227; RUN JOB</b>',
34
+ run: '<b>&#8227; 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
@@ -0,0 +1,8 @@
1
+ module Pult::Api::Server
2
+
3
+ PORT = ENV['PULT_API_PORT']&.to_i || 9292
4
+
5
+ def self.run! api:, port: PORT
6
+ Rack::Handler::WEBrick.run api, Port: port
7
+ end
8
+ end
data/lib/pult/executor.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  class Pult::Executor
2
2
 
3
- # ActiveJob::Base
4
3
  class Job
5
4
  def perform *args
6
5
  Pult::Executor.run! *args
@@ -1,5 +1,3 @@
1
- require 'open3'
2
-
3
1
  class Pult::Executor::Screener
4
2
 
5
3
  attr_reader :runner
data/lib/pult/panel.rb CHANGED
@@ -1,4 +1,3 @@
1
- # Hash
2
1
  class Pult::Panel
3
2
 
4
3
  include DotAccessible
@@ -1,6 +1,5 @@
1
1
  module Pult::Panel::Executor
2
2
 
3
- # ActiveJob::Base
4
3
  class Job
5
4
  def perform hash_id, action, *args
6
5
  hash = ObjectSpace._id2ref hash_id
data/lib/pult/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pult
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.7"
3
3
  end
data/pult.gemspec CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ RUBY_VERSION_REQ = '>= 2.3.0'
3
+
2
4
  lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require "pult/version"
@@ -13,6 +15,8 @@ Gem::Specification.new do |spec|
13
15
  spec.homepage = "https://github.com/dmitryck/pult"
14
16
  spec.license = "MIT"
15
17
 
18
+ spec.required_ruby_version = RUBY_VERSION_REQ
19
+
16
20
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
21
  # to allow pushing to a single host or delete this section to allow pushing to any host.
18
22
  if spec.respond_to?(:metadata)
@@ -39,5 +43,7 @@ Gem::Specification.new do |spec|
39
43
  spec.add_development_dependency "minitest", "~> 5.0"
40
44
  spec.add_development_dependency "activesupport", "~> 5.2"
41
45
  spec.add_development_dependency "activejob", "~> 5.2"
46
+ spec.add_development_dependency "rack", "~> 2.0"
42
47
  spec.add_development_dependency "grape", "~> 1.2"
48
+ spec.add_development_dependency "grape-swagger", "~> 0.33"
43
49
  end
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.2
4
+ version: 0.0.7
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-04 00:00:00.000000000 Z
11
+ date: 2019-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: grape
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '1.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: grape-swagger
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.33'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.33'
97
125
  description:
98
126
  email:
99
127
  - dmitryck@gmail.com
@@ -103,6 +131,7 @@ extra_rdoc_files: []
103
131
  files:
104
132
  - ".gitignore"
105
133
  - ".travis.yml"
134
+ - CHANGELOG.md
106
135
  - Gemfile
107
136
  - Gemfile.lock
108
137
  - LICENSE.txt
@@ -116,6 +145,10 @@ files:
116
145
  - lib/init/req-proj.rb
117
146
  - lib/init/struct.rb
118
147
  - lib/pult.rb
148
+ - lib/pult/api.rb
149
+ - lib/pult/api/drawer.rb
150
+ - lib/pult/api/drawer/helper.rb
151
+ - lib/pult/api/server.rb
119
152
  - lib/pult/cli.rb
120
153
  - lib/pult/executor.rb
121
154
  - lib/pult/executor/enver.rb
@@ -145,7 +178,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
178
  requirements:
146
179
  - - ">="
147
180
  - !ruby/object:Gem::Version
148
- version: '0'
181
+ version: 2.3.0
149
182
  required_rubygems_version: !ruby/object:Gem::Requirement
150
183
  requirements:
151
184
  - - ">="