active_scheduler 0.5.0 → 0.6.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: 9445ea94c943115cbf2f6f9d4b1a02e97bd69d9d
4
- data.tar.gz: bfb4eb364fcb2f50d43adb610d41c3f1f26cdcd7
3
+ metadata.gz: bce92faeee0147e77ab595311f6a310cb46faf2b
4
+ data.tar.gz: d50fadc1849b52f24202674d7fb817d8cb050113
5
5
  SHA512:
6
- metadata.gz: 0ccde6b34bbdbc63627724aaf06c0ab312fa9e41156e0ee9a0bfd01191c87bc680e9af6178a5aa202eac2ad4a7fc3d5765a69f180ec0ca48b47520ff8f9f05b1
7
- data.tar.gz: 4245e0cb345d9d9358c187a062292a9bae0325457f2347fc43b54749381f9e4b49716f75cb1e8e098e32b1b8dfcbda28de8d8df7beef9c5518230a536bd7c7a1
6
+ metadata.gz: 1d92c872b659df7ce609086c80fcc5bf144684dabe446a4f102441cfed86d554046ccc13650754e4c4fec85f54f8d85a4120bcc98f0beee326245483fb7c518b
7
+ data.tar.gz: c31433a27c31878b0cab832589db762c57fb87524a174577bac399229e6190b0a5e4be506de21ee9bdfc042ee67284a797ece694bcc53847430206e7f529c1f9
data/.gitignore CHANGED
@@ -22,3 +22,4 @@
22
22
  .DS_Store
23
23
  /.rvmrc
24
24
  /.yardoc
