talentbox-delayed_job_sequel 4.0.1 → 4.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: d45ac6c7bc184fb66e341cc59236553f1115e6e3
4
- data.tar.gz: 970a765aa1627ffe051f5daeb691ebe67f49dd96
3
+ metadata.gz: 1e533fcbcda3ce78b2c6bad187b62a19e085103b
4
+ data.tar.gz: 2c40fdc180963165fcc84ea81b3d3c46fc761feb
5
5
  SHA512:
6
- metadata.gz: 510bb5253ca7c083cdd0106c58f4ded8fc402b7621e9e99d90f33b283937d788cdab16e75bb24eba4aea107fc9e7644b7a84a29454671ca59c52d2974d707de9
7
- data.tar.gz: 85e338fcc518bd581abca679b5b8a0eec6e643121aa71eace78b6e81a3818ea0d08f2cd1b88550a884319a8a87875c576ff783f186b373f4b0f3895b0b8129d4
6
+ metadata.gz: f8ab43e1ceca96e0405cfdbfeab609bc377ac1918081183298fbebfa01e5475ddf1c46b2b6adad2f6d0affafbc090d7d0a282d146661ab49505d998e1822fb70
7
+ data.tar.gz: e6a47703436a779ba61d764080c6c28a8515da332452845cc5c5cfc81c810859543579c3244c35af847f58be13deb2b22814d3c13747139398e317ed887b9a2c
data/README.md CHANGED
@@ -17,6 +17,14 @@ Add the gem to your Gemfile:
17
17
 
18
18
  Run `bundle install`.
19
19
 
20
+ Create an initializer to setup the DelayedJob backend:
21
+
22
+ ```ruby
23
+ # config/initializers/delayed_job.rb
24
+
25
+ ::Delayed::Job.backend = :sequel
26
+ ```
27
+
20
28
  Create the table (using the sequel migration syntax):
21
29
 
22
30
  create_table :delayed_jobs do
@@ -4,7 +4,7 @@ module Delayed
4
4
  module Sequel
5
5
  # A job object that is persisted to the database.
6
6
  # Contains the work object as a YAML field.
7
- class Job < ::Sequel::Model(:delayed_jobs)
7
+ class Job < ::Sequel::Model(::DelayedJobSequel.table_name)
8
8
  include Delayed::Backend::Base
9
9
  plugin :timestamps
10
10
 
@@ -105,7 +105,7 @@ module Delayed
105
105
  if attrs.has_key?(:group)
106
106
  column = attrs[:group]
107
107
  group_and_count(column.to_sym).map do |record|
108
- [column, record[:count]]
108
+ [record[column.to_sym], record[:count]]
109
109
  end
110
110
  else
111
111
  ds.count
@@ -1,6 +1,12 @@
1
1
  require 'sequel'
2
2
  require 'delayed_job'
3
- require 'delayed/backend/sequel'
4
- require 'delayed/serialization/sequel'
5
3
 
6
- Delayed::Worker.backend = :sequel
4
+ module DelayedJobSequel
5
+ def self.table_name=(table_name)
6
+ @table_name = table_name
7
+ end
8
+
9
+ def self.table_name
10
+ @table_name || :delayed_jobs
11
+ end
12
+ end
@@ -1,8 +1,12 @@
1
1
  require "spec_helper"
2
- require "delayed/backend/sequel"
3
2
 
4
3
  describe Delayed::Backend::Sequel::Job do
4
+ before do
5
+ SimpleJob.runs = 0
6
+ described_class.delete_all
7
+ end
5
8
  after do
9
+ Delayed::Worker.reset
6
10
  Time.zone = nil
7
11
  end
8
12
 
@@ -29,16 +33,19 @@ describe Delayed::Backend::Sequel::Job do
29
33
  context ".count" do
30
34
  context "NewRelic sampler compat" do
31
35
  it "allow count with conditions" do
36
+ described_class.create(failed_at: Time.now)
32
37
  expect do
33
- Delayed::Job.count(:conditions => "failed_at is not NULL").should == 1
34
- Delayed::Job.count(:conditions => "locked_by is not NULL").should == 0
38
+ Delayed::Job.count(:conditions => "failed_at is not NULL").should eq 1
39
+ Delayed::Job.count(:conditions => "locked_by is not NULL").should eq 0
35
40
  end.to_not raise_error
36
41
  end
37
42
 
38
43
  it "allow count with group and conditions" do
44
+ described_class.create(queue: "slow", priority: 2)
45
+ described_class.create(queue: "important", priority: 1)
39
46
  expect do
40
- Delayed::Job.count(:group => "queue", :conditions => ['run_at < ? and failed_at is NULL', Time.now]).should =~ [["queue", 1]]
41
- Delayed::Job.count(:group => "priority", :conditions => ['run_at < ? and failed_at is NULL', Time.now]).should =~ [["priority", 1]]
47
+ Delayed::Job.count(:group => "queue", :conditions => ['run_at < ? and failed_at is NULL', Time.now]).should =~ [["slow", 1], ["important", 1]]
48
+ Delayed::Job.count(:group => "priority", :conditions => ['run_at < ? and failed_at is NULL', Time.now]).should =~ [[1, 1], [2, 1]]
42
49
  end.to_not raise_error
43
50
  end
44
51
  end
@@ -77,4 +84,41 @@ describe Delayed::Backend::Sequel::Job do
77
84
  Delayed::Backend::Sequel::Job[job.id].run_at.should be_within(1).of(later)
78
85
  end
79
86
  end
