say_when 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/generators/say_when_migration/say_when_migration_generator.rb +11 -0
- data/generators/say_when_migration/templates/migration.rb +48 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/say_when/migration/migration_generator.rb +13 -0
- data/lib/generators/say_when/migration/templates/migration.rb +47 -0
- data/lib/say_when/base_job.rb +96 -0
- data/lib/say_when/cron_expression.rb +621 -0
- data/lib/say_when/processor/active_messaging.rb +22 -0
- data/lib/say_when/processor/base.rb +17 -0
- data/lib/say_when/processor/simple.rb +15 -0
- data/lib/say_when/scheduler.rb +129 -0
- data/lib/say_when/storage/active_record/acts.rb +85 -0
- data/lib/say_when/storage/active_record/job.rb +85 -0
- data/lib/say_when/storage/active_record/job_execution.rb +17 -0
- data/lib/say_when/storage/memory/base.rb +34 -0
- data/lib/say_when/storage/memory/job.rb +48 -0
- data/lib/say_when/storage/mongoid/job.rb +15 -0
- data/lib/say_when/tasks.rb +22 -0
- data/lib/say_when/triggers/base.rb +11 -0
- data/lib/say_when/triggers/cron_strategy.rb +22 -0
- data/lib/say_when/triggers/once_strategy.rb +30 -0
- data/lib/say_when/version.rb +3 -0
- data/lib/say_when.rb +28 -0
- data/lib/tasks/say_when.rake +2 -0
- data/say_when.gemspec +26 -0
- data/spec/active_record_spec_helper.rb +11 -0
- data/spec/db/schema.rb +36 -0
- data/spec/db/test.db +0 -0
- data/spec/mongoid_spec_helper.rb +7 -0
- data/spec/say_when/cron_expression_spec.rb +72 -0
- data/spec/say_when/scheduler_spec.rb +76 -0
- data/spec/say_when/storage/active_record/job_spec.rb +84 -0
- data/spec/say_when/storage/memory/job_spec.rb +31 -0
- data/spec/say_when/storage/memory/trigger_spec.rb +54 -0
- data/spec/say_when/storage/mongoid/trigger_spec.rb +57 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/models.rb +31 -0
- metadata +224 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe SayWhen::CronExpression do
|
4
|
+
|
5
|
+
it "should set the time_zone" do
|
6
|
+
@ce = SayWhen::CronExpression.new("0 0 12 ? * 1#1 *", 'Pacific Time (US & Canada)')
|
7
|
+
@ce.time_zone.should == 'Pacific Time (US & Canada)'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'get first sunday in the month with "1#1' do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@ce = SayWhen::CronExpression.new("0 0 12 ? * 1#1 *", 'Pacific Time (US & Canada)')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "finds first sunday in the same month" do
|
17
|
+
@ce.next_fire_at(Time.utc(2008,1,1)).should == Time.parse('2008-01-06 12:00:00 -0800')
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
it "finds first sunday in the next month" do
|
22
|
+
@ce.next_fire_at(Time.utc(2008,1,7)).should == Time.parse('2008-02-03 12:00:00 -0800')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "finds last sunday in the same month" do
|
26
|
+
@ce.last_fire_at(Time.utc(2008,1,10)).should == Time.parse('2008-01-06 12:00:00 -0800')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "finds sundays in the prior months and years" do
|
30
|
+
@ce.last_fire_at(Time.utc(2008,1,5)).should == Time.parse('2007-12-02 12:00:00 -0800')
|
31
|
+
@ce.last_fire_at(Time.parse('2007-12-02 12:00:00 -0800') - 1.second).should == Time.parse('2007-11-04 12:00:00 -0800')
|
32
|
+
@ce.last_fire_at(Time.parse('2007-11-04 12:00:00 -0800') - 1.second).should == Time.parse('2007-10-07 12:00:00 -0700')
|
33
|
+
@ce.next_fire_at(Time.parse('2007-10-07 12:00:00 -0700') + 1.second).should == Time.parse('2007-11-04 12:00:00 -0800')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'get last sunday in the month with "1L"' do
|
38
|
+
before do
|
39
|
+
@ce = SayWhen::CronExpression.new("0 0 12 ? * 1L *", 'Pacific Time (US & Canada)')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "gets next final sunday for same month" do
|
43
|
+
@ce.next_fire_at(Time.utc(2008,1,1)).should == Time.parse('2008-01-27 12:00:00 -0800')
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
it "gets next final sunday for next month" do
|
48
|
+
@ce.next_fire_at(Time.utc(2008,1,28)).should == Time.parse('2008-02-24 12:00:00 -0800')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "gets last final sunday for same month" do
|
52
|
+
@ce.last_fire_at(Time.utc(2008,1,28)).should == Time.parse('2008-01-27 12:00:00 -0800')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "gets last sunday for prior month and year" do
|
56
|
+
@ce.last_fire_at(Time.utc(2008,1,1)).should == Time.parse('2007-12-30 12:00:00 -0800')
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
it "gets last sunday for prior month and year" do
|
61
|
+
nfa = @ce.last_fire_at(Time.utc(2007,12,1))
|
62
|
+
nfa.should == Time.parse('2007-11-25 12:00:00 -0800')
|
63
|
+
|
64
|
+
nfa = @ce.last_fire_at(nfa - 1.second)
|
65
|
+
nfa.should == Time.parse('2007-10-28 12:00:00 -0700')
|
66
|
+
|
67
|
+
nfa = @ce.next_fire_at(nfa + 1.second)
|
68
|
+
nfa.should == Time.parse('2007-11-25 12:00:00 -0800')
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../active_record_spec_helper'
|
3
|
+
|
4
|
+
describe SayWhen::Scheduler do
|
5
|
+
|
6
|
+
describe "class methods" do
|
7
|
+
|
8
|
+
it "can return singleton" do
|
9
|
+
s = SayWhen::Scheduler.scheduler
|
10
|
+
s.should_not be_nil
|
11
|
+
s.should == SayWhen::Scheduler.scheduler
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can be configured" do
|
15
|
+
SayWhen::Scheduler.configure do |scheduler|
|
16
|
+
scheduler.storage_strategy = :active_record
|
17
|
+
scheduler.processor_class = SayWhen::Test::TestProcessor
|
18
|
+
end
|
19
|
+
SayWhen::Scheduler.scheduler.storage_strategy.should == :active_record
|
20
|
+
SayWhen::Scheduler.scheduler.processor_class.should == SayWhen::Test::TestProcessor
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can schedule a new job" do
|
24
|
+
SayWhen::Scheduler.configure do |scheduler|
|
25
|
+
scheduler.storage_strategy = :active_record
|
26
|
+
scheduler.processor_class = SayWhen::Test::TestProcessor
|
27
|
+
end
|
28
|
+
|
29
|
+
job = SayWhen::Scheduler.schedule(
|
30
|
+
:trigger_strategy => 'once',
|
31
|
+
:trigger_options => 10.second.since,
|
32
|
+
:job_class => 'SayWhen::Test::TestTask',
|
33
|
+
:job_method => 'execute'
|
34
|
+
)
|
35
|
+
job.should_not be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "instance methods" do
|
41
|
+
|
42
|
+
before(:all) do
|
43
|
+
SayWhen::Scheduler.configure do |scheduler|
|
44
|
+
scheduler.storage_strategy = :active_record
|
45
|
+
scheduler.processor_class = SayWhen::Test::TestProcessor
|
46
|
+
end
|
47
|
+
@scheduler = SayWhen::Scheduler.scheduler
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should instantiate the processor from its class" do
|
51
|
+
@scheduler.processor.should be_a(SayWhen::Test::TestProcessor)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should get the job class based on the strategy" do
|
55
|
+
@scheduler.job_class.should == SayWhen::Storage::ActiveRecord::Job
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should start the scheduler running and stop it" do
|
59
|
+
@scheduler.running.should be_false
|
60
|
+
|
61
|
+
puts 'starting'
|
62
|
+
scheduler_thread = Thread.start{@scheduler.start}
|
63
|
+
puts 'started'
|
64
|
+
sleep(0.1)
|
65
|
+
@scheduler.running.should == true
|
66
|
+
|
67
|
+
puts 'stop'
|
68
|
+
@scheduler.stop
|
69
|
+
puts 'wait for it'
|
70
|
+
@scheduler.running.should == false
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../active_record_spec_helper'
|
3
|
+
require File.dirname(__FILE__) + '/../../../../lib/say_when/storage/active_record/job'
|
4
|
+
|
5
|
+
describe SayWhen::Storage::ActiveRecord::Job do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@valid_attributes = {
|
9
|
+
:trigger_strategy => :cron,
|
10
|
+
:trigger_options => {:expression => '0 0 12 ? * * *', :time_zone => 'Pacific Time (US & Canada)'},
|
11
|
+
:data => {:foo=>'bar', :result=>1},
|
12
|
+
:job_class => 'SayWhen::Test::TestTask',
|
13
|
+
:job_method => 'execute'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can be instantiated" do
|
18
|
+
j = SayWhen::Storage::ActiveRecord::Job.create!(@valid_attributes)
|
19
|
+
j.should_not be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "can execute the task for the job" do
|
23
|
+
j = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
24
|
+
j.execute_job({:result=>1}).should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can execute the job" do
|
28
|
+
j = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
29
|
+
j.execute.should == 1
|
30
|
+
end
|
31
|
+
|
32
|
+
it "derives a trigger from the attributes" do
|
33
|
+
t = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
34
|
+
t.trigger.should_not be_nil
|
35
|
+
t.trigger.should be_a SayWhen::Triggers::CronStrategy
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has a waiting state on create" do
|
39
|
+
t = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
40
|
+
t.status.should == SayWhen::BaseJob::STATE_WAITING
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a next fire at set on create" do
|
44
|
+
opts = @valid_attributes[:trigger_options]
|
45
|
+
ce = SayWhen::CronExpression.new(opts[:expression], opts[:time_zone])
|
46
|
+
j = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
47
|
+
j.status.should == SayWhen::BaseJob::STATE_WAITING
|
48
|
+
j.next_fire_at.should == ce.next_fire_at
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can find the next job" do
|
52
|
+
j2_opts = {
|
53
|
+
:trigger_strategy => :cron,
|
54
|
+
:trigger_options => {:expression => '0 0 10 ? * * *', :time_zone => 'Pacific Time (US & Canada)'},
|
55
|
+
:data => {:foo=>'bar', :result=>2},
|
56
|
+
:job_class => 'SayWhen::Test::TestTask',
|
57
|
+
:job_method => 'execute'
|
58
|
+
}
|
59
|
+
|
60
|
+
j1 = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
61
|
+
j2 = SayWhen::Storage::ActiveRecord::Job.create(j2_opts)
|
62
|
+
next_job = SayWhen::Storage::ActiveRecord::Job.acquire_next(1.day.since)
|
63
|
+
next_job.should == j2
|
64
|
+
end
|
65
|
+
|
66
|
+
it "can be fired" do
|
67
|
+
opts = @valid_attributes[:trigger_options]
|
68
|
+
ce = SayWhen::CronExpression.new(opts[:expression], opts[:time_zone])
|
69
|
+
j = SayWhen::Storage::ActiveRecord::Job.create(@valid_attributes)
|
70
|
+
nfa = ce.last_fire_at(j.created_at - 1.second)
|
71
|
+
lfa = ce.last_fire_at(nfa - 1.second)
|
72
|
+
j.next_fire_at = nfa
|
73
|
+
j.last_fire_at = lfa
|
74
|
+
|
75
|
+
now = Time.now
|
76
|
+
Time.stub!(:now).and_return(now)
|
77
|
+
|
78
|
+
j.fired
|
79
|
+
j.next_fire_at.should == ce.next_fire_at(now)
|
80
|
+
j.last_fire_at.should == now
|
81
|
+
j.status.should == SayWhen::BaseJob::STATE_WAITING
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../../lib/say_when/storage/memory/job'
|
3
|
+
|
4
|
+
describe SayWhen::Store::Memory::Job do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@valid_attributes = {
|
8
|
+
:name => 'Memory::Job::Test',
|
9
|
+
:group => 'Test',
|
10
|
+
:data => {:foo=>'bar', :result=>1},
|
11
|
+
:job_class => 'SayWhen::Test::TestTask',
|
12
|
+
:job_method => 'execute'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can be instantiated" do
|
17
|
+
j = SayWhen::Store::Memory::Job.new(@valid_attributes)
|
18
|
+
j.should_not be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can execute the task for the job" do
|
22
|
+
j = SayWhen::Store::Memory::Job.new(@valid_attributes)
|
23
|
+
j.execute_job({:result=>1}).should == 1
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can execute the job" do
|
27
|
+
j = SayWhen::Store::Memory::Job.new(@valid_attributes)
|
28
|
+
j.execute.should == 1
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../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
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../../../mongoid_spec_helper'
|
3
|
+
# require File.dirname(__FILE__) + '/../../../../lib/say_when/store/mongoid/trigger'
|
4
|
+
|
5
|
+
# describe SayWhen::Store::Mongoid::Trigger do
|
6
|
+
|
7
|
+
# before(:each) do
|
8
|
+
# SayWhen::Store::Mongoid::Trigger.delete_all
|
9
|
+
# @valid_attributes = {
|
10
|
+
# :expression => '0 0 12 ? * * *',
|
11
|
+
# :time_zone => 'Pacific Time (US & Canada)'
|
12
|
+
# }
|
13
|
+
# end
|
14
|
+
|
15
|
+
# it "can be created using new and save" do
|
16
|
+
# t = SayWhen::Store::Mongoid::Trigger.new(@valid_attributes)
|
17
|
+
# t.should be_valid
|
18
|
+
# t.save
|
19
|
+
# end
|
20
|
+
|
21
|
+
# it "sets a cron_expression" do
|
22
|
+
# t = SayWhen::Store::Mongoid::Trigger.create(@valid_attributes)
|
23
|
+
# t.cron_expression.should_not be_nil
|
24
|
+
# t.cron_expression.expression.should == '0 0 12 ? * * *'
|
25
|
+
# t.cron_expression.time_zone.should == 'Pacific Time (US & Canada)'
|
26
|
+
# end
|
27
|
+
|
28
|
+
# it "has a waiting state on create" do
|
29
|
+
# t = SayWhen::Store::Mongoid::Trigger.create(@valid_attributes)
|
30
|
+
# t.status.should == SayWhen::BaseTrigger::STATE_WAITING
|
31
|
+
# end
|
32
|
+
|
33
|
+
# it "has a next fire at set on create" do
|
34
|
+
# ce = SayWhen::CronExpression.new(@valid_attributes[:expression], @valid_attributes[:time_zone])
|
35
|
+
# t = SayWhen::Store::Mongoid::Trigger.create(@valid_attributes)
|
36
|
+
# t.status.should == SayWhen::BaseTrigger::STATE_WAITING
|
37
|
+
# t.next_fire_at.should == ce.next_fire_at(t.created_at)
|
38
|
+
# end
|
39
|
+
|
40
|
+
# it "can be fired" do
|
41
|
+
# ce = SayWhen::CronExpression.new(@valid_attributes[:expression], @valid_attributes[:time_zone])
|
42
|
+
# t = SayWhen::Store::Mongoid::Trigger.create(@valid_attributes)
|
43
|
+
# nfa = ce.last_fire_at(t.created_at - 1.second)
|
44
|
+
# lfa = ce.last_fire_at(nfa - 1.second)
|
45
|
+
# t.next_fire_at = nfa
|
46
|
+
# t.last_fire_at = lfa
|
47
|
+
|
48
|
+
# now = Time.now
|
49
|
+
# Time.stub!(:now).and_return(now)
|
50
|
+
|
51
|
+
# t.fired
|
52
|
+
# t.next_fire_at.should == ce.next_fire_at(now)
|
53
|
+
# t.last_fire_at.should == now
|
54
|
+
# t.status.should == SayWhen::BaseTrigger::STATE_WAITING
|
55
|
+
# end
|
56
|
+
|
57
|
+
# end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
ENV['RAILS_ENV']='test'
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'active_support'
|
6
|
+
|
7
|
+
require 'spec'
|
8
|
+
require 'spec/autorun'
|
9
|
+
|
10
|
+
$: << (File.dirname(__FILE__) + "/../lib")
|
11
|
+
require "say_when"
|
12
|
+
|
13
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
14
|
+
|
15
|
+
Spec::Runner.configure do |config|
|
16
|
+
config.mock_with :rspec
|
17
|
+
end
|
18
|
+
|
19
|
+
module SayWhen
|
20
|
+
module Test
|
21
|
+
|
22
|
+
class TestTask
|
23
|
+
def execute(data)
|
24
|
+
data[:result] || 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class TestProcessor < SayWhen::Processor::Base
|
29
|
+
attr_accessor :jobs
|
30
|
+
|
31
|
+
def initialize(scheduler)
|
32
|
+
super(scheduler)
|
33
|
+
reset
|
34
|
+
end
|
35
|
+
|
36
|
+
def process(job)
|
37
|
+
self.jobs << job
|
38
|
+
end
|
39
|
+
|
40
|
+
def reset
|
41
|
+
self.jobs = []
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
class TestModel < Object
|
4
|
+
attr_accessor :id
|
5
|
+
|
6
|
+
def initialize(id=nil)
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def ==(b)
|
11
|
+
return false unless b
|
12
|
+
# puts "compare: #{self.class.name}_#{@id} == #{b.class.name}_#{b.id}"
|
13
|
+
@id == b.id
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
|
18
|
+
def find(ids=nil)
|
19
|
+
Array(ids).collect{|i| self.new(i)}
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class User < TestModel
|
27
|
+
end
|
28
|
+
|
29
|
+
class Account < TestModel
|
30
|
+
attr_accessor :owner
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: say_when
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andrew Kuklewicz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-06-06 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activemessaging
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 59
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 9
|
31
|
+
- 0
|
32
|
+
version: 0.9.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 31
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 3
|
47
|
+
- 14
|
48
|
+
version: 2.3.14
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
requirement: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: activerecord
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 31
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 3
|
63
|
+
- 14
|
64
|
+
version: 2.3.14
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
requirement: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: mongoid
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 57
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 9
|
79
|
+
- 5
|
80
|
+
version: 1.9.5
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
requirement: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 9
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 3
|
95
|
+
version: "1.3"
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
requirement: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: sqlite3
|
101
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
requirement: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rake
|
115
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
requirement: *id007
|
127
|
+
description:
|
128
|
+
email:
|
129
|
+
- andrew@prx.org
|
130
|
+
executables: []
|
131
|
+
|
132
|
+
extensions: []
|
133
|
+
|
134
|
+
extra_rdoc_files: []
|
135
|
+
|
136
|
+
files:
|
137
|
+
- .gitignore
|
138
|
+
- Gemfile
|
139
|
+
- Rakefile
|
140
|
+
- generators/say_when_migration/say_when_migration_generator.rb
|
141
|
+
- generators/say_when_migration/templates/migration.rb
|
142
|
+
- lib/generators/.DS_Store
|
143
|
+
- lib/generators/say_when/migration/migration_generator.rb
|
144
|
+
- lib/generators/say_when/migration/templates/migration.rb
|
145
|
+
- lib/say_when.rb
|
146
|
+
- lib/say_when/base_job.rb
|
147
|
+
- lib/say_when/cron_expression.rb
|
148
|
+
- lib/say_when/processor/active_messaging.rb
|
149
|
+
- lib/say_when/processor/base.rb
|
150
|
+
- lib/say_when/processor/simple.rb
|
151
|
+
- lib/say_when/scheduler.rb
|
152
|
+
- lib/say_when/storage/active_record/acts.rb
|
153
|
+
- lib/say_when/storage/active_record/job.rb
|
154
|
+
- lib/say_when/storage/active_record/job_execution.rb
|
155
|
+
- lib/say_when/storage/memory/base.rb
|
156
|
+
- lib/say_when/storage/memory/job.rb
|
157
|
+
- lib/say_when/storage/mongoid/job.rb
|
158
|
+
- lib/say_when/tasks.rb
|
159
|
+
- lib/say_when/triggers/base.rb
|
160
|
+
- lib/say_when/triggers/cron_strategy.rb
|
161
|
+
- lib/say_when/triggers/once_strategy.rb
|
162
|
+
- lib/say_when/version.rb
|
163
|
+
- lib/tasks/say_when.rake
|
164
|
+
- say_when.gemspec
|
165
|
+
- spec/active_record_spec_helper.rb
|
166
|
+
- spec/db/schema.rb
|
167
|
+
- spec/db/test.db
|
168
|
+
- spec/mongoid_spec_helper.rb
|
169
|
+
- spec/say_when/cron_expression_spec.rb
|
170
|
+
- spec/say_when/scheduler_spec.rb
|
171
|
+
- spec/say_when/storage/active_record/job_spec.rb
|
172
|
+
- spec/say_when/storage/memory/job_spec.rb
|
173
|
+
- spec/say_when/storage/memory/trigger_spec.rb
|
174
|
+
- spec/say_when/storage/mongoid/trigger_spec.rb
|
175
|
+
- spec/spec.opts
|
176
|
+
- spec/spec_helper.rb
|
177
|
+
- spec/support/models.rb
|
178
|
+
homepage: http://labs.prx.org
|
179
|
+
licenses: []
|
180
|
+
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
hash: 3
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
version: "0"
|
195
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
none: false
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
hash: 3
|
201
|
+
segments:
|
202
|
+
- 0
|
203
|
+
version: "0"
|
204
|
+
requirements: []
|
205
|
+
|
206
|
+
rubyforge_project:
|
207
|
+
rubygems_version: 1.8.22
|
208
|
+
signing_key:
|
209
|
+
specification_version: 3
|
210
|
+
summary: Scheduling system for programmatically defined and stored jobs.
|
211
|
+
test_files:
|
212
|
+
- spec/active_record_spec_helper.rb
|
213
|
+
- spec/db/schema.rb
|
214
|
+
- spec/db/test.db
|
215
|
+
- spec/mongoid_spec_helper.rb
|
216
|
+
- spec/say_when/cron_expression_spec.rb
|
217
|
+
- spec/say_when/scheduler_spec.rb
|
218
|
+
- spec/say_when/storage/active_record/job_spec.rb
|
219
|
+
- spec/say_when/storage/memory/job_spec.rb
|
220
|
+
- spec/say_when/storage/memory/trigger_spec.rb
|
221
|
+
- spec/say_when/storage/mongoid/trigger_spec.rb
|
222
|
+
- spec/spec.opts
|
223
|
+
- spec/spec_helper.rb
|
224
|
+
- spec/support/models.rb
|