activejob-dispatch_rider 1.0.1 → 1.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: 2154aefe422c1bd365aa5539c0981fc5a2376011
4
- data.tar.gz: 0c5b75841bd49d5970c3e38eca1be3644804dd91
3
+ metadata.gz: b3f8d36d44530716ef40fe1d3092a0eebf3600be
4
+ data.tar.gz: ae45ba60ab64e01f6b30a82dd920512b1cdcc3f8
5
5
  SHA512:
6
- metadata.gz: 3e95b5deb170e20a1cbff1d003cb1aebf92db5d06b6811c343b1e4c389cae6453e3ce393c6dbf4d18209de0ae86c27a1c111bacf3047085c5be8d4cba421af5c
7
- data.tar.gz: 0b101afa949ad24023667a1779b507164d5cb058b908d45cdc7a2fdbf7301f5ab9611499737b07409f7260c34be494d6193a45eb92b177245a53b3fc9d7cad31
6
+ metadata.gz: 8d2de58525640a3b8b05877d3b59daadd16f8dccb11e851e0b4ca30608ef8b8a0782edb458218dabd0b946b5db4fef532f5d4d0e9546eee100053c7c4a16d2a8
7
+ data.tar.gz: e621c9f7d434b1b10c50518d65be70b231155b38b075456ebf1c46ac586500216c19c459f97a6e4ed586f8fd9440480386a4dba69a8e5ea571e81bc1ebf88319
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ spectmp
10
11
  *.bundle
11
12
  *.so
12
13
  *.o
@@ -19,9 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "activejob"
22
- spec.add_dependency "dispatch-rider"
22
+ spec.add_dependency "dispatch-rider", "~> 1.7"
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec"
26
26
  spec.add_development_dependency "codeclimate-test-reporter"
27
+ spec.add_development_dependency "sqlite3"
27
28
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveJob
2
2
  module DispatchRider
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -5,18 +5,15 @@ module ActiveJob
5
5
  class << self
6
6
  # @param [ActiveJob::Base] job
7
7
  def enqueue(job)
8
- publisher.publish destinations: Array(job.queue_name),
9
- message: {
10
- subject: job.class.name.underscore,
11
- body: job.serialize.merge(guid: job.job_id)
12
- }
8
+ publisher.publish job_details_for(job)
13
9
  end
14
10
 
15
- def enqueue_at(*)
16
- raise NotImplementedError,
17
- "This queueing backend does not support scheduling jobs. To "\
18
- "see what features are supported go to "\
19
- "http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html"
11
+ # @param [ActiveJob::Base] job
12
+ # @param [Float] scheduled_at - float representing time (blame AJ)
13
+ def enqueue_at(job, scheduled_at)
14
+ scheduled_job_details = job_details_for(job).merge(scheduled_at: Time.at(scheduled_at))
15
+
16
+ ::DispatchRider::ScheduledJob.create! scheduled_job_details
20
17
  end
21
18
 
22
19
  private
@@ -24,6 +21,16 @@ module ActiveJob
24
21
  def publisher
25
22
  @publisher ||= ::DispatchRider::Publisher.new
26
23
  end
24
+
25
+ def job_details_for(job)
26
+ {
27
+ destinations: Array(job.queue_name),
28
+ message: {
29
+ subject: job.class.name.underscore,
30
+ body: job.serialize.merge(guid: job.job_id)
31
+ }
32
+ }
33
+ end
27
34
  end
28
35
  end
29
36
  end
@@ -65,10 +65,15 @@ describe ActiveJob::QueueAdapters::DispatchRiderAdapter do
65
65
  end
66
66
 
67
67
  describe ".enqueue_at" do
68
- let(:job) { double :job }
69
- let(:timestamp) { Time.now }
68
+ let(:tomorrow_midnight) { Date.tomorrow.midnight }
70
69
 
71
- example { expect { adapter.enqueue_at job, timestamp }.to raise_error NotImplementedError }
70
+ example {
71
+ expect {
72
+ foo_job_class.set(wait_until: tomorrow_midnight).perform_later foo: "bar"
73
+ }.to change(DispatchRider::ScheduledJob, :count).by 1
74
+
75
+ expect(DispatchRider::ScheduledJob.last.scheduled_at).to eq tomorrow_midnight
76
+ }
72
77
  end
73
78
  end
74
79
  end
@@ -1,4 +1,6 @@
1
1
  require "codeclimate-test-reporter"
2
+ require "sqlite3"
3
+
2
4
  CodeClimate::TestReporter.start
3
5
 
4
6
  require "activejob/dispatch_rider"
@@ -109,4 +111,20 @@ RSpec.configure do |config|
109
111
  # as the one that triggered the failure.
110
112
  Kernel.srand config.seed
111
113
  =end
114
+
115
+ config.before(:suite) do
116
+ FileUtils.mkdir_p "tmp"
117
+ FileUtils.rm_f "tmp/lite.db"
118
+ FileUtils.rm_rf "spectmp"
119
+ SQLite3::Database.new "tmp/lite.db"
120
+ ActiveRecord::Base.establish_connection adapter: :sqlite3, database: File.dirname(__FILE__) + "tmp/lite.db"
121
+ ActiveRecord::Schema.define(version: 1) do
122
+ extend DispatchRider::ScheduledJob::Migration
123
+ create_scheduled_jobs_table
124
+ end
125
+ end
126
+
127
+ config.after do
128
+ DispatchRider::ScheduledJob.destroy_all
129
+ end
112
130
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob-dispatch_rider
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronald Maravilla
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-21 00:00:00.000000000 Z
12
+ date: 2015-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activejob
@@ -29,16 +29,16 @@ dependencies:
29
29
  name: dispatch-rider
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '1.7'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '1.7'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: sqlite3
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
98
112
  description: "'ActiveJob::DispatchRider' adds `DispatchRider` support for `ActiveJob`."
99
113
  email:
100
114
  - more.ron.too@gmail.com
@@ -148,4 +162,3 @@ test_files:
148
162
  - spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb
149
163
  - spec/dispatch_rider/registrars/handler_spec.rb
150
164
  - spec/spec_helper.rb
151
- has_rdoc: