whenever-web 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/app/controllers/whenever/application_controller.rb +4 -0
- data/app/controllers/whenever/jobs_controller.rb +22 -0
- data/app/helpers/whenever/jobs_helper.rb +9 -0
- data/app/models/whenever/web_job.rb +28 -0
- data/app/models/whenever/web_job_list.rb +23 -0
- data/app/views/whenever/jobs/index.html.erb +70 -0
- data/config/routes.rb +4 -0
- data/lib/whenever/patches/job.rb +7 -0
- data/lib/whenever/patches/job_list.rb +9 -0
- data/lib/whenever/web.rb +9 -0
- data/whenever-web.gemspec +24 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27141e05c3c4d740cb86f492e3020d8e94b51620
|
4
|
+
data.tar.gz: 12c00e70b4ed91df4958713f0fbc8cff973acb63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a21685ad1ef1d40a4c7401bd9188b4e0b2477b3e8a3c032012d567e3d9f6c573468a4a94172cbd8168fd0de02a9d7571d3668c47205714bb7fb7af2d92b78003
|
7
|
+
data.tar.gz: cb9f0695618946ba651fe965d12497b229b008a7b0f6cbfe5ed12a16a93942a36c2dcd06435d78e8198c76c06502b452cf75b408192c0d6163527761094f4933
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Bartosz Kopiński
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Whenever Web
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
gem 'whenever-web'
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Mount the engine in your `routes.rb`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
MyApp::Application.routes.draw do
|
19
|
+
# ...
|
20
|
+
mount Whenever::Web, at: '/whenever'
|
21
|
+
# ...
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
And go to `/whenever`.
|
26
|
+
|
27
|
+
You can add a link to the panel in your views:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
= link_to 'Cron Jobs', whenever_path
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it (http://github.com/bartoszkopinski/whenever-web/fork)
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Whenever
|
2
|
+
class JobsController < ActionController::Base
|
3
|
+
before_filter :list_jobs
|
4
|
+
layout 'admin'
|
5
|
+
|
6
|
+
def index
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
job = @job_list.web_jobs.fetch(params[:id].to_i)
|
11
|
+
`#{job.command}`
|
12
|
+
flash[:notice] = job.command
|
13
|
+
redirect_to jobs_path
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def list_jobs
|
19
|
+
@job_list = WebJobList.new(file: 'config/schedule.rb')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'whenever/patches/job'
|
2
|
+
|
3
|
+
module Whenever
|
4
|
+
class WebJob
|
5
|
+
include ActionView::Helpers::DateHelper
|
6
|
+
attr_reader :interval, :job
|
7
|
+
|
8
|
+
def initialize job, interval
|
9
|
+
@job = job
|
10
|
+
@interval = interval
|
11
|
+
end
|
12
|
+
|
13
|
+
def description
|
14
|
+
@job.options.fetch(:description) {
|
15
|
+
@job.options[:task]
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def command
|
20
|
+
replacements = @job.options.map{ |k, v| [":#{k}", v] }.to_h
|
21
|
+
@job.template.gsub(/:\w+/, replacements)
|
22
|
+
end
|
23
|
+
|
24
|
+
def interval
|
25
|
+
distance_of_time_in_words(@interval)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'whenever/patches/job_list'
|
2
|
+
|
3
|
+
module Whenever
|
4
|
+
class WebJobList < JobList
|
5
|
+
attr_reader :set_variables
|
6
|
+
|
7
|
+
def web_jobs
|
8
|
+
@jobs.flat_map do |interval, jobs|
|
9
|
+
jobs.map do |job|
|
10
|
+
WebJob.new(job, interval)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def error_log
|
16
|
+
File.read(set_variables[:output][:error])
|
17
|
+
end
|
18
|
+
|
19
|
+
def standard_log
|
20
|
+
File.read(set_variables[:output][:standard])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<div class="panel panel-default">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<div class="panel-title">
|
4
|
+
Settings
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
<table class="table">
|
8
|
+
<thead>
|
9
|
+
<tr>
|
10
|
+
<% @job_list.set_variables.keys.each do |k| %>
|
11
|
+
<th><%= k.to_s.humanize %></th>
|
12
|
+
<% end %>
|
13
|
+
</tr>
|
14
|
+
</thead>
|
15
|
+
<tbody>
|
16
|
+
<tr>
|
17
|
+
<% @job_list.set_variables.values.each do |v| %>
|
18
|
+
<td><%= v %></td>
|
19
|
+
<% end %>
|
20
|
+
</tr>
|
21
|
+
</tbody>
|
22
|
+
</table>
|
23
|
+
</div>
|
24
|
+
<div class="panel panel-default">
|
25
|
+
<div class="panel-heading">
|
26
|
+
<div class="panel-title">
|
27
|
+
Cron jobs
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<table class="table">
|
31
|
+
<thead>
|
32
|
+
<tr>
|
33
|
+
<th>Task</th>
|
34
|
+
<th>Interval</th>
|
35
|
+
<th>Action</th>
|
36
|
+
</tr>
|
37
|
+
</thead>
|
38
|
+
<tbody>
|
39
|
+
<% @job_list.web_jobs.each_with_index do |job, i| %>
|
40
|
+
<tr>
|
41
|
+
<td><%= job.description %></td>
|
42
|
+
<td><%= job.interval %></td>
|
43
|
+
<td><%= link_to 'Run now', run_job_path(i), class: 'btn btn-danger', title: job.command %></td>
|
44
|
+
</tr>
|
45
|
+
<% end %>
|
46
|
+
</tbody>
|
47
|
+
</table>
|
48
|
+
</div>
|
49
|
+
<div class="panel panel-default">
|
50
|
+
<div class="panel-heading">
|
51
|
+
<div class="panel-title">
|
52
|
+
Error log
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
<%= text_area(:job_list, :error_log, rows: 15, class: 'form-control', disabled: 'disabled') %>
|
56
|
+
</div>
|
57
|
+
<div class="panel panel-default">
|
58
|
+
<div class="panel-heading">
|
59
|
+
<div class="panel-title">
|
60
|
+
Standard log
|
61
|
+
</div>
|
62
|
+
</div>
|
63
|
+
<%= text_area(:job_list, :standard_log, rows: 15, class: 'form-control', disabled: 'disabled') %>
|
64
|
+
</div>
|
65
|
+
<script type="text/javascript">
|
66
|
+
var error_log = document.getElementById('job_list_error_log');
|
67
|
+
var standard_log = document.getElementById('job_list_standard_log');
|
68
|
+
error_log.scrollTop = error_log.scrollHeight;
|
69
|
+
standard_log.scrollTop = standard_log.scrollHeight;
|
70
|
+
</script
|
data/config/routes.rb
ADDED
data/lib/whenever/web.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "whenever-web"
|
7
|
+
spec.version = "0.0.3"
|
8
|
+
spec.authors = ["Bartosz Kopinski"]
|
9
|
+
spec.email = ["bartosz.kopinski@gmail.pl"]
|
10
|
+
spec.summary = %q{Web GUI for Whenever gem}
|
11
|
+
spec.description = %q{Rails based web GUI for managing Whenever Cron jobs}
|
12
|
+
spec.homepage = "https://github.com/bartoszkopinski/whenever-web"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_dependency "rails"
|
23
|
+
spec.add_dependency "whenever"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whenever-web
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bartosz Kopinski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: whenever
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Rails based web GUI for managing Whenever Cron jobs
|
70
|
+
email:
|
71
|
+
- bartosz.kopinski@gmail.pl
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- app/controllers/whenever/application_controller.rb
|
82
|
+
- app/controllers/whenever/jobs_controller.rb
|
83
|
+
- app/helpers/whenever/jobs_helper.rb
|
84
|
+
- app/models/whenever/web_job.rb
|
85
|
+
- app/models/whenever/web_job_list.rb
|
86
|
+
- app/views/whenever/jobs/index.html.erb
|
87
|
+
- config/routes.rb
|
88
|
+
- lib/whenever/patches/job.rb
|
89
|
+
- lib/whenever/patches/job_list.rb
|
90
|
+
- lib/whenever/web.rb
|
91
|
+
- whenever-web.gemspec
|
92
|
+
homepage: https://github.com/bartoszkopinski/whenever-web
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.2.0.rc.1
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Web GUI for Whenever gem
|
116
|
+
test_files: []
|