say_when 0.4.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +13 -4
  3. data/Gemfile +1 -9
  4. data/LICENSE +21 -0
  5. data/README.md +31 -0
  6. data/Rakefile +6 -6
  7. data/lib/generators/say_when/migration/migration_generator.rb +8 -5
  8. data/lib/generators/say_when/migration/templates/migration.rb +8 -7
  9. data/lib/say_when/base_job.rb +2 -0
  10. data/lib/say_when/cron_expression.rb +129 -191
  11. data/lib/say_when/processor/active_messaging.rb +7 -8
  12. data/lib/say_when/processor/base.rb +5 -3
  13. data/lib/say_when/processor/shoryuken.rb +14 -0
  14. data/lib/say_when/processor/simple.rb +2 -0
  15. data/lib/say_when/railtie.rb +9 -0
  16. data/lib/say_when/scheduler.rb +49 -90
  17. data/lib/say_when/storage/active_record/acts.rb +16 -16
  18. data/lib/say_when/storage/active_record/job.rb +17 -24
  19. data/lib/say_when/storage/active_record/job_execution.rb +5 -8
  20. data/lib/say_when/storage/memory/base.rb +3 -1
  21. data/lib/say_when/storage/memory/job.rb +14 -42
  22. data/lib/say_when/tasks.rb +4 -4
  23. data/lib/say_when/triggers/base.rb +4 -3
  24. data/lib/say_when/triggers/cron_strategy.rb +4 -3
  25. data/lib/say_when/triggers/instance_strategy.rb +4 -3
  26. data/lib/say_when/triggers/once_strategy.rb +3 -2
  27. data/lib/say_when/version.rb +3 -1
  28. data/lib/say_when.rb +8 -7
  29. data/lib/tasks/say_when.rake +3 -1
  30. data/say_when.gemspec +26 -19
  31. data/test/active_record_helper.rb +13 -0
  32. data/{spec → test}/db/schema.rb +4 -4
  33. data/{spec/spec_helper.rb → test/minitest_helper.rb} +9 -19
  34. data/test/say_when/cron_expression_spec.rb +74 -0
  35. data/{spec/say_when/processor/active_messaging_spec.rb → test/say_when/processor/active_messaging_test.rb} +17 -13
  36. data/test/say_when/scheduler_test.rb +75 -0
  37. data/test/say_when/storage/active_record/job_test.rb +90 -0
  38. data/test/say_when/storage/memory/job_test.rb +32 -0
  39. data/test/say_when/storage/memory/trigger_test.rb +54 -0
  40. data/test/say_when/triggers/once_strategy_test.rb +23 -0
  41. data/{spec → test}/support/models.rb +5 -3
  42. metadata +97 -54
  43. data/.travis.yml +0 -4
  44. data/generators/say_when_migration/say_when_migration_generator.rb +0 -11
  45. data/generators/say_when_migration/templates/migration.rb +0 -48
  46. data/spec/active_record_spec_helper.rb +0 -9
  47. data/spec/say_when/cron_expression_spec.rb +0 -72
  48. data/spec/say_when/scheduler_spec.rb +0 -126
  49. data/spec/say_when/storage/active_record/job_spec.rb +0 -97
  50. data/spec/say_when/storage/memory/job_spec.rb +0 -45
  51. data/spec/say_when/storage/memory/trigger_spec.rb +0 -54
  52. data/spec/say_when/triggers/once_strategy_spec.rb +0 -22
  53. 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
@@ -1,4 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse