mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-23 09:51:48 +01:00
Rename to Crono
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
periodicity (0.0.1)
|
||||
crono (0.0.1)
|
||||
activejob (~> 4.0)
|
||||
activesupport (~> 4.0)
|
||||
|
||||
@@ -47,7 +47,7 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
bundler (>= 1.0.0)
|
||||
periodicity!
|
||||
crono!
|
||||
rake (~> 10.0)
|
||||
rspec (~> 3.0)
|
||||
timecop (~> 0.7)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Under Construction
|
||||
|
||||
Periodicity — Job scheduler for Rails
|
||||
Crono — Job scheduler for Rails
|
||||
------------------------
|
||||
|
||||
Periodicity is a background job scheduler (just like Unix cron) for Ruby on Rails, on top of the Active Job framework. You can specify a schedule for Active Job jobs and check execution using a web interface.
|
||||
Crono is a background job scheduler (just like Unix cron) for Ruby on Rails, on top of the Active Job framework. You can specify a schedule for Active Job jobs and check execution using a web interface.
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
||||
|
||||
require "periodicity/cli"
|
||||
require "crono/cli"
|
||||
|
||||
begin
|
||||
cli = Periodicity::CLI.instance
|
||||
cli = Crono::CLI.instance
|
||||
cli.run
|
||||
rescue => e
|
||||
raise e if $DEBUG
|
||||
@@ -1,17 +1,17 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
require File.expand_path('../lib/periodicity/version', __FILE__)
|
||||
require File.expand_path('../lib/crono/version', __FILE__)
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "periodicity"
|
||||
s.version = Periodicity::VERSION
|
||||
s.name = "crono"
|
||||
s.version = Crono::VERSION
|
||||
s.authors = ["Dzmitry Plashchynski"]
|
||||
s.email = ["plashchynski@gmail.com"]
|
||||
s.homepage = "https://github.com/plashchynski/periodicity"
|
||||
s.homepage = "https://github.com/plashchynski/crono"
|
||||
s.description = s.summary = "Job scheduler for Rails"
|
||||
s.license = "Apache-2.0"
|
||||
|
||||
s.required_rubygems_version = ">= 1.3.6"
|
||||
s.rubyforge_project = "periodicity"
|
||||
s.rubyforge_project = "crono"
|
||||
|
||||
s.add_runtime_dependency "activejob", "~> 4.0"
|
||||
s.add_runtime_dependency "activesupport", "~> 4.0"
|
||||
8
lib/crono.rb
Normal file
8
lib/crono.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
module Crono
|
||||
end
|
||||
|
||||
require "active_support/all"
|
||||
require "crono/version.rb"
|
||||
require "crono/period.rb"
|
||||
require "crono/config.rb"
|
||||
require "crono/performer_proxy.rb"
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'periodicity'
|
||||
require 'crono'
|
||||
|
||||
module Periodicity
|
||||
module Crono
|
||||
class CLI
|
||||
include Singleton
|
||||
|
||||
@@ -10,7 +10,7 @@ module Periodicity
|
||||
end
|
||||
|
||||
def print_banner
|
||||
puts "Loading Periodicity #{Periodicity::VERSION}"
|
||||
puts "Loading Crono #{Crono::VERSION}"
|
||||
puts "Running in #{RUBY_DESCRIPTION}"
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Periodicity
|
||||
module Crono
|
||||
class Config
|
||||
include Singleton
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Periodicity
|
||||
module Crono
|
||||
class PerformerProxy
|
||||
def initialize(performer)
|
||||
@performer = performer
|
||||
@@ -1,4 +1,4 @@
|
||||
module Periodicity
|
||||
module Crono
|
||||
class Period
|
||||
def initialize(period, at: nil)
|
||||
@period = period
|
||||
@@ -1,3 +1,3 @@
|
||||
module Periodicity
|
||||
module Crono
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
@@ -1,11 +1,11 @@
|
||||
module Periodicity
|
||||
module Crono
|
||||
module Generators
|
||||
class InstallGenerator < ::Rails::Generators::Base
|
||||
desc "Installs periodicity and generates the necessary configuration files"
|
||||
desc "Installs crono and generates the necessary configuration files"
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
|
||||
def copy_config
|
||||
template 'periodicity.rb.erb', 'config/initializers/periodicity.rb'
|
||||
template 'crono.rb.erb', 'config/initializers/crono.rb'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,9 @@
|
||||
# Periodicity configuration file
|
||||
# Crono configuration file
|
||||
#
|
||||
# Here you can specify periodic jobs and their schedule.
|
||||
# You can specify a periodic job as a ActiveJob class in `app/jobs/`
|
||||
# Actually you can use any class. The only requirement is that
|
||||
# the class should implement a method `perform` without arguments.
|
||||
#
|
||||
# Periodicity.perform(TestJob).every 2.days, at: "15:30"
|
||||
# Crono.perform(TestJob).every 2.days, at: "15:30"
|
||||
#
|
||||
@@ -1,8 +0,0 @@
|
||||
module Periodicity
|
||||
end
|
||||
|
||||
require "active_support/all"
|
||||
require "periodicity/version.rb"
|
||||
require "periodicity/period.rb"
|
||||
require "periodicity/config.rb"
|
||||
require "periodicity/performer_proxy.rb"
|
||||
@@ -1,8 +1,8 @@
|
||||
require "spec_helper"
|
||||
require 'periodicity/cli'
|
||||
require 'crono/cli'
|
||||
|
||||
describe Periodicity::CLI do
|
||||
let(:cli) { Periodicity::CLI.instance }
|
||||
describe Crono::CLI do
|
||||
let(:cli) { Crono::CLI.instance }
|
||||
|
||||
describe "#run" do
|
||||
it "should try to initialize rails with #load_rails" do
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Periodicity::Config do
|
||||
describe Crono::Config do
|
||||
describe "#initialize" do
|
||||
it "should initialize schedule with an empty array" do
|
||||
@config = Periodicity::Config.instance
|
||||
@config = Crono::Config.instance
|
||||
expect(@config.schedule).to eql([])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,9 @@ class TestJob < ActiveJob::Base
|
||||
def perform;end
|
||||
end
|
||||
|
||||
describe Periodicity::PerformerProxy do
|
||||
describe Crono::PerformerProxy do
|
||||
it "should add job and period to schedule" do
|
||||
Periodicity.perform(TestJob).every(2.days, at: "15:30")
|
||||
expect(Periodicity::Config.instance.schedule).to_not be_empty
|
||||
Crono.perform(TestJob).every(2.days, at: "15:30")
|
||||
expect(Crono::Config.instance.schedule).to_not be_empty
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Periodicity::Period do
|
||||
describe Crono::Period do
|
||||
around(:each) do |example|
|
||||
Timecop.freeze do
|
||||
example.run
|
||||
@@ -10,24 +10,24 @@ describe Periodicity::Period do
|
||||
describe "#next" do
|
||||
context "in daily basis" do
|
||||
it "should return the time 2 days from now" do
|
||||
@period = Periodicity::Period.new(2.day)
|
||||
@period = Crono::Period.new(2.day)
|
||||
expect(@period.next).to be_eql(2.day.from_now)
|
||||
end
|
||||
|
||||
it "should set time to 'at' time as a string" do
|
||||
@period = Periodicity::Period.new(2.day, at: "15:20")
|
||||
@period = Crono::Period.new(2.day, at: "15:20")
|
||||
expect(@period.next).to be_eql(2.day.from_now.change(hour: 15, min: 20))
|
||||
end
|
||||
|
||||
it "should set time to 'at' time as a hash" do
|
||||
at = {hour: 18, min: 45}
|
||||
@period = Periodicity::Period.new(2.day, at: at)
|
||||
@period = Crono::Period.new(2.day, at: at)
|
||||
expect(@period.next).to be_eql(2.day.from_now.change(at))
|
||||
end
|
||||
|
||||
it "should raise error when 'at' is wrong" do
|
||||
expect {
|
||||
@period = Periodicity::Period.new(2.day, at: 1)
|
||||
@period = Crono::Period.new(2.day, at: 1)
|
||||
}.to raise_error("Unknown 'at' format")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ require 'bundler/setup'
|
||||
Bundler.setup
|
||||
|
||||
require 'timecop'
|
||||
require 'periodicity'
|
||||
require 'crono'
|
||||
|
||||
RSpec.configure do |config|
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user