activejob-dispatch_rider 1.0.1 → 2.2.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
- SHA1:
3
- metadata.gz: 2154aefe422c1bd365aa5539c0981fc5a2376011
4
- data.tar.gz: 0c5b75841bd49d5970c3e38eca1be3644804dd91
2
+ SHA256:
3
+ metadata.gz: 1177fb40b9c1e4225b9e42babbbfd6eb8ca05259d04f3c73f61926eea62b2928
4
+ data.tar.gz: 1dcc9a40be6b705b040974e1a2016713075357a318a1a36d2b167e10944961cb
5
5
  SHA512:
6
- metadata.gz: 3e95b5deb170e20a1cbff1d003cb1aebf92db5d06b6811c343b1e4c389cae6453e3ce393c6dbf4d18209de0ae86c27a1c111bacf3047085c5be8d4cba421af5c
7
- data.tar.gz: 0b101afa949ad24023667a1779b507164d5cb058b908d45cdc7a2fdbf7301f5ab9611499737b07409f7260c34be494d6193a45eb92b177245a53b3fc9d7cad31
6
+ metadata.gz: '081c5ce0e5a21f2c698118fef332d72573cdd739a08863edcc7eb69240c4d07d7cbc0d0bdfe9fc1170a01de06e12cf305cac8737c5a335744a0568bf92729649'
7
+ data.tar.gz: 57242fe4bd83b161dbee694ace25e1edb222541985b61a1784fdff8d17bc0d0cabc6129372d4555a101a7537522022115abcce533823db8d831b2708f9ee4e1c
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
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ addons:
3
+ apt:
4
+ packages:
5
+ - libgmp-dev
6
+ rvm:
7
+ - 2.4.6
8
+ - 2.5.5
9
+ - 2.6.3
10
+ script: "bundle exec rspec"
11
+
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activejob"
22
- spec.add_dependency "dispatch-rider"
21
+ spec.add_dependency "activejob", '~> 5.2.0'
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
- spec.add_development_dependency "codeclimate-test-reporter"
26
+ spec.add_development_dependency "sqlite3"
27
27
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveJob
2
2
  module DispatchRider
3
- VERSION = "1.0.1"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -2,21 +2,17 @@ module ActiveJob
2
2
  module QueueAdapters
3
3
  # Adds support for DispatchRider to ActiveJob.
4
4
  class DispatchRiderAdapter
5
- class << self
6
5
  # @param [ActiveJob::Base] job
7
6
  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
- }
7
+ publisher.publish job_details_for(job)
13
8
  end
14
9
 
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"
10
+ # @param [ActiveJob::Base] job
11
+ # @param [Float] scheduled_at - float representing time (blame AJ)
12
+ def enqueue_at(job, scheduled_at)
13
+ scheduled_job_details = job_details_for(job).merge(scheduled_at: Time.at(scheduled_at))
14
+
15
+ ::DispatchRider::ScheduledJob.create! scheduled_job_details
20
16
  end
21
17
 
22
18
  private
@@ -24,7 +20,16 @@ module ActiveJob
24
20
  def publisher
25
21
  @publisher ||= ::DispatchRider::Publisher.new
26
22
  end
27
- end
23
+
24
+ def job_details_for(job)
25
+ {
26
+ destinations: Array(job.queue_name),
27
+ message: {
28
+ subject: job.class.name.underscore,
29
+ body: job.serialize.merge(guid: job.job_id)
30
+ }
31
+ }
32
+ end
28
33
  end
29
34
  end
30
35
  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
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ require "sqlite3"
3
2
 
4
3
  require "activejob/dispatch_rider"
5
4
 
@@ -109,4 +108,20 @@ RSpec.configure do |config|
109
108
  # as the one that triggered the failure.
110
109
  Kernel.srand config.seed
111
110
  =end
111
+
112
+ config.before(:suite) do
113
+ FileUtils.mkdir_p "tmp"
114
+ FileUtils.rm_f "tmp/lite.db"
115
+ FileUtils.rm_rf "spectmp"
116
+ SQLite3::Database.new "tmp/lite.db"
117
+ ActiveRecord::Base.establish_connection adapter: :sqlite3, database: File.dirname(__FILE__) + "tmp/lite.db"
118
+ ActiveRecord::Schema.define(version: 1) do
119
+ extend DispatchRider::ScheduledJob::Migration
120
+ create_scheduled_jobs_table
121
+ end
122
+ end
123
+
124
+ config.after do
125
+ DispatchRider::ScheduledJob.destroy_all
126
+ end
112
127
  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: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ronald Maravilla
@@ -9,36 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-21 00:00:00.000000000 Z
12
+ date: 2021-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activejob
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: 5.2.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: 5.2.0
28
28
  - !ruby/object:Gem::Dependency
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
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: codeclimate-test-reporter
85
+ name: sqlite3
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
@@ -105,6 +105,7 @@ extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
107
  - ".rspec"
108
+ - ".travis.yml"
108
109
  - Gemfile
109
110
  - README.md
110
111
  - Rakefile
@@ -138,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.2.2
142
+ rubygems_version: 3.0.9
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: "'ActiveJob::DispatchRider' adds `DispatchRider` support for `ActiveJob`."
@@ -148,4 +148,3 @@ test_files:
148
148
  - spec/activejob/queue_adapters/dispatch_rider_adapter_spec.rb
149
149
  - spec/dispatch_rider/registrars/handler_spec.rb
150
150
  - spec/spec_helper.rb
151
- has_rdoc: