active_scheduler 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -0
- data/README.markdown +2 -0
- data/lib/active_scheduler/resque_wrapper.rb +4 -2
- data/lib/active_scheduler/version.rb +1 -1
- data/spec/active_scheduler/resque_wrapper_spec.rb +19 -1
- data/spec/spec_helper.rb +9 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ba70054e1bb771404a32c12fb267d203af40ff
|
4
|
+
data.tar.gz: 8ae34c71ac6b98180726bac6c709d302d6fec381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ce49add1fbfd7c9f7855a9743c427f52c425bcb90ecf8937aefb1c92231d474f7acbfa5fc4e53f60fa9eb2a2c696033d1267f964ca4a0605ce2a4ab7053a6d3
|
7
|
+
data.tar.gz: 5c8b69658933b8c32f07d784ce01c95534c4b680c30c6a319015f257cc50e94d25d5f110970f3a40e52a7addb51b6c0989ef31844eaafa02c461bea5c0bcf1b9
|
data/CHANGELOG.markdown
ADDED
data/README.markdown
CHANGED
@@ -15,7 +15,9 @@ module ActiveScheduler
|
|
15
15
|
schedule = HashWithIndifferentAccess.new(schedule)
|
16
16
|
|
17
17
|
schedule.each do |job, opts|
|
18
|
-
|
18
|
+
class_name = opts[:class] || job
|
19
|
+
next if class_name =~ /ActiveScheduler::ResqueWrapper/
|
20
|
+
next unless class_name.constantize <= ActiveJob::Base
|
19
21
|
|
20
22
|
queue = opts[:queue] || 'default'
|
21
23
|
|
@@ -23,7 +25,7 @@ module ActiveScheduler
|
|
23
25
|
class: 'ActiveScheduler::ResqueWrapper',
|
24
26
|
queue: queue,
|
25
27
|
args: [{
|
26
|
-
job_class:
|
28
|
+
job_class: class_name,
|
27
29
|
queue_name: queue,
|
28
30
|
arguments: opts[:arguments]
|
29
31
|
}]
|
@@ -9,6 +9,7 @@ describe ActiveScheduler::ResqueWrapper do
|
|
9
9
|
let(:schedule) { YAML.load_file 'spec/fixtures/simple_job.yaml' }
|
10
10
|
|
11
11
|
it "queues up a simple job" do
|
12
|
+
stub_jobs("SimpleJob")
|
12
13
|
expect(wrapped['simple_job']).to eq(
|
13
14
|
"class" => "ActiveScheduler::ResqueWrapper",
|
14
15
|
"queue" => "simple",
|
@@ -21,12 +22,26 @@ describe ActiveScheduler::ResqueWrapper do
|
|
21
22
|
}]
|
22
23
|
)
|
23
24
|
end
|
25
|
+
|
26
|
+
context "job is not an active job descendant" do
|
27
|
+
it "doesn't wrap" do
|
28
|
+
stub_const("SimpleJob", Class.new)
|
29
|
+
expect(wrapped['simple_job']).to eq(
|
30
|
+
"class" => "SimpleJob",
|
31
|
+
"queue" => "simple",
|
32
|
+
"description" => "It's a simple job.",
|
33
|
+
"every" => "30s",
|
34
|
+
"args" => [nil],
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
24
38
|
end
|
25
39
|
|
26
40
|
context "with a simple job json" do
|
27
41
|
let(:schedule) { YAML.load_file 'spec/fixtures/simple_job.json' }
|
28
42
|
|
29
43
|
it "queues up a simple job" do
|
44
|
+
stub_jobs("SimpleJob")
|
30
45
|
expect(wrapped['simple_job']).to eq(
|
31
46
|
"class" => "ActiveScheduler::ResqueWrapper",
|
32
47
|
"queue" => "simple",
|
@@ -45,6 +60,7 @@ describe ActiveScheduler::ResqueWrapper do
|
|
45
60
|
let(:schedule) { YAML.load_file 'spec/fixtures/two_jobs.yaml' }
|
46
61
|
|
47
62
|
it "queues them all up simple job" do
|
63
|
+
stub_jobs("JobOne", "JobTwo")
|
48
64
|
expect(wrapped['job_1']['args'][0]['job_class']).to eq 'JobOne'
|
49
65
|
expect(wrapped['job_2']['args'][0]['job_class']).to eq 'JobTwo'
|
50
66
|
end
|
@@ -54,6 +70,7 @@ describe ActiveScheduler::ResqueWrapper do
|
|
54
70
|
let(:schedule) { YAML.load_file 'spec/fixtures/cron_job.yaml' }
|
55
71
|
|
56
72
|
it "uses that instead" do
|
73
|
+
stub_jobs("CronJob")
|
57
74
|
expect(wrapped['cron_job']['cron']).to eq '* * * *'
|
58
75
|
expect(wrapped['cron_job']['every']).to be_nil
|
59
76
|
end
|
@@ -63,6 +80,7 @@ describe ActiveScheduler::ResqueWrapper do
|
|
63
80
|
let(:schedule) { YAML.load_file 'spec/fixtures/no_queue.yaml' }
|
64
81
|
|
65
82
|
it "uses 'default'" do
|
83
|
+
stub_jobs("SimpleJob")
|
66
84
|
expect(wrapped['no_queue_job']['queue']).to eq 'default'
|
67
85
|
end
|
68
86
|
end
|
@@ -71,6 +89,7 @@ describe ActiveScheduler::ResqueWrapper do
|
|
71
89
|
let(:schedule) { YAML.load_file 'spec/fixtures/schedule_name_is_class_name.yaml' }
|
72
90
|
|
73
91
|
it "queues up a job, using the schedule name for the class name" do
|
92
|
+
stub_jobs("MyScheduleNameIsClassNameJob")
|
74
93
|
expect(wrapped['MyScheduleNameIsClassNameJob']).to eq(
|
75
94
|
"class" => "ActiveScheduler::ResqueWrapper",
|
76
95
|
"queue" => "myscheduledjobqueue",
|
@@ -83,7 +102,6 @@ describe ActiveScheduler::ResqueWrapper do
|
|
83
102
|
}]
|
84
103
|
)
|
85
104
|
end
|
86
|
-
|
87
105
|
end
|
88
106
|
end
|
89
107
|
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,16 @@ unless ENV["NO_COVERALLS"]
|
|
5
5
|
Coveralls.wear!
|
6
6
|
end
|
7
7
|
|
8
|
+
module Helpers
|
9
|
+
def stub_jobs(*names)
|
10
|
+
names.each do |name|
|
11
|
+
stub_const(name, Class.new(ActiveJob::Base))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
RSpec.configure do |config|
|
17
|
+
config.include Helpers
|
9
18
|
config.filter_run :focus
|
10
19
|
config.run_all_when_everything_filtered = true
|
11
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Aiken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.markdown
|
93
94
|
- Gemfile
|
94
95
|
- Guardfile
|
95
96
|
- LICENSE
|
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
version: '0'
|
128
129
|
requirements: []
|
129
130
|
rubyforge_project: active_scheduler
|
130
|
-
rubygems_version: 2.4.
|
131
|
+
rubygems_version: 2.4.8
|
131
132
|
signing_key:
|
132
133
|
specification_version: 4
|
133
134
|
summary: Scheduling for ActiveJob
|