mirror of
https://github.com/plashchynski/crono.git
synced 2026-04-23 17:28:45 +02:00
Use Rails plugin generator and adapt
This commit is contained in:
197
Gemfile.lock
197
Gemfile.lock
@@ -2,77 +2,170 @@ PATH
|
|||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
crono (1.1.2)
|
crono (1.1.2)
|
||||||
activerecord (>= 4.0)
|
rails (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
rspec (>= 3.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
activemodel (5.0.0.1)
|
actioncable (6.1.2)
|
||||||
activesupport (= 5.0.0.1)
|
actionpack (= 6.1.2)
|
||||||
activerecord (5.0.0.1)
|
activesupport (= 6.1.2)
|
||||||
activemodel (= 5.0.0.1)
|
nio4r (~> 2.0)
|
||||||
activesupport (= 5.0.0.1)
|
websocket-driver (>= 0.6.1)
|
||||||
arel (~> 7.0)
|
actionmailbox (6.1.2)
|
||||||
activesupport (5.0.0.1)
|
actionpack (= 6.1.2)
|
||||||
|
activejob (= 6.1.2)
|
||||||
|
activerecord (= 6.1.2)
|
||||||
|
activestorage (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
mail (>= 2.7.1)
|
||||||
|
actionmailer (6.1.2)
|
||||||
|
actionpack (= 6.1.2)
|
||||||
|
actionview (= 6.1.2)
|
||||||
|
activejob (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
mail (~> 2.5, >= 2.5.4)
|
||||||
|
rails-dom-testing (~> 2.0)
|
||||||
|
actionpack (6.1.2)
|
||||||
|
actionview (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
rack (~> 2.0, >= 2.0.9)
|
||||||
|
rack-test (>= 0.6.3)
|
||||||
|
rails-dom-testing (~> 2.0)
|
||||||
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||||
|
actiontext (6.1.2)
|
||||||
|
actionpack (= 6.1.2)
|
||||||
|
activerecord (= 6.1.2)
|
||||||
|
activestorage (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
nokogiri (>= 1.8.5)
|
||||||
|
actionview (6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
builder (~> 3.1)
|
||||||
|
erubi (~> 1.4)
|
||||||
|
rails-dom-testing (~> 2.0)
|
||||||
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||||
|
activejob (6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
globalid (>= 0.3.6)
|
||||||
|
activemodel (6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
activerecord (6.1.2)
|
||||||
|
activemodel (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
activestorage (6.1.2)
|
||||||
|
actionpack (= 6.1.2)
|
||||||
|
activejob (= 6.1.2)
|
||||||
|
activerecord (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
marcel (~> 0.3.1)
|
||||||
|
mimemagic (~> 0.3.2)
|
||||||
|
activesupport (6.1.2)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (~> 0.7)
|
i18n (>= 1.6, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (>= 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 2.0)
|
||||||
arel (7.1.4)
|
zeitwerk (~> 2.3)
|
||||||
byebug (9.0.6)
|
builder (3.2.4)
|
||||||
concurrent-ruby (1.0.2)
|
byebug (11.1.3)
|
||||||
daemons (1.2.4)
|
concurrent-ruby (1.1.8)
|
||||||
diff-lcs (1.2.5)
|
crass (1.0.6)
|
||||||
haml (4.0.7)
|
daemons (1.3.1)
|
||||||
tilt
|
diff-lcs (1.4.4)
|
||||||
i18n (0.7.0)
|
erubi (1.10.0)
|
||||||
minitest (5.9.1)
|
globalid (0.4.2)
|
||||||
rack (1.6.5)
|
activesupport (>= 4.2.0)
|
||||||
rack-protection (1.5.3)
|
i18n (1.8.8)
|
||||||
rack
|
concurrent-ruby (~> 1.0)
|
||||||
rack-test (0.6.3)
|
loofah (2.9.0)
|
||||||
rack (>= 1.0)
|
crass (~> 1.0.2)
|
||||||
rake (11.3.0)
|
nokogiri (>= 1.5.9)
|
||||||
rspec (3.5.0)
|
mail (2.7.1)
|
||||||
rspec-core (~> 3.5.0)
|
mini_mime (>= 0.1.1)
|
||||||
rspec-expectations (~> 3.5.0)
|
marcel (0.3.3)
|
||||||
rspec-mocks (~> 3.5.0)
|
mimemagic (~> 0.3.2)
|
||||||
rspec-core (3.5.4)
|
method_source (1.0.0)
|
||||||
rspec-support (~> 3.5.0)
|
mimemagic (0.3.5)
|
||||||
rspec-expectations (3.5.0)
|
mini_mime (1.0.2)
|
||||||
|
minitest (5.14.3)
|
||||||
|
nio4r (2.5.5)
|
||||||
|
nokogiri (1.11.1-arm64-darwin)
|
||||||
|
racc (~> 1.4)
|
||||||
|
racc (1.5.2)
|
||||||
|
rack (2.2.3)
|
||||||
|
rack-test (1.1.0)
|
||||||
|
rack (>= 1.0, < 3)
|
||||||
|
rails (6.1.2)
|
||||||
|
actioncable (= 6.1.2)
|
||||||
|
actionmailbox (= 6.1.2)
|
||||||
|
actionmailer (= 6.1.2)
|
||||||
|
actionpack (= 6.1.2)
|
||||||
|
actiontext (= 6.1.2)
|
||||||
|
actionview (= 6.1.2)
|
||||||
|
activejob (= 6.1.2)
|
||||||
|
activemodel (= 6.1.2)
|
||||||
|
activerecord (= 6.1.2)
|
||||||
|
activestorage (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
bundler (>= 1.15.0)
|
||||||
|
railties (= 6.1.2)
|
||||||
|
sprockets-rails (>= 2.0.0)
|
||||||
|
rails-dom-testing (2.0.3)
|
||||||
|
activesupport (>= 4.2.0)
|
||||||
|
nokogiri (>= 1.6)
|
||||||
|
rails-html-sanitizer (1.3.0)
|
||||||
|
loofah (~> 2.3)
|
||||||
|
railties (6.1.2)
|
||||||
|
actionpack (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
|
method_source
|
||||||
|
rake (>= 0.8.7)
|
||||||
|
thor (~> 1.0)
|
||||||
|
rake (13.0.3)
|
||||||
|
rspec (3.10.0)
|
||||||
|
rspec-core (~> 3.10.0)
|
||||||
|
rspec-expectations (~> 3.10.0)
|
||||||
|
rspec-mocks (~> 3.10.0)
|
||||||
|
rspec-core (3.10.1)
|
||||||
|
rspec-support (~> 3.10.0)
|
||||||
|
rspec-expectations (3.10.1)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.10.0)
|
||||||
rspec-mocks (3.5.0)
|
rspec-mocks (3.10.2)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.10.0)
|
||||||
rspec-support (3.5.0)
|
rspec-support (3.10.2)
|
||||||
sinatra (1.4.7)
|
sprockets (4.0.2)
|
||||||
rack (~> 1.5)
|
concurrent-ruby (~> 1.0)
|
||||||
rack-protection (~> 1.4)
|
rack (> 1, < 3)
|
||||||
tilt (>= 1.3, < 3)
|
sprockets-rails (3.2.2)
|
||||||
sqlite3 (1.3.12)
|
actionpack (>= 4.0)
|
||||||
thread_safe (0.3.5)
|
activesupport (>= 4.0)
|
||||||
tilt (2.0.5)
|
sprockets (>= 3.0.0)
|
||||||
timecop (0.8.1)
|
sqlite3 (1.4.2)
|
||||||
tzinfo (1.2.2)
|
thor (1.1.0)
|
||||||
thread_safe (~> 0.1)
|
timecop (0.9.4)
|
||||||
|
tzinfo (2.0.4)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
|
websocket-driver (0.7.3)
|
||||||
|
websocket-extensions (>= 0.1.0)
|
||||||
|
websocket-extensions (0.1.5)
|
||||||
|
zeitwerk (2.4.2)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
arm64-darwin-20
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bundler (>= 1.0.0)
|
bundler (>= 1.0.0)
|
||||||
byebug
|
byebug
|
||||||
crono!
|
crono!
|
||||||
daemons
|
daemons
|
||||||
haml
|
|
||||||
rack-test
|
rack-test
|
||||||
rake (>= 10.0)
|
rake (>= 10.0)
|
||||||
rspec (>= 3.0)
|
rspec (>= 3.0)
|
||||||
sinatra
|
|
||||||
sqlite3
|
sqlite3
|
||||||
timecop (>= 0.7)
|
timecop (>= 0.7)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.13.6
|
2.2.7
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -171,19 +171,13 @@ There are "start", "stop", and "restart" commands.
|
|||||||
|
|
||||||
## Web UI
|
## Web UI
|
||||||
|
|
||||||
Crono comes with a Sinatra application that can display the current state of Crono jobs.
|
Crono can display the current state of Crono jobs.
|
||||||
Add `sinatra` and `haml` to your Gemfile
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
gem 'haml'
|
|
||||||
gem 'sinatra', require: nil
|
|
||||||
```
|
|
||||||
|
|
||||||
Add the following to your `config/routes.rb`:
|
Add the following to your `config/routes.rb`:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
mount Crono::Web, at: '/crono'
|
mount Crono::Engine, at: '/crono'
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
7
Rakefile
7
Rakefile
@@ -1,6 +1,5 @@
|
|||||||
require 'bundler/gem_tasks'
|
require "bundler/setup"
|
||||||
|
|
||||||
require 'rspec/core/rake_task'
|
load "rails/tasks/statistics.rake"
|
||||||
RSpec::Core::RakeTask.new('spec')
|
|
||||||
|
|
||||||
task default: :spec
|
require "bundler/gem_tasks"
|
||||||
|
|||||||
6
app/assets/javascripts/crono/materialize.min.js
vendored
Normal file
6
app/assets/javascripts/crono/materialize.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
26
app/assets/stylesheets/crono/application.css
Normal file
26
app/assets/stylesheets/crono/application.css
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
nav {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
nav .brand-logo {
|
||||||
|
font-size: 1.75em;
|
||||||
|
letter-spacing: -0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
main .page-footer {
|
||||||
|
margin: 0 -20px -20px -20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-footer > .footer-copyright {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.responsive-overflow {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
31
app/assets/stylesheets/crono/materialize.min.css
vendored
Normal file
31
app/assets/stylesheets/crono/materialize.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
app/controllers/crono/application_controller.rb
Normal file
5
app/controllers/crono/application_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module Crono
|
||||||
|
class ApplicationController < ActionController::Base
|
||||||
|
protect_from_forgery with: :exception
|
||||||
|
end
|
||||||
|
end
|
||||||
11
app/controllers/crono/jobs_controller.rb
Normal file
11
app/controllers/crono/jobs_controller.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
module Crono
|
||||||
|
class JobsController < ApplicationController
|
||||||
|
def index
|
||||||
|
@jobs = Crono::CronoJob.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@job = Crono::CronoJob.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
54
app/views/crono/jobs/index.html.erb
Normal file
54
app/views/crono/jobs/index.html.erb
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<header>
|
||||||
|
<h4>Running Jobs</h4>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="responsive-overflow">
|
||||||
|
<table id="job_list">
|
||||||
|
<tr>
|
||||||
|
<th>Job</th>
|
||||||
|
<th>Last performed at</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
<% @jobs.each do |job| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= job.job_id %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= job.last_performed_at || 'Never performed yet' %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if job.last_performed_at.nil? %>
|
||||||
|
<span class="grey-text darken-3" title="This job has never been performed yet.">
|
||||||
|
<i class="mdi-device-access-time"></i>
|
||||||
|
Pending
|
||||||
|
</span>
|
||||||
|
<% elsif job.healthy %>
|
||||||
|
<a href="<%= job_path(job) %>">
|
||||||
|
<span class="green-text darken-3" title="This job was performed successfully.">
|
||||||
|
<i class="mdi-action-done"></i>
|
||||||
|
Success
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<% else %>
|
||||||
|
<a href="<%= job_path(job) %>">
|
||||||
|
<span class="red-text" title="There were problems with this job. Follow the link to check the log.">
|
||||||
|
<i class="mdi-alert-warning"></i>
|
||||||
|
Error
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if job.last_performed_at %>
|
||||||
|
<a href="<%= job_path(job) %>" class="right">
|
||||||
|
Log
|
||||||
|
<i class="mdi-navigation-chevron-right"></i>
|
||||||
|
</a>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
17
app/views/crono/jobs/show.html.erb
Normal file
17
app/views/crono/jobs/show.html.erb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<header class="blue-grey lighten-4 grey-text text-darken-4">
|
||||||
|
<a href="<%= root_url %>">
|
||||||
|
<i class="mdi-navigation-chevron-left"></i>
|
||||||
|
‹ Back to Home
|
||||||
|
</a>
|
||||||
|
<h4>Last log of <i><%= @job.job_id %></i>:</h4>
|
||||||
|
</header>
|
||||||
|
<% if @job.healthy == false %>
|
||||||
|
<div class="row red-text">
|
||||||
|
<div class="s12 center-align">
|
||||||
|
<i class="mdi-alert-warning"></i>
|
||||||
|
An error occurs during the last execution of this job.
|
||||||
|
Check the log below for details.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<pre class="responsive-overflow"><%= @job.log %></pre>
|
||||||
31
app/views/layouts/crono/application.html.erb
Normal file
31
app/views/layouts/crono/application.html.erb
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
|
||||||
|
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
|
||||||
|
<title>Crono Dashboard</title>
|
||||||
|
<%= stylesheet_link_tag 'crono/materialize.min.css', media: "all" %>
|
||||||
|
<%= stylesheet_link_tag 'crono/application', media: "all" %>
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="blue-grey darken-2">
|
||||||
|
<nav class="blue-grey white-text" role="navigation">
|
||||||
|
<a class="brand-logo center" href="<%= root_path %>">
|
||||||
|
<b>Crono</b> Dashboard
|
||||||
|
</a>
|
||||||
|
</nav>
|
||||||
|
<main class="container blue-grey lighten-4">
|
||||||
|
|
||||||
|
<%= yield %>
|
||||||
|
|
||||||
|
<footer class="page-footer blue-grey darken-2">
|
||||||
|
<div class="footer-copyright blue-grey">
|
||||||
|
Crono v<%= Crono::VERSION %>
|
||||||
|
<a class="right" href="https://github.com/plashchynski/crono" target="_blank">Documentation</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
24
bin/rails
Executable file
24
bin/rails
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# This command will automatically be run when you run "rails" with Rails gems
|
||||||
|
# installed from the root of your application.
|
||||||
|
|
||||||
|
ENGINE_ROOT = File.expand_path('..', __dir__)
|
||||||
|
ENGINE_PATH = File.expand_path('../lib/crono/engine', __dir__)
|
||||||
|
|
||||||
|
# Set up gems listed in the Gemfile.
|
||||||
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||||
|
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||||
|
|
||||||
|
require 'rails'
|
||||||
|
# Pick the frameworks you want:
|
||||||
|
require 'active_model/railtie'
|
||||||
|
require 'active_job/railtie'
|
||||||
|
require 'active_record/railtie'
|
||||||
|
require 'active_storage/engine'
|
||||||
|
require 'action_controller/railtie'
|
||||||
|
require 'action_mailer/railtie'
|
||||||
|
require 'action_view/railtie'
|
||||||
|
require 'action_cable/engine'
|
||||||
|
# require "sprockets/railtie"
|
||||||
|
# require "rails/test_unit/railtie"
|
||||||
|
require 'rails/engine/commands'
|
||||||
4
config/routes.rb
Normal file
4
config/routes.rb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Crono::Engine.routes.draw do
|
||||||
|
resources :jobs
|
||||||
|
root 'jobs#index'
|
||||||
|
end
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
# coding: utf-8
|
require_relative 'lib/crono/version'
|
||||||
lib = File.expand_path('../lib', __FILE__)
|
|
||||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
||||||
require 'crono/version'
|
|
||||||
|
|
||||||
Gem::Specification.new do |spec|
|
Gem::Specification.new do |spec|
|
||||||
spec.name = 'crono'
|
spec.name = 'crono'
|
||||||
@@ -14,21 +11,20 @@ Gem::Specification.new do |spec|
|
|||||||
spec.homepage = 'https://github.com/plashchynski/crono'
|
spec.homepage = 'https://github.com/plashchynski/crono'
|
||||||
spec.license = 'Apache-2.0'
|
spec.license = 'Apache-2.0'
|
||||||
|
|
||||||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
spec.files = Dir['{app,config,db,lib}/**/*', 'LICENSE', 'Rakefile', 'README.rdoc']
|
||||||
spec.bindir = 'exe' # http://bundler.io/blog/2015/03/20/moving-bins-to-exe.html
|
spec.bindir = 'exe' # http://bundler.io/blog/2015/03/20/moving-bins-to-exe.html
|
||||||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
spec.executables = ['crono']
|
||||||
spec.require_paths = ['lib']
|
spec.require_paths = ['lib']
|
||||||
|
|
||||||
spec.add_runtime_dependency 'activesupport', '>= 4.0'
|
spec.add_dependency 'rails', '>= 4.0'
|
||||||
spec.add_runtime_dependency 'activerecord', '>= 4.0'
|
spec.add_dependency 'rspec', '>= 3.0'
|
||||||
spec.add_development_dependency 'rake', '>= 10.0'
|
|
||||||
spec.add_development_dependency 'bundler', '>= 1.0.0'
|
spec.add_development_dependency 'bundler', '>= 1.0.0'
|
||||||
spec.add_development_dependency 'rspec', '>= 3.0'
|
|
||||||
spec.add_development_dependency 'timecop', '>= 0.7'
|
|
||||||
spec.add_development_dependency 'sqlite3'
|
|
||||||
spec.add_development_dependency 'byebug'
|
spec.add_development_dependency 'byebug'
|
||||||
spec.add_development_dependency 'sinatra'
|
|
||||||
spec.add_development_dependency 'haml'
|
|
||||||
spec.add_development_dependency 'rack-test'
|
|
||||||
spec.add_development_dependency 'daemons'
|
spec.add_development_dependency 'daemons'
|
||||||
|
spec.add_development_dependency 'rack-test'
|
||||||
|
spec.add_development_dependency 'rake', '>= 10.0'
|
||||||
|
spec.add_development_dependency 'rspec', '>= 3.0'
|
||||||
|
spec.add_development_dependency 'sqlite3'
|
||||||
|
spec.add_development_dependency 'timecop', '>= 0.7'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
module Crono
|
module Crono
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require 'rails'
|
||||||
require 'active_support/all'
|
require 'active_support/all'
|
||||||
require 'crono/version'
|
require 'crono/version'
|
||||||
|
require 'crono/engine'
|
||||||
require 'crono/logging'
|
require 'crono/logging'
|
||||||
require 'crono/period'
|
require 'crono/period'
|
||||||
require 'crono/time_of_day'
|
require 'crono/time_of_day'
|
||||||
@@ -15,5 +17,3 @@ require 'crono/performer_proxy'
|
|||||||
require 'crono/cronotab'
|
require 'crono/cronotab'
|
||||||
require 'crono/orm/active_record/crono_job'
|
require 'crono/orm/active_record/crono_job'
|
||||||
require 'crono/railtie' if defined?(Rails)
|
require 'crono/railtie' if defined?(Rails)
|
||||||
|
|
||||||
Crono.autoload :Web, 'crono/web'
|
|
||||||
|
|||||||
9
lib/crono/engine.rb
Normal file
9
lib/crono/engine.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module Crono
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
isolate_namespace Crono
|
||||||
|
|
||||||
|
initializer 'crono.assets.precompile' do |app|
|
||||||
|
app.config.assets.precompile += %w( crono/application.css crono/materialize.min.css )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -76,7 +76,7 @@ module Crono
|
|||||||
end
|
end
|
||||||
|
|
||||||
def perform_job
|
def perform_job
|
||||||
performer.new.perform *JSON.parse(job_args)
|
performer.new.perform JSON.parse(job_args)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
handle_job_fail(e)
|
handle_job_fail(e)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ require 'active_record'
|
|||||||
module Crono
|
module Crono
|
||||||
# Crono::CronoJob is a ActiveRecord model to store job state
|
# Crono::CronoJob is a ActiveRecord model to store job state
|
||||||
class CronoJob < ActiveRecord::Base
|
class CronoJob < ActiveRecord::Base
|
||||||
|
self.table_name = 'crono_jobs'
|
||||||
validates :job_id, presence: true, uniqueness: true
|
validates :job_id, presence: true, uniqueness: true
|
||||||
|
|
||||||
def self.outdated
|
def self.outdated
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ module Crono
|
|||||||
@job_args = job_args
|
@job_args = job_args
|
||||||
end
|
end
|
||||||
|
|
||||||
def every(period, *args)
|
def every(period, **options)
|
||||||
@job = Job.new(@performer, Period.new(period, *args), @job_args, @options)
|
@job = Job.new(@performer, Period.new(period, **options), @job_args, @options)
|
||||||
@scheduler.add_job(@job)
|
@scheduler.add_job(@job)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
require 'haml'
|
|
||||||
require 'sinatra/base'
|
|
||||||
require 'crono'
|
|
||||||
|
|
||||||
module Crono
|
|
||||||
# Web is a Web UI Sinatra app
|
|
||||||
class Web < Sinatra::Base
|
|
||||||
set :root, File.expand_path(File.dirname(__FILE__) + '/../../web')
|
|
||||||
set :public_folder, proc { "#{root}/assets" }
|
|
||||||
set :views, proc { "#{root}/views" }
|
|
||||||
|
|
||||||
get '/' do
|
|
||||||
@jobs = Crono::CronoJob.all
|
|
||||||
haml :dashboard, format: :html5
|
|
||||||
end
|
|
||||||
|
|
||||||
get '/job/:id' do
|
|
||||||
@job = Crono::CronoJob.find(params[:id])
|
|
||||||
haml :job
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user