Compare commits

..

5 Commits

Author SHA1 Message Date
Dzmitry Plashchynski
6b627275d8 v0.9.0 2015-05-29 23:29:46 +03:00
Dzmitry Plashchynski
00d5c777dd Merge branch 'master' of github.com:plashchynski/crono 2015-05-28 17:43:12 +03:00
Dzmitry Plashchynski
c28a0bbc8a Able to specify minutes for hour-based schedule. Closing #26 2015-05-28 17:43:02 +03:00
Dzmitry Plashchynski
45c22ee6ba Merge pull request #24 from rogercampos/feature/no-activejob-dependency
activejob is not a real dependency
2015-05-12 13:33:13 +03:00
Roger Campos
2ac14113b6 activejob is not a real dependency 2015-05-11 18:03:56 +02:00
5 changed files with 30 additions and 18 deletions

View File

@@ -1,17 +1,13 @@
PATH
remote: .
specs:
crono (0.8.9)
activejob (~> 4.0)
crono (0.9.0)
activerecord (~> 4.0)
activesupport (~> 4.0)
GEM
remote: https://rubygems.org/
specs:
activejob (4.2.1)
activesupport (= 4.2.1)
globalid (>= 0.3.0)
activemodel (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
@@ -27,18 +23,16 @@ GEM
tzinfo (~> 1.1)
arel (6.0.0)
builder (3.2.2)
byebug (4.0.5)
byebug (5.0.0)
columnize (= 0.9.0)
columnize (0.9.0)
diff-lcs (1.2.5)
globalid (0.3.5)
activesupport (>= 4.1.0)
haml (4.0.6)
tilt
i18n (0.7.0)
json (1.8.2)
minitest (5.5.1)
rack (1.6.0)
minitest (5.6.1)
rack (1.6.1)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
@@ -57,13 +51,13 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
sinatra (1.4.5)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
tilt (>= 1.3, < 3)
sqlite3 (1.3.10)
thread_safe (0.3.5)
tilt (1.4.1)
tilt (2.0.1)
timecop (0.7.3)
tzinfo (1.2.2)
thread_safe (~> 0.1)

View File

@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.add_runtime_dependency 'activejob', '~> 4.0'
spec.add_runtime_dependency 'activesupport', '~> 4.0'
spec.add_runtime_dependency 'activerecord', '~> 4.0'
spec.add_development_dependency 'rake', '~> 10.0'

View File

@@ -49,7 +49,10 @@ module Crono
end
def parse_at(at)
fail "period should be at least 1 day to use 'at'" if @period < 1.day
if @period < 1.day && (at.is_a? String || at[:hour])
fail "period should be at least 1 day to use 'at' with specified hour"
end
case at
when String
time = Time.parse(at)

View File

@@ -1,3 +1,3 @@
module Crono
VERSION = '0.8.9'
VERSION = '0.9.0'
end

View File

@@ -52,7 +52,7 @@ describe Crono::Period do
expect(@period.next(since: 2.days.ago).to_s).to be_eql(Time.now.to_s)
end
it 'should return the time 2 days from now' do
it 'should return time 2 days from now' do
@period = Crono::Period.new(2.day)
expect(@period.next.to_s).to be_eql(2.days.from_now.to_s)
end
@@ -80,7 +80,7 @@ describe Crono::Period do
it 'should raise error when period is less than 1 day' do
expect {
Crono::Period.new(5.hours, at: '15:30')
}.to raise_error("period should be at least 1 day to use 'at'")
}.to raise_error("period should be at least 1 day to use 'at' with specified hour")
end
it 'should return time in relation to last time' do
@@ -95,5 +95,21 @@ describe Crono::Period do
expect(@period.next.utc.to_s).to be_eql(Time.now.change(at).utc.to_s)
end
end
context 'in hourly basis' do
it 'should return next hour minutes if current hour minutes passed' do
Timecop.freeze(Time.now.beginning_of_hour.advance(minutes: 20)) do
@period = Crono::Period.new(1.hour, at: { min: 15 })
expect(@period.next.utc.to_s).to be_eql 1.hour.from_now.beginning_of_hour.advance(minutes: 15).utc.to_s
end
end
it 'should return current hour minutes if current hour minutes not passed yet' do
Timecop.freeze(Time.now.beginning_of_hour.advance(minutes: 10)) do
@period = Crono::Period.new(1.hour, at: { min: 15 })
expect(@period.next.utc.to_s).to be_eql Time.now.beginning_of_hour.advance(minutes: 15).utc.to_s
end
end
end
end
end