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