Skip to content

Commit

Permalink
Cleanup and get rspec to run again
Browse files Browse the repository at this point in the history
  • Loading branch information
cseelus committed Feb 11, 2021
1 parent 6fee31f commit ee79596
Show file tree
Hide file tree
Showing 63 changed files with 457 additions and 1,448 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--require spec_helper
--format documentation
--color
8 changes: 8 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
X.X.X
-----------
- Converted this gem to a proper Rails engine
- Gets rid of `sinatra` and `haml` dependencies for the Web UI
- Web UI is now responsive and thus usable on smartphones, etc.
- Fixed crash with Ruby 3.0


1.1.0
-----------
- Rails 3 and old Rubies are not supported anymore, sorry rails 3 guys...
Expand Down
22 changes: 21 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Specify your gem's dependencies in crono.gemspec
# Specify your gem's dependencies in crono.gemspec.
gemspec

group :development, :test do
# gem 'activerecord'
# gem 'actionpack' # action_controller, action_view
# gem 'sprockets'

gem 'byebug'
gem 'combustion', '~> 1.3'
gem 'daemons'
gem 'rack-test'
gem 'rake', '>= 10.0'
gem 'rspec', '>= 3.0'
gem 'rspec-rails', '>= 4.0'
gem 'sqlite3'
gem 'timecop', '>= 0.7'
end

# To use a debugger
# gem 'byebug', group: [:development, :test]
122 changes: 67 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,75 @@ PATH
specs:
crono (1.1.2)
rails (>= 4.0)
rspec (>= 3.0)

GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.2)
actionpack (= 6.1.2)
activesupport (= 6.1.2)
actioncable (6.1.2.1)
actionpack (= 6.1.2.1)
activesupport (= 6.1.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.2)
actionpack (= 6.1.2)
activejob (= 6.1.2)
activerecord (= 6.1.2)
activestorage (= 6.1.2)
activesupport (= 6.1.2)
actionmailbox (6.1.2.1)
actionpack (= 6.1.2.1)
activejob (= 6.1.2.1)
activerecord (= 6.1.2.1)
activestorage (= 6.1.2.1)
activesupport (= 6.1.2.1)
mail (>= 2.7.1)
actionmailer (6.1.2)
actionpack (= 6.1.2)
actionview (= 6.1.2)
activejob (= 6.1.2)
activesupport (= 6.1.2)
actionmailer (6.1.2.1)
actionpack (= 6.1.2.1)
actionview (= 6.1.2.1)
activejob (= 6.1.2.1)
activesupport (= 6.1.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.2)
actionview (= 6.1.2)
activesupport (= 6.1.2)
actionpack (6.1.2.1)
actionview (= 6.1.2.1)
activesupport (= 6.1.2.1)
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)
actiontext (6.1.2.1)
actionpack (= 6.1.2.1)
activerecord (= 6.1.2.1)
activestorage (= 6.1.2.1)
activesupport (= 6.1.2.1)
nokogiri (>= 1.8.5)
actionview (6.1.2)
activesupport (= 6.1.2)
actionview (6.1.2.1)
activesupport (= 6.1.2.1)
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)
activejob (6.1.2.1)
activesupport (= 6.1.2.1)
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)
activemodel (6.1.2.1)
activesupport (= 6.1.2.1)
activerecord (6.1.2.1)
activemodel (= 6.1.2.1)
activesupport (= 6.1.2.1)
activestorage (6.1.2.1)
actionpack (= 6.1.2.1)
activejob (= 6.1.2.1)
activerecord (= 6.1.2.1)
activesupport (= 6.1.2.1)
marcel (~> 0.3.1)
mimemagic (~> 0.3.2)
activesupport (6.1.2)
activesupport (6.1.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
builder (3.2.4)
byebug (11.1.3)
combustion (1.3.1)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
thor (>= 0.14.6)
concurrent-ruby (1.1.8)
crass (1.0.6)
daemons (1.3.1)
Expand Down Expand Up @@ -96,29 +99,29 @@ GEM
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)
rails (6.1.2.1)
actioncable (= 6.1.2.1)
actionmailbox (= 6.1.2.1)
actionmailer (= 6.1.2.1)
actionpack (= 6.1.2.1)
actiontext (= 6.1.2.1)
actionview (= 6.1.2.1)
activejob (= 6.1.2.1)
activemodel (= 6.1.2.1)
activerecord (= 6.1.2.1)
activestorage (= 6.1.2.1)
activesupport (= 6.1.2.1)
bundler (>= 1.15.0)
railties (= 6.1.2)
railties (= 6.1.2.1)
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)
railties (6.1.2.1)
actionpack (= 6.1.2.1)
activesupport (= 6.1.2.1)
method_source
rake (>= 0.8.7)
thor (~> 1.0)
Expand All @@ -135,6 +138,14 @@ GEM
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (4.0.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
Expand All @@ -157,13 +168,14 @@ PLATFORMS
arm64-darwin-20

DEPENDENCIES
bundler (>= 1.0.0)
byebug
combustion (~> 1.3)
crono!
daemons
rack-test
rake (>= 10.0)
rspec (>= 3.0)
rspec-rails (>= 4.0)
sqlite3
timecop (>= 0.7)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Currently, there is no such thing as Ruby Cron for Rails. Well, there's [Wheneve

## Requirements

Tested with latest MRI Ruby 2.2+, 2.3+, Rails 4.\*, and Rails 5.\*.
Tested with latest MRI Ruby 2.2+, 2.3+, Rails 4.\*, Rails 5.\*, and Rails 6.\*.
Other versions are untested but might work fine.


Expand Down Expand Up @@ -53,7 +53,7 @@ Here's an example of a job:
```ruby
# app/jobs/test_job.rb
class TestJob < ActiveJob::Base
def perform
def perform(options)
# put you scheduled code here
# Comments.deleted.clean_up...
end
Expand All @@ -80,7 +80,7 @@ require 'rake'
Rails.app_class.load_tasks

class Test
def perform
def perform(options)
Rake::Task['crono:hello'].invoke
end
end
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "bundler/setup"
require 'bundler/setup'

load "rails/tasks/statistics.rake"
load 'rails/tasks/statistics.rake'

require "bundler/gem_tasks"
require 'bundler/gem_tasks'
12 changes: 4 additions & 8 deletions app/views/crono/jobs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,26 @@
<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
◷ 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
✔ 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
⚠ 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>
Log ›
</a>
<% end %>
</td>
Expand Down
5 changes: 2 additions & 3 deletions app/views/crono/jobs/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<header class="blue-grey lighten-4 grey-text text-darken-4">
<a href="<%= root_url %>">
<i class="mdi-navigation-chevron-left"></i>
&lsaquo; Back to Home
‹ 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>
Expand Down
9 changes: 9 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require "rubygems"
require "bundler"

Bundler.require :default, :development

Combustion.initialize! :all
run Combustion::Application
11 changes: 1 addition & 10 deletions crono.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ Gem::Specification.new do |spec|
spec.bindir = 'exe' # http://bundler.io/blog/2015/03/20/moving-bins-to-exe.html
spec.executables = ['crono']
spec.require_paths = ['lib']
spec.test_files = Dir['spec/**/*']

spec.add_dependency 'rails', '>= 4.0'
spec.add_dependency 'rspec', '>= 3.0'

spec.add_development_dependency 'bundler', '>= 1.0.0'
spec.add_development_dependency 'byebug'
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
6 changes: 6 additions & 0 deletions lib/crono/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ class Engine < ::Rails::Engine
initializer 'crono.assets.precompile' do |app|
app.config.assets.precompile += %w( crono/application.css crono/materialize.min.css )
end

config.generators do |g|
g.test_framework :rspec
g.assets false
g.helper false
end
end
end
Binary file added spec/internal/:memory
Binary file not shown.
Empty file.
3 changes: 3 additions & 0 deletions spec/internal/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
5 changes: 5 additions & 0 deletions spec/internal/app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class PagesController < ApplicationController
def index
#
end
end
1 change: 1 addition & 0 deletions spec/internal/app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Hello World</p>
22 changes: 22 additions & 0 deletions spec/internal/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require 'crono'

module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end
Loading

0 comments on commit ee79596

Please sign in to comment.