actionable 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aba5c2dd61d34960608b12a00742c86eddeb904e
4
- data.tar.gz: 0c9d7ab01b25b32b973c7a69e8cf254999a46eaf
3
+ metadata.gz: b187586cc793a33104a2f5c1710daefae5d25023
4
+ data.tar.gz: 77797479469c0474aa59cc8c545160086ba50033
5
5
  SHA512:
6
- metadata.gz: b83923f9cde4a28559ac389a02f634541947c320cfe36655a3d42756ad400df0b6f419708ad1141ceaf82e4bce9959260b044ec73eea0f93580f733ad1492261
7
- data.tar.gz: e8ad792fcfb39c41ee9f1edc8f71000b6a8018b4bc21d7686b6148deaf642ff47ed5232f63b1dc8ca52682a2b7b49ec133dc6191d334c6632faf57b3b03cffc2
6
+ metadata.gz: 535ef546df907bbdc4eb4b1564bf8272185cd8724842394f216f25c98f0dd77c65111add75475a412ebc88f945453f2e4a11d39659da394d3b144472a7479ec1
7
+ data.tar.gz: dd8b4beee3770047d760f8f126907358407931d072e9eca60825b2cc43d177e5c229ca2d7ab90b50e6e5a40eca5e7ac481f1cc388f17b4e9f9aa0e9b5c15ddcb
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'resque', github: 'resque/resque', branch: 'master'
3
+ gem 'resque', '~> 1.24.1'
4
4
  gem 'mongoid', github: 'mongoid/mongoid', branch: 'master'
5
- gemspec
5
+ gemspec
data/actionable.gemspec CHANGED
@@ -27,7 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rb-fsevent"
28
28
  spec.add_development_dependency "terminal-notifier-guard"
29
29
 
30
- spec.add_dependency "resque", "~> 2.0.0.pre.1"
30
+ spec.add_dependency "activesupport", "~> 4.0.0"
31
+ spec.add_dependency "resque", "~> 1.24.1"
31
32
  spec.add_dependency "mongoid", "~> 4.0.0"
32
33
  spec.add_dependency "rufus-scheduler"
33
34
 
data/lib/actionable.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "mongoid"
2
2
  require "resque"
3
+ require "active_support"
3
4
 
4
5
  require "actionable/version"
5
6
 
@@ -1,16 +1,17 @@
1
1
  require 'actionable/sweep'
2
2
 
3
3
  module Resque
4
- class MultiQueue
5
-
6
- alias :default_poll :poll
4
+ class Worker
7
5
 
8
- def poll(t)
9
- default_poll(t) || sweep
6
+ alias :default_reserve :reserve
7
+
8
+ def reserve
9
+ default_reserve || sweep
10
10
  end
11
11
 
12
12
  def sweep
13
13
  Resque.enqueue(Actionable::Sweep)
14
+ nil
14
15
  end
15
16
 
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module Actionable
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/job_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  class TestWorker
4
-
4
+
5
5
  attr_accessor :pid
6
6
 
7
7
  def spawn
@@ -40,7 +40,7 @@ describe Actionable::Job do
40
40
  }
41
41
 
42
42
  before do
43
- target.schedule_actionable(1.minute.ago,TestJob,{number:2})
43
+ target.schedule_actionable(1.minute.ago,TestJob,{number:2})
44
44
  end
45
45
 
46
46
  it "should be executed by a worker manually" do
@@ -61,4 +61,4 @@ describe Actionable::Job do
61
61
 
62
62
  end
63
63
 
64
- end
64
+ end
@@ -2,98 +2,110 @@ require "spec_helper"
2
2
 
3
3
  describe Actionable::Recurrence do
4
4
 
5
- let(:every_five){ "*/5 * * * *" }
6
- let(:new_args){
7
- { recurrence_string:every_five, job_class: RecurringTestJob }
8
- }
9
-
10
- let(:recurrence) {
11
- Actionable::Recurrence.create(new_args)
12
- }
13
-
14
- it "should be instantiated with a recurrence string and a job class" do
15
- r = Actionable::Recurrence.new(new_args)
16
- expect(r).to be_valid
17
- end
5
+ context "every day at 2:00 AM" do
6
+ let(:every_day_at_2){ "0 2 * * *" }
18
7
 
19
- it "should refuse to save with a bad recurrence string" do
20
- new_args[:recurrence_string] = '* D * L * . *'
21
- r = Actionable::Recurrence.new(new_args)
22
- expect(r).to_not be_valid
8
+ it "should parse good" do
9
+ recurrence = Rufus::CronLine.new(every_day_at_2)
10
+ end
23
11
  end
24
12
 
25
- it "should refuse to save with a non-existent class" do
26
- new_args[:job_class] = "NonExistentJob"
27
- r = Actionable::Recurrence.new(new_args)
28
- expect(r).to_not be_valid
29
- end
13
+ context "every five minutes" do
30
14
 
15
+ let(:every_five){ "*/5 * * * *" }
16
+ let(:new_args){
17
+ { recurrence_string:every_five, job_class: RecurringTestJob }
18
+ }
31
19
 
32
- it "should not add to the database until saved" do
33
- r = Actionable::Recurrence.new(new_args)
34
- expect(Actionable::Recurrence.count).to eq(0)
35
- end
20
+ let(:recurrence) {
21
+ Actionable::Recurrence.create(new_args)
22
+ }
36
23
 
37
- it "should add to the database afer being committed" do
38
- r = Actionable::Recurrence.new(new_args)
39
- r.save
40
- expect(Actionable::Recurrence.count).to eq(1)
41
- end
24
+ it "should be instantiated with a recurrence string and a job class" do
25
+ r = Actionable::Recurrence.new(new_args)
26
+ expect(r).to be_valid
27
+ end
42
28
 
43
- it "should know its job class" do
44
- expect(recurrence.send(:job_class)).to eq(RecurringTestJob)
45
- end
29
+ it "should refuse to save with a bad recurrence string" do
30
+ new_args[:recurrence_string] = '* D * L * . *'
31
+ r = Actionable::Recurrence.new(new_args)
32
+ expect(r).to_not be_valid
33
+ end
34
+
35
+ it "should refuse to save with a non-existent class" do
36
+ new_args[:job_class] = "NonExistentJob"
37
+ r = Actionable::Recurrence.new(new_args)
38
+ expect(r).to_not be_valid
39
+ end
46
40
 
47
- it "should create an actionable upon creation" do
48
- expect(Actionable::Action.count).to eq(0)
49
- Actionable::Recurrence.create(new_args)
50
- expect(Actionable::Action.count).to eq(1)
51
- end
52
41
 
53
- context "when time passes" do
42
+ it "should not add to the database until saved" do
43
+ r = Actionable::Recurrence.new(new_args)
44
+ expect(Actionable::Recurrence.count).to eq(0)
45
+ end
46
+
47
+ it "should add to the database afer being committed" do
48
+ r = Actionable::Recurrence.new(new_args)
49
+ r.save
50
+ expect(Actionable::Recurrence.count).to eq(1)
51
+ end
54
52
 
55
- before do
56
- Resque.inline = true
57
- recurrence.valid?
58
- Timecop.travel(5.minutes.from_now)
53
+ it "should know its job class" do
54
+ expect(recurrence.send(:job_class)).to eq(RecurringTestJob)
59
55
  end
60
-
61
- it "should run the first action and create a new one on sweep" do
56
+
57
+ it "should create an actionable upon creation" do
58
+ expect(Actionable::Action.count).to eq(0)
59
+ Actionable::Recurrence.create(new_args)
62
60
  expect(Actionable::Action.count).to eq(1)
63
- Actionable::Sweep.perform
64
- expect(Actionable::Action.count).to eq(2)
65
61
  end
66
62
 
67
- end
63
+ context "when time passes" do
68
64
 
69
- context "when no time passes" do
65
+ before do
66
+ Resque.inline = true
67
+ recurrence.valid?
68
+ Timecop.travel(5.minutes.from_now)
69
+ end
70
70
 
71
- before do
72
- Resque.inline = true
73
- recurrence.valid?
74
- end
71
+ it "should run the first action and create a new one on sweep" do
72
+ expect(Actionable::Action.count).to eq(1)
73
+ 2.times { Actionable::Sweep.perform }
74
+ expect(Actionable::Action.count).to eq(2)
75
+ end
75
76
 
76
- it "should not run the first action or create a new one" do
77
- expect(Actionable::Action.count).to eq(1)
78
- Actionable::Sweep.perform
79
- expect(Actionable::Action.count).to eq(1)
80
77
  end
81
78
 
82
- end
79
+ context "when no time passes" do
83
80
 
84
- context "over the course of an hour" do
81
+ before do
82
+ Resque.inline = true
83
+ recurrence.valid?
84
+ end
85
85
 
86
- it "should create and perform the job 11 times" do
87
- RecurringTestJob.should_receive(:go).at_least(11).times
88
- Timecop.travel(1.hour.from_now.change(minutes:0))
89
- recurrence.valid?
90
- 60.times do
86
+ it "should not run the first action or create a new one" do
87
+ expect(Actionable::Action.count).to eq(1)
91
88
  Actionable::Sweep.perform
92
- Timecop.travel(1.minute.from_now)
89
+ expect(Actionable::Action.count).to eq(1)
93
90
  end
94
- expect(Actionable::Action.count).to be_within(1).of(12)
91
+
92
+ end
93
+
94
+ context "over the course of an hour" do
95
+
96
+ it "should create and perform the job 11 times" do
97
+ RecurringTestJob.should_receive(:go).at_least(11).times
98
+ Timecop.travel(1.hour.from_now.change(minutes:0))
99
+ recurrence.valid?
100
+ 60.times do
101
+ Actionable::Sweep.perform
102
+ Timecop.travel(1.minute.from_now)
103
+ end
104
+ expect(Actionable::Action.count).to be_within(1).of(12)
105
+ end
106
+
95
107
  end
96
108
 
97
109
  end
98
110
 
99
- end
111
+ end
data/spec/sweep_spec.rb CHANGED
@@ -26,15 +26,15 @@ describe Actionable::Sweep do
26
26
 
27
27
  it "should enqueue a job that knows the id for its target" do
28
28
  Actionable::Sweep.perform
29
- expect(Resque.queue('actionable').pop['args'].first).to eq(target.actionables.first.id.to_s)
29
+ expect(Resque.pop('actionable')['args'].first).to eq(target.actionables.first.id.to_s)
30
30
  end
31
31
 
32
32
  it "should update the actionable's status to 'enqueued'" do
33
- expect(target.actionables.first.status).to eq(:late)
33
+ expect(target.actionables.first.status).to eq(:late)
34
34
  Actionable::Sweep.perform
35
35
  expect(target.actionables.first.status).to eq(:enqueued)
36
36
  end
37
37
 
38
38
  end
39
39
 
40
- end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Luxemburg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-16 00:00:00.000000000 Z
11
+ date: 2013-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,20 +122,34 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: activesupport
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 4.0.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 4.0.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: resque
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ~>
130
144
  - !ruby/object:Gem::Version
131
- version: 2.0.0.pre.1
145
+ version: 1.24.1
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - ~>
137
151
  - !ruby/object:Gem::Version
138
- version: 2.0.0.pre.1
152
+ version: 1.24.1
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: mongoid
141
155
  requirement: !ruby/object:Gem::Requirement