say_when 0.4.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +13 -4
- data/Gemfile +1 -9
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +6 -6
- data/lib/generators/say_when/migration/migration_generator.rb +8 -5
- data/lib/generators/say_when/migration/templates/migration.rb +8 -7
- data/lib/say_when/base_job.rb +2 -0
- data/lib/say_when/cron_expression.rb +129 -191
- data/lib/say_when/processor/active_messaging.rb +7 -8
- data/lib/say_when/processor/base.rb +5 -3
- data/lib/say_when/processor/shoryuken.rb +14 -0
- data/lib/say_when/processor/simple.rb +2 -0
- data/lib/say_when/railtie.rb +9 -0
- data/lib/say_when/scheduler.rb +49 -90
- data/lib/say_when/storage/active_record/acts.rb +16 -16
- data/lib/say_when/storage/active_record/job.rb +17 -24
- data/lib/say_when/storage/active_record/job_execution.rb +5 -8
- data/lib/say_when/storage/memory/base.rb +3 -1
- data/lib/say_when/storage/memory/job.rb +14 -42
- data/lib/say_when/tasks.rb +4 -4
- data/lib/say_when/triggers/base.rb +4 -3
- data/lib/say_when/triggers/cron_strategy.rb +4 -3
- data/lib/say_when/triggers/instance_strategy.rb +4 -3
- data/lib/say_when/triggers/once_strategy.rb +3 -2
- data/lib/say_when/version.rb +3 -1
- data/lib/say_when.rb +8 -7
- data/lib/tasks/say_when.rake +3 -1
- data/say_when.gemspec +26 -19
- data/test/active_record_helper.rb +13 -0
- data/{spec → test}/db/schema.rb +4 -4
- data/{spec/spec_helper.rb → test/minitest_helper.rb} +9 -19
- data/test/say_when/cron_expression_spec.rb +74 -0
- data/{spec/say_when/processor/active_messaging_spec.rb → test/say_when/processor/active_messaging_test.rb} +17 -13
- data/test/say_when/scheduler_test.rb +75 -0
- data/test/say_when/storage/active_record/job_test.rb +90 -0
- data/test/say_when/storage/memory/job_test.rb +32 -0
- data/test/say_when/storage/memory/trigger_test.rb +54 -0
- data/test/say_when/triggers/once_strategy_test.rb +23 -0
- data/{spec → test}/support/models.rb +5 -3
- metadata +97 -54
- data/.travis.yml +0 -4
- data/generators/say_when_migration/say_when_migration_generator.rb +0 -11
- data/generators/say_when_migration/templates/migration.rb +0 -48
- data/spec/active_record_spec_helper.rb +0 -9
- data/spec/say_when/cron_expression_spec.rb +0 -72
- data/spec/say_when/scheduler_spec.rb +0 -126
- data/spec/say_when/storage/active_record/job_spec.rb +0 -97
- data/spec/say_when/storage/memory/job_spec.rb +0 -45
- data/spec/say_when/storage/memory/trigger_spec.rb +0 -54
- data/spec/say_when/triggers/once_strategy_spec.rb +0 -22
- data/spec/spec.opts +0 -4
@@ -1,54 +0,0 @@
|
|
1
|
-
require_relative '../../../spec_helper'
|
2
|
-
# require File.dirname(__FILE__) + '/../../../../lib/say_when/store/memory/trigger'
|
3
|
-
|
4
|
-
# describe SayWhen::Store::Memory::Trigger do
|
5
|
-
|
6
|
-
# before(:each) do
|
7
|
-
# @valid_attributes = {
|
8
|
-
# :expression => '0 0 12 ? * * *',
|
9
|
-
# :time_zone => 'Pacific Time (US & Canada)'
|
10
|
-
# }
|
11
|
-
# end
|
12
|
-
|
13
|
-
# it "can be instantiated" do
|
14
|
-
# t = SayWhen::Store::Memory::Trigger.new(@valid_attributes)
|
15
|
-
# t.should_not be_nil
|
16
|
-
# end
|
17
|
-
|
18
|
-
# it "sets a cron_expression" do
|
19
|
-
# t = SayWhen::Store::Memory::Trigger.new(@valid_attributes)
|
20
|
-
# t.cron_expression.should_not be_nil
|
21
|
-
# t.cron_expression.expression.should == '0 0 12 ? * * *'
|
22
|
-
# t.cron_expression.time_zone.should == 'Pacific Time (US & Canada)'
|
23
|
-
# end
|
24
|
-
|
25
|
-
# it "has a waiting state on instantiate" do
|
26
|
-
# t = SayWhen::Store::Memory::Trigger.new(@valid_attributes)
|
27
|
-
# t.status.should == SayWhen::BaseTrigger::STATE_WAITING
|
28
|
-
# end
|
29
|
-
|
30
|
-
# it "has a next fire at set on instantiate" do
|
31
|
-
# ce = SayWhen::CronExpression.new(@valid_attributes[:expression], @valid_attributes[:time_zone])
|
32
|
-
# t = SayWhen::Store::Memory::Trigger.new(@valid_attributes)
|
33
|
-
# t.status.should == SayWhen::BaseTrigger::STATE_WAITING
|
34
|
-
# t.next_fire_at.should == ce.next_fire_at
|
35
|
-
# end
|
36
|
-
|
37
|
-
# it "can be fired" do
|
38
|
-
# ce = SayWhen::CronExpression.new(@valid_attributes[:expression], @valid_attributes[:time_zone])
|
39
|
-
# t = SayWhen::Store::Memory::Trigger.new(@valid_attributes)
|
40
|
-
# nfa = ce.last_fire_at(1.second.ago)
|
41
|
-
# lfa = ce.last_fire_at(nfa - 1.second)
|
42
|
-
# t.next_fire_at = nfa
|
43
|
-
# t.last_fire_at = lfa
|
44
|
-
|
45
|
-
# now = Time.now
|
46
|
-
# Time.stub!(:now).and_return(now)
|
47
|
-
|
48
|
-
# t.fired
|
49
|
-
# t.next_fire_at.should == ce.next_fire_at(now)
|
50
|
-
# t.last_fire_at.should == now
|
51
|
-
# t.status.should == SayWhen::BaseTrigger::STATE_WAITING
|
52
|
-
# end
|
53
|
-
|
54
|
-
# end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require_relative '../../spec_helper'
|
2
|
-
require_relative '../../../lib/say_when/triggers/once_strategy'
|
3
|
-
|
4
|
-
describe SayWhen::Triggers::OnceStrategy do
|
5
|
-
|
6
|
-
it "should be constucted with at option" do
|
7
|
-
time_at = 1.second.ago
|
8
|
-
o = SayWhen::Triggers::OnceStrategy.new({:at=>time_at})
|
9
|
-
o.should_not be_nil
|
10
|
-
o.once_at.should == time_at
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return once at only once" do
|
14
|
-
time_at = 1.second.ago
|
15
|
-
o = SayWhen::Triggers::OnceStrategy.new({:at=>time_at})
|
16
|
-
o.should_not be_nil
|
17
|
-
o.next_fire_at.should == time_at
|
18
|
-
o.next_fire_at(time_at + 10.second).should be_nil
|
19
|
-
o.next_fire_at(time_at - 10.second).should == time_at
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/spec/spec.opts
DELETED