25
+ .idea/
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.6.0
2
+
3
+ - Add `persist` option [#15](https://github.com/JustinAiken/active_scheduler/pull/15) (Thanks @SpiffyStores)
4
+ - Remove hardcoded class references [#16](https://github.com/JustinAiken/active_scheduler/pull/16) (Thanks @kensentor)
5
+
1
6
  # 0.5.0
2
7
  - Expand Travis matrix to include Rails 5 and more ruby versions
3
8
  - Allow `rails_env` option since [resque-scheduler](https://github.com/resque/resque-scheduler) does [#10](https://github.com/JustinAiken/active_scheduler/pull/10) (Thanks @blahutka)
data/README.markdown CHANGED
@@ -86,6 +86,8 @@ simple_job:
86
86
  - [@jdguzman](https://github.com/jdguzman)
87
87
  - [@r3trofitted](https://github.com/r3trofitted)
88
88
  - [@blahutka](https://github.com/blahutka)
89
+ - [@SpiffyStores](https://github.com/SpiffyStores)
90
+ - [@kensentor](https://github.com/kensentor)
89
91
 
90
92
  ## License
91
93
 
@@ -23,8 +23,8 @@ module ActiveScheduler
23
23
 
24
24
  schedule.each do |job, opts|
25
25
  class_name = opts[:class] || job
26
- next if class_name =~ /ActiveScheduler::ResqueWrapper/
27
-
26
+ next if class_name =~ /#{self.to_s}/
27
+
28
28
  klass = class_name.constantize
29
29
  next unless klass <= ActiveJob::Base
30
30
 
@@ -40,13 +40,13 @@ module ActiveScheduler
40
40
  end
41
41
 
42
42
  schedule[job] = {
43
- class: 'ActiveScheduler::ResqueWrapper',
43
+ class: self.to_s,
44
44
  queue: queue,
45
45
  args: [{
46
- job_class: class_name,
47
- queue_name: queue,
48
- arguments: args,
49
- }]
46
+ job_class: class_name,
47
+ queue_name: queue,
48
+ arguments: args,
49
+ }]
50
50
  }
51
51
 
52
52
  schedule[job][:args].first.merge!({ named_args: named_args }) if named_args
@@ -55,6 +55,7 @@ module ActiveScheduler
55
55
  schedule[job][:every] = opts.fetch(:every, nil) if opts.fetch(:every, nil)
56
56
  schedule[job][:cron] = opts.fetch(:cron, nil) if opts.fetch(:cron, nil)
57
57
  schedule[job][:rails_env] = opts.fetch(:rails_env, nil) if opts.fetch(:rails_env, nil)
58
+ schedule[job][:persist] = true if opts.fetch(:persist, nil)
58
59
  end
59
60
  end
60
61
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveScheduler
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -37,6 +37,29 @@ describe ActiveScheduler::ResqueWrapper do
37
37
  )
38
38
  end
39
39
  end
40
+
41
+ context 'with a custom wrapper class' do
42
+ class CustomWrapper < ActiveScheduler::ResqueWrapper
43
+ end
44
+
45
+ let(:schedule) { YAML.load_file 'spec/fixtures/simple_job.yaml' }
46
+
47
+ it "queues up a simple job" do
48
+ stub_jobs("SimpleJob")
49
+ expect(CustomWrapper.wrap(schedule)['simple_job']).to eq(
50
+ "class" => "CustomWrapper",
51
+ "queue" => "simple",
52
+ "description" => "It's a simple job.",
53
+ "every" => "30s",
54
+ "rails_env" => "test",
55
+ "args" => [{
56
+ "job_class" => "SimpleJob",
57
+ "queue_name" => "simple",
58
+ "arguments" => ['foo-arg-1', 'foo-arg-2'],
59
+ }]
60
+ )
61
+ end
62
+ end
40
63
  end
41
64
 
42
65
  context "with a simple job json" do
@@ -58,6 +81,27 @@ describe ActiveScheduler::ResqueWrapper do
58
81
  end
59
82
  end
60
83
 
84
+ context "with a persist key" do
85
+ let(:schedule) { YAML.load_file 'spec/fixtures/persist_job.yaml' }
86
+
87
+ it "queues up a simple job" do
88
+ stub_jobs("SimpleJob")
89
+ expect(wrapped['persist_job']).to eq(
90
+ "class" => "ActiveScheduler::ResqueWrapper",
91
+ "queue" => "simple",
92
+ "description" => "It's a simple job. That persists.",
93
+ "every" => "30s",
94
+ "rails_env" => "test",
95
+ "persist" => true,
96
+ "args" => [{
97
+ "job_class" => "SimpleJob",
98
+ "queue_name" => "simple",
99
+ "arguments" => ['foo-arg-1', 'foo-arg-2'],
100
+ }]
101
+ )
102
+ end
103
+ end
104
+
61
105
  context "with a multiple jobs in the schedule" do
62
106
  let(:schedule) { YAML.load_file 'spec/fixtures/two_jobs.yaml' }
63
107
 
@@ -85,9 +129,9 @@ describe ActiveScheduler::ResqueWrapper do
85
129
  simple_job = Class.new(ActiveJob::Base) do
86
130
  queue_as :myscheduledjobqueue
87
131
  end
88
-
132
+
89
133
  stub_const("SimpleJob", simple_job)
90
-
134
+
91
135
  expect(wrapped['no_queue_job']['queue']).to eq 'myscheduledjobqueue'
92
136
  end
93
137
  end
@@ -0,0 +1,10 @@
1
+ persist_job:
2
+ every: "30s"
3
+ queue: "simple"
4
+ class: "SimpleJob"
5
+ rails_env: "test"
6
+ args:
7
+ - foo-arg-1
8
+ - foo-arg-2
9
+ description: "It's a simple job. That persists."
10
+ persist: true
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.5.0
4
+ version: 0.6.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: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -90,6 +90,7 @@ files:
90
90
  - spec/fixtures/cron_job.yaml
91
91
  - spec/fixtures/named_args_job.yaml
92
92
  - spec/fixtures/no_queue.yaml
93
+ - spec/fixtures/persist_job.yaml
93
94
  - spec/fixtures/schedule_name_is_class_name.yaml
94
95
  - spec/fixtures/simple_job.json
95
96
  - spec/fixtures/simple_job.yaml
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  requirements: []
117
118
  rubyforge_project: active_scheduler
118
- rubygems_version: 2.6.6
119
+ rubygems_version: 2.6.14
119
120
  signing_key:
120
121
  specification_version: 4
121
122
  summary: Scheduling for ActiveJob