running_station 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 10dc7cca61f5dfb887d3997f4bd1f537117c2d46393e1f88a69800fff321f29f
4
+ data.tar.gz: 9a2c48446c6fec3ca70e45b46f39756ba7b040be4f9313c4abcfc6cfb30af1ae
5
+ SHA512:
6
+ metadata.gz: 1172c75c8bb69f389e3354b1405caf95e1ff308637324cdd07fac46d3e6223d7cc61979a0a503d323eb4f72aaedfc9e599a0d172b8de9fefbc294c7fa85fe251
7
+ data.tar.gz: a0fef60cbdb1a16b7f2c004065ba6df71ca9af4425a5e64170f6e47e24c09b8aa20de7649a2298749c0a68eda537b4ec4f1cd81bf4d6ac3f5488a49c6e31b334
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 kimromi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # 🏃 RunningStation
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/running_station.svg)](https://badge.fury.io/rb/running_station)
4
+ [![Build Status](https://travis-ci.org/kimromi/running_station.svg?branch=master)](https://travis-ci.org/kimromi/running_station)
5
+
6
+ Rails runners(scripts) management for Ruby on Rails. made for Rails Mountable Engine.
7
+
8
+ ## Usage
9
+
10
+ ## Installation
11
+ Add this line to your Ruby on Rails application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'running_station'
15
+ ```
16
+
17
+ And then execute:
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ ## Config
23
+
24
+ Set your Ruby on Rails application.
25
+
26
+ ### config/routes.rb
27
+
28
+ ```ruby
29
+ mount RunningStation::Engine => "/running_station"
30
+ ```
31
+
32
+ for Device authentication example:
33
+
34
+ ```ruby
35
+ authenticate :user do
36
+ mount RunningStation::Engine => "/running_station"
37
+ end
38
+ ```
39
+
40
+ ### app/runners
41
+
42
+ Put on executable script file in app/runners with rails runner.
43
+
44
+ ## See runners list / Execute
45
+
46
+ http://your.rails.app/running_station
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "rdoc/task"
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "RunningStation"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
17
+ end
18
+
19
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
20
+ load "rails/tasks/engine.rake"
21
+
22
+ load "rails/tasks/statistics.rake"
23
+
24
+ require "bundler/gem_tasks"
25
+
26
+ require "rake/testtask"
27
+
28
+ Rake::TestTask.new(:test) do |t|
29
+ t.libs << "test"
30
+ t.pattern = "test/**/*_test.rb"
31
+ t.verbose = false
32
+ end
33
+
34
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/running_station .js
2
+ //= link_directory ../stylesheets/running_station .css
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ before_action :search_runners
7
+
8
+ private
9
+
10
+ def search_runners
11
+ @runners = Dir.glob(Rails.root + "app/runners/*.rb").map do |file|
12
+ File.basename(file).gsub(/\.rb$/, "")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module RunningStation
6
+ class RunnersController < ApplicationController
7
+ before_action :redirect_to_station_if_excluded_runners
8
+
9
+ def show
10
+ @runner = Runner.new(runner_params)
11
+ end
12
+
13
+ def update
14
+ @runner = Runner.new(runner_params)
15
+
16
+ @stdout, @stderr, @status = Open3.capture3(*["bin/rails", "runner", "#{@runner.full_path}"])
17
+ render :show
18
+ end
19
+
20
+ private
21
+
22
+ def runner_params
23
+ params.permit(:name)
24
+ end
25
+
26
+ def redirect_to_station_if_excluded_runners
27
+ if @runners.exclude?(runner_params[:name])
28
+ redirect_to running_station.root_path
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class StationController < ApplicationController
5
+ def index
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ module ApplicationHelper
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class ApplicationJob < ActiveJob::Base
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class ApplicationMailer < ActionMailer::Base
5
+ default from: "from@example.com"
6
+ layout "mailer"
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class ApplicationRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class Runner
5
+ include ActiveModel::Model
6
+
7
+ attr_accessor :name
8
+
9
+ def script_name
10
+ "#{name}.rb"
11
+ end
12
+
13
+ def full_path
14
+ Rails.root + "app/runners/#{script_name}"
15
+ end
16
+
17
+ def code
18
+ File.read(Rails.root + "app/runners/#{script_name}")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Running station</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "running_station/application", media: "all" %>
9
+ <%= javascript_include_tag "running_station/application" %>
10
+ </head>
11
+ <body>
12
+
13
+ <%= yield %>
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,28 @@
1
+ h2
2
+ span 🏃
3
+ = @runner.script_name
4
+
5
+ pre
6
+ code
7
+ = @runner.code
8
+
9
+ - unless @status
10
+ = form_tag(running_station.runner_path(@runner.name), method: :put)
11
+ button execute
12
+
13
+ - if @status
14
+ h3 exit code
15
+ p
16
+ = @status.exitstatus
17
+
18
+ - if @stdout
19
+ h3 stdout
20
+ pre
21
+ code
22
+ = @stdout
23
+
24
+ - if @stderr
25
+ h3 stderr
26
+ pre
27
+ code
28
+ = @stderr
@@ -0,0 +1,9 @@
1
+ - if @runners.empty?
2
+ p Not found runners!
3
+ p please set runner app/runners/[runner_name].rb
4
+ - else
5
+ ul
6
+ - @runners.each do |runner|
7
+ li
8
+ span 🏃
9
+ = link_to runner, running_station.runner_path(runner)
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ RunningStation::Engine.routes.draw do
4
+ root to: "station#index"
5
+
6
+ resources :runners, param: :name, only: %i(show update)
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace RunningStation
6
+
7
+ # require all dependencies
8
+ Gem.loaded_specs["running_station"].dependencies.each do |d|
9
+ require d.name if d.type == :runtime
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunningStation
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "running_station/engine"
4
+
5
+ module RunningStation
6
+ # Your code goes here...
7
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: running_station
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kimromi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: slim-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rails_config
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: runners management for rails
84
+ email:
85
+ - kimromi4@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - MIT-LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - app/assets/config/running_station_manifest.js
94
+ - app/assets/javascripts/running_station/application.js
95
+ - app/assets/stylesheets/running_station/application.css
96
+ - app/controllers/running_station/application_controller.rb
97
+ - app/controllers/running_station/runners_controller.rb
98
+ - app/controllers/running_station/station_controller.rb
99
+ - app/helpers/running_station/application_helper.rb
100
+ - app/jobs/running_station/application_job.rb
101
+ - app/mailers/running_station/application_mailer.rb
102
+ - app/models/running_station/application_record.rb
103
+ - app/models/running_station/runner.rb
104
+ - app/views/layouts/running_station/application.html.erb
105
+ - app/views/running_station/runners/show.html.slim
106
+ - app/views/running_station/station/index.html.slim
107
+ - config/routes.rb
108
+ - lib/running_station.rb
109
+ - lib/running_station/engine.rb
110
+ - lib/running_station/version.rb
111
+ homepage: https://github.com/kimromi/running_station
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.7.6
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: runners management for rails
135
+ test_files: []