87
+
88
+ it "allows to override the table name" do
89
+ ::Sequel::Model.db.transaction :rollback => :always do
90
+ begin
91
+ DB.create_table :another_delayed_jobs do
92
+ primary_key :id
93
+ Integer :priority, :default => 0
94
+ Integer :attempts, :default => 0
95
+ String :handler, :text => true
96
+ String :last_error, :text => true
97
+ Time :run_at
98
+ Time :locked_at
99
+ Time :failed_at
100
+ String :locked_by
101
+ String :queue
102
+ Time :created_at
103
+ Time :updated_at
104
+ index [:priority, :run_at]
105
+ end
106
+ change_table_name :another_delayed_jobs
107
+
108
+ Delayed::Job.table_name.should == :another_delayed_jobs
109
+ ensure
110
+ change_table_name nil
111
+ end
112
+ end
113
+ end
114
+
115
+ def change_table_name(name)
116
+ ::DelayedJobSequel.table_name = name
117
+ ::Delayed::Backend::Sequel.send :remove_const, :Job
118
+ load File.expand_path(
119
+ "../../../../lib/delayed/backend/sequel.rb",
120
+ __FILE__
121
+ )
122
+ ::Delayed::Worker.backend = :sequel
123
+ end
80
124
  end
@@ -64,6 +64,8 @@ require "delayed/backend/shared_spec"
64
64
  Delayed::Worker.logger = Logger.new(ENV["DEBUG"] ? $stdout : "/tmp/dj.log")
65
65
  DB.logger = Delayed::Worker.logger
66
66
 
67
+ Delayed::Worker.backend = :sequel
68
+
67
69
  # Purely useful for test cases...
68
70
  class Story < Sequel::Model
69
71
  def tell; text; end
@@ -72,4 +74,5 @@ class Story < Sequel::Model
72
74
  update *args
73
75
  end
74
76
  handle_asynchronously :whatever
77
+ alias_method :persisted?, :exists?
75
78
  end
metadata CHANGED
@@ -1,91 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talentbox-delayed_job_sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Tron
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.38'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5.0'
23
- requirement: !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
24
26
  requirements:
25
- - - '>='
27
+ - - ">="
26
28
  - !ruby/object:Gem::Version
27
29
  version: '3.38'
28
- - - <
30
+ - - "<"
29
31
  - !ruby/object:Gem::Version
30
32
  version: '5.0'
31
- prerelease: false
32
- type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: delayed_job
35
- version_requirements: !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: 4.0.0
40
- requirement: !ruby/object:Gem::Requirement
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
41
43
  requirements:
42
- - - ~>
44
+ - - "~>"
43
45
  - !ruby/object:Gem::Version
44
46
  version: 4.0.0
45
- prerelease: false
46
- type: :runtime
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: tzinfo
49
- version_requirements: !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
- requirement: !ruby/object:Gem::Requirement
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
55
57
  requirements:
56
- - - '>='
58
+ - - ">="
57
59
  - !ruby/object:Gem::Version
58
60
  version: '0'
59
- prerelease: false
60
- type: :runtime
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
- version_requirements: !ruby/object:Gem::Requirement
63
+ requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '2.13'
68
- requirement: !ruby/object:Gem::Requirement
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
69
71
  requirements:
70
- - - ~>
72
+ - - "~>"
71
73
  - !ruby/object:Gem::Version
72
74
  version: '2.13'
73
- prerelease: false
74
- type: :development
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
- version_requirements: !ruby/object:Gem::Requirement
77
+ requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
- requirement: !ruby/object:Gem::Requirement
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
83
85
  requirements:
84
- - - '>='
86
+ - - ">="
85
87
  - !ruby/object:Gem::Version
86
88
  version: '0'
87
- prerelease: false
88
- type: :development
89
89
  description: Sequel backend for DelayedJob, originally authored by Tobias Luetke
90
90
  email:
91
91
  - jonathan@tron.name
@@ -94,44 +94,44 @@ extensions: []
94
94
  extra_rdoc_files:
95
95
  - README.md
96
96
  files:
97
- - lib/delayed_job_sequel.rb
97
+ - LICENSE
98
+ - README.md
98
99
  - lib/delayed/backend/sequel.rb
99
100
  - lib/delayed/serialization/sequel.rb
101
+ - lib/delayed_job_sequel.rb
100
102
  - lib/generators/delayed_job/sequel_generator.rb
101
103
  - lib/generators/delayed_job/templates/migration.rb
102
- - spec/spec_helper.rb
103
104
  - spec/delayed/backend/sequel_spec.rb
104
105
  - spec/delayed/serialization/sequel_spec.rb
105
- - LICENSE
106
- - README.md
106
+ - spec/spec_helper.rb
107
107
  homepage: http://github.com/TalentBox/delayed_job_sequel
108
108
  licenses: []
109
109
  metadata: {}
110
- post_install_message:
110
+ post_install_message:
111
111
  rdoc_options:
112
- - --main
112
+ - "--main"
113
113
  - README.md
114
- - --inline-source
115
- - --line-numbers
114
+ - "--inline-source"
115
+ - "--line-numbers"
116
116
  require_paths:
117
117
  - lib
118
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - '>='
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.1.9
131
- signing_key:
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.5
131
+ signing_key:
132
132
  specification_version: 4
133
133
  summary: Sequel backend for DelayedJob
134
134
  test_files:
135
- - spec/spec_helper.rb
136
135
  - spec/delayed/backend/sequel_spec.rb
137
136
  - spec/delayed/serialization/sequel_spec.rb
137
+ - spec/spec_helper.rb