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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2c062dfa8434dc5822c02c0a44aac00ea427afc
4
- data.tar.gz: 2c2667862c1528c8c2fd2d9a8ed4e7dd12834c66
3
+ metadata.gz: 26ba70054e1bb771404a32c12fb267d203af40ff
4
+ data.tar.gz: 8ae34c71ac6b98180726bac6c709d302d6fec381
5
5
  SHA512:
6
- metadata.gz: 9b0bbfebcedf077487966652616de23b0b6b144ec831a8f7870b82343508dd2777f88e5da43be245847f83c780fe4a91eebe60ea6dd3ce9fad1b35fd301a3bbc
7
- data.tar.gz: 79f0c8ebf0777cd5d41284989969d8d5ed8efe3d1241f40ae4bfc7b3d372992f4e2bbc9db0c604e5cb4ec885b45f73b9a23baf602ad026d63c8187042372bf1b
6
+ metadata.gz: 4ce49add1fbfd7c9f7855a9743c427f52c425bcb90ecf8937aefb1c92231d474f7acbfa5fc4e53f60fa9eb2a2c696033d1267f964ca4a0605ce2a4ab7053a6d3
7
+ data.tar.gz: 5c8b69658933b8c32f07d784ce01c95534c4b680c30c6a319015f257cc50e94d25d5f110970f3a40e52a7addb51b6c0989ef31844eaafa02c461bea5c0bcf1b9
@@ -0,0 +1,5 @@
1
+ # 0.1.0
2
+
3
+ - Only wrap jobs that are descendants of `ActiveJob::Base` [#3](https://github.com/JustinAiken/active_scheduler/pull/3)
4
+
5
+ # 0.0.3
data/README.markdown CHANGED
@@ -55,6 +55,8 @@ ThisIsTheClass:
55
55
  description: "Will call the ThisIsTheClass class"
56
56
  ```
57
57
 
58
+ Only classes that are descended from `ActiveJob::Base` will be wrapped
59
+
58
60
  ## Credits
59
61
 
60
62
  - Written by [@JustinAiken](https://www.github.com/JustinAiken)
@@ -15,7 +15,9 @@ module ActiveScheduler
15
15
  schedule = HashWithIndifferentAccess.new(schedule)
16
16
 
17
17
  schedule.each do |job, opts|
18
- next if opts[:class] =~ /ActiveScheduler::ResqueWrapper/
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: opts[:class] || job,
28
+ job_class: class_name,
27
29
  queue_name: queue,
28
30
  arguments: opts[:arguments]
29
31
  }]
@@ -1,3 +1,3 @@
1
1
  module ActiveScheduler
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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.3
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: 2015-10-07 00:00:00.000000000 Z
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.5
131
+ rubygems_version: 2.4.8
131
132
  signing_key:
132
133
  specification_version: 4
133
134
  summary: Scheduling for ActiveJob