From b301b95ae5a6ccebc279b8cd15b9b901283eb0d2 Mon Sep 17 00:00:00 2001 From: Dzmitry Plashchynski Date: Tue, 3 Mar 2015 18:39:26 +0200 Subject: [PATCH] Add Crono.config --- lib/crono/config.rb | 4 ++++ lib/crono/performer_proxy.rb | 2 +- spec/config_spec.rb | 2 +- spec/performer_proxy_spec.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/crono/config.rb b/lib/crono/config.rb index 809965e..3e51e30 100644 --- a/lib/crono/config.rb +++ b/lib/crono/config.rb @@ -8,4 +8,8 @@ module Crono self.schedule = Schedule.new end end + + def self.config + Config.instance + end end diff --git a/lib/crono/performer_proxy.rb b/lib/crono/performer_proxy.rb index bd95a38..fc5be53 100644 --- a/lib/crono/performer_proxy.rb +++ b/lib/crono/performer_proxy.rb @@ -5,7 +5,7 @@ module Crono end def every(period, *args) - Config.instance.schedule.add(@performer, Period.new(period, *args)) + Crono.config.schedule.add(@performer, Period.new(period, *args)) end end diff --git a/spec/config_spec.rb b/spec/config_spec.rb index 32e7c1f..fdb0c38 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" describe Crono::Config do describe "#initialize" do it "should initialize schedule" do - @config = Crono::Config.instance + @config = Crono.config expect(@config.schedule).to be_a(Crono::Schedule) end end diff --git a/spec/performer_proxy_spec.rb b/spec/performer_proxy_spec.rb index 920cefe..6cf9bb5 100644 --- a/spec/performer_proxy_spec.rb +++ b/spec/performer_proxy_spec.rb @@ -6,7 +6,7 @@ end describe Crono::PerformerProxy do it "should add job and period to schedule" do - expect(Crono::Config.instance.schedule).to receive(:add).with(TestJob, kind_of(Crono::Period)) + expect(Crono.config.schedule).to receive(:add).with(TestJob, kind_of(Crono::Period)) Crono.perform(TestJob).every(2.days, at: "15:30") end end