From 3652e9525afda60f5c77db3657390a068bb19373 Mon Sep 17 00:00:00 2001 From: Dzmitry Plashchynski Date: Tue, 3 Mar 2015 13:51:40 +0200 Subject: [PATCH] Rename to Crono --- Gemfile.lock | 4 ++-- README.md | 4 ++-- bin/{periodicity => crono} | 4 ++-- periodicity.gemspec => crono.gemspec | 10 +++++----- lib/crono.rb | 8 ++++++++ lib/{periodicity => crono}/cli.rb | 6 +++--- lib/{periodicity => crono}/config.rb | 2 +- lib/{periodicity => crono}/performer_proxy.rb | 2 +- lib/{periodicity => crono}/period.rb | 2 +- lib/{periodicity => crono}/version.rb | 2 +- .../install/install_generator.rb | 6 +++--- .../install/templates/crono.rb.erb} | 4 ++-- lib/periodicity.rb | 8 -------- spec/cli_spec.rb | 6 +++--- spec/config_spec.rb | 4 ++-- spec/performer_proxy_spec.rb | 6 +++--- spec/period_spec.rb | 10 +++++----- spec/spec_helper.rb | 2 +- 18 files changed, 45 insertions(+), 45 deletions(-) rename bin/{periodicity => crono} (77%) rename periodicity.gemspec => crono.gemspec (75%) create mode 100644 lib/crono.rb rename lib/{periodicity => crono}/cli.rb (76%) rename lib/{periodicity => crono}/config.rb (87%) rename lib/{periodicity => crono}/performer_proxy.rb (93%) rename lib/{periodicity => crono}/period.rb (96%) rename lib/{periodicity => crono}/version.rb (55%) rename lib/generators/{periodicity => crono}/install/install_generator.rb (51%) rename lib/generators/{periodicity/install/templates/periodicity.rb.erb => crono/install/templates/crono.rb.erb} (74%) delete mode 100644 lib/periodicity.rb diff --git a/Gemfile.lock b/Gemfile.lock index acd1fd6..549145d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/README.md b/README.md index c4d2084..623a16a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/bin/periodicity b/bin/crono similarity index 77% rename from bin/periodicity rename to bin/crono index 2c591de..5da4eff 100755 --- a/bin/periodicity +++ b/bin/crono @@ -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 diff --git a/periodicity.gemspec b/crono.gemspec similarity index 75% rename from periodicity.gemspec rename to crono.gemspec index be0cbf6..7c8db0b 100644 --- a/periodicity.gemspec +++ b/crono.gemspec @@ -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" diff --git a/lib/crono.rb b/lib/crono.rb new file mode 100644 index 0000000..6744e57 --- /dev/null +++ b/lib/crono.rb @@ -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" diff --git a/lib/periodicity/cli.rb b/lib/crono/cli.rb similarity index 76% rename from lib/periodicity/cli.rb rename to lib/crono/cli.rb index 2a61d28..6667e46 100644 --- a/lib/periodicity/cli.rb +++ b/lib/crono/cli.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 diff --git a/lib/periodicity/config.rb b/lib/crono/config.rb similarity index 87% rename from lib/periodicity/config.rb rename to lib/crono/config.rb index 741c61f..55cbbfc 100644 --- a/lib/periodicity/config.rb +++ b/lib/crono/config.rb @@ -1,4 +1,4 @@ -module Periodicity +module Crono class Config include Singleton diff --git a/lib/periodicity/performer_proxy.rb b/lib/crono/performer_proxy.rb similarity index 93% rename from lib/periodicity/performer_proxy.rb rename to lib/crono/performer_proxy.rb index b57bf11..30fca3d 100644 --- a/lib/periodicity/performer_proxy.rb +++ b/lib/crono/performer_proxy.rb @@ -1,4 +1,4 @@ -module Periodicity +module Crono class PerformerProxy def initialize(performer) @performer = performer diff --git a/lib/periodicity/period.rb b/lib/crono/period.rb similarity index 96% rename from lib/periodicity/period.rb rename to lib/crono/period.rb index 8b5fbc3..f1296df 100644 --- a/lib/periodicity/period.rb +++ b/lib/crono/period.rb @@ -1,4 +1,4 @@ -module Periodicity +module Crono class Period def initialize(period, at: nil) @period = period diff --git a/lib/periodicity/version.rb b/lib/crono/version.rb similarity index 55% rename from lib/periodicity/version.rb rename to lib/crono/version.rb index 228a220..e63cb3b 100644 --- a/lib/periodicity/version.rb +++ b/lib/crono/version.rb @@ -1,3 +1,3 @@ -module Periodicity +module Crono VERSION = "0.0.1" end diff --git a/lib/generators/periodicity/install/install_generator.rb b/lib/generators/crono/install/install_generator.rb similarity index 51% rename from lib/generators/periodicity/install/install_generator.rb rename to lib/generators/crono/install/install_generator.rb index dfae31b..00af656 100644 --- a/lib/generators/periodicity/install/install_generator.rb +++ b/lib/generators/crono/install/install_generator.rb @@ -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 diff --git a/lib/generators/periodicity/install/templates/periodicity.rb.erb b/lib/generators/crono/install/templates/crono.rb.erb similarity index 74% rename from lib/generators/periodicity/install/templates/periodicity.rb.erb rename to lib/generators/crono/install/templates/crono.rb.erb index 05dcca7..2ebeb44 100644 --- a/lib/generators/periodicity/install/templates/periodicity.rb.erb +++ b/lib/generators/crono/install/templates/crono.rb.erb @@ -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" # diff --git a/lib/periodicity.rb b/lib/periodicity.rb deleted file mode 100644 index 0ca81d8..0000000 --- a/lib/periodicity.rb +++ /dev/null @@ -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" \ No newline at end of file diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index af2505d..1e8364a 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.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 diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 415c030..bb25b4f 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -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 diff --git a/spec/performer_proxy_spec.rb b/spec/performer_proxy_spec.rb index d77c022..aa83d02 100644 --- a/spec/performer_proxy_spec.rb +++ b/spec/performer_proxy_spec.rb @@ -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 diff --git a/spec/period_spec.rb b/spec/period_spec.rb index 4d2265d..de53e46 100644 --- a/spec/period_spec.rb +++ b/spec/period_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c822b8..eb258ee 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,7 @@ require 'bundler/setup' Bundler.setup require 'timecop' -require 'periodicity' +require 'crono' RSpec.configure do |config| end