delayed_job_shallow_mongoid 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 +4 -4
- data/.travis.yml +3 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +6 -4
- data/LICENSE.txt +1 -1
- data/README.md +5 -3
- data/Rakefile +7 -4
- data/delayed_job_shallow_mongoid.gemspec +27 -27
- data/lib/delayed/shallow_mongoid.rb +3 -4
- data/lib/delayed/shallow_mongoid/document_stub.rb +3 -3
- data/lib/delayed/shallow_mongoid/mongoid.rb +1 -1
- data/lib/delayed/shallow_mongoid/performable_mailer.rb +2 -2
- data/lib/delayed/shallow_mongoid/performable_method.rb +4 -4
- data/lib/delayed/shallow_mongoid/version.rb +1 -1
- metadata +38 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 241496eebc696681823dccc7e8c86b31a821a470
|
4
|
+
data.tar.gz: 6a3694a48a1c5f94e00e904678ad2290001b9917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e3d4c20ede088bcdfb6737d74b016da324aece575250254c7d3a6a6a36d6deacc5a2ed4f6b48bc3710fb67fb58a942acf4cf52f2af782da3212ec313315bbcb
|
7
|
+
data.tar.gz: 8ca08d593b35d303a86049f7c2cd2024f692ba5931df58e511a11380747d34f035e67571ef3b0720f0784ab232923087b91ab3e38077e7ed722fb87e5b18a9e5
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
1.1.0 (2015-09-25)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* [#11](https://github.com/joeyAghion/delayed_job_shallow_mongoid/pull/11): Support Mongoid 5 - [@dblock](http://github.com/dblock).
|
5
|
+
* [#10](https://github.com/joeyAghion/delayed_job_shallow_mongoid/pull/10): Added Rubocop, Ruby style linter - [@dblock](http://github.com/dblock).
|
6
|
+
|
1
7
|
1.0.1 (2014-07-02)
|
2
8
|
------------------
|
3
9
|
|
data/Gemfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
case version = ENV['MONGOID_VERSION'] || '
|
6
|
-
when /
|
5
|
+
case version = ENV['MONGOID_VERSION'] || '5.0'
|
6
|
+
when /^5/
|
7
7
|
gem 'mongoid', '~> 4.0'
|
8
|
-
when /
|
8
|
+
when /^4/
|
9
|
+
gem 'mongoid', '~> 4.0'
|
10
|
+
when /^3/
|
9
11
|
gem 'mongoid', '~> 3.1'
|
10
12
|
else
|
11
13
|
gem 'mongoid', version
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -5,15 +5,17 @@ delayed_job_shallow_mongoid
|
|
5
5
|
|
6
6
|
This library short-circuits serialization of [Mongoid](http://mongoid.org) model instances when a delayed job is called on them, or when they're passed as arguments to a delayed job. Rather than generate and store the fully-serialized YAML, a simple stub is stored. When the job is run, the stub is recognized and a `find` is done to look up the underlying document. If a referenced model isn't found at this point, the job simply does nothing.
|
7
7
|
|
8
|
-
|
8
|
+
This gem supports Mongoid 3.x, 4.x and 5.x.
|
9
9
|
|
10
10
|
Contributions
|
11
11
|
-------------
|
12
12
|
|
13
13
|
* Contributions encouraged. Feature branches appreciated.
|
14
|
-
* Development generously supported by [
|
14
|
+
* Development generously supported by [Artsy](http://artsy.net).
|
15
15
|
|
16
16
|
Copyright
|
17
17
|
---------
|
18
18
|
|
19
|
-
Copyright (c) 2011 Joey Aghion,
|
19
|
+
Copyright (c) 2011-2015 Joey Aghion, Artsy Inc.
|
20
|
+
|
21
|
+
MIT License. See [LICENSE](LICENSE.txt) for further details.
|
data/Rakefile
CHANGED
@@ -7,15 +7,18 @@ begin
|
|
7
7
|
Bundler.setup(:default, :development)
|
8
8
|
rescue Bundler::BundlerError => e
|
9
9
|
$stderr.puts e.message
|
10
|
-
$stderr.puts
|
10
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
11
11
|
exit e.status_code
|
12
12
|
end
|
13
13
|
require 'rake'
|
14
14
|
require 'rspec/core/rake_task'
|
15
15
|
|
16
|
-
desc
|
16
|
+
desc 'Run all tests'
|
17
17
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
18
|
-
spec.pattern =
|
18
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
require 'rubocop/rake_task'
|
22
|
+
RuboCop::RakeTask.new(:rubocop)
|
23
|
+
|
24
|
+
task default: [:rubocop, :spec]
|
@@ -5,40 +5,40 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'delayed/shallow_mongoid/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name =
|
8
|
+
s.name = 'delayed_job_shallow_mongoid'
|
9
9
|
s.version = Delayed::ShallowMongoid::VERSION
|
10
10
|
|
11
|
-
s.authors = [
|
12
|
-
s.description =
|
13
|
-
s.email =
|
11
|
+
s.authors = ['Joey Aghion', 'Daniel Doubrovkine']
|
12
|
+
s.description = 'When the object or arg to a delayed_job is a Mongoid document, store only a small stub of the object instead of the full serialization.'
|
13
|
+
s.email = 'joey@aghion.com'
|
14
14
|
s.extra_rdoc_files = [
|
15
|
-
|
16
|
-
|
15
|
+
'LICENSE.txt',
|
16
|
+
'README.md'
|
17
17
|
]
|
18
18
|
s.files = Dir[
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
'.document',
|
20
|
+
'.travis.yml',
|
21
|
+
'CHANGELOG.md',
|
22
|
+
'Gemfile',
|
23
|
+
'LICENSE.txt',
|
24
|
+
'README.md',
|
25
|
+
'Rakefile',
|
26
|
+
'delayed_job_shallow_mongoid.gemspec',
|
27
27
|
'lib/**/*'
|
28
28
|
]
|
29
|
-
s.homepage =
|
30
|
-
s.licenses = [
|
31
|
-
s.require_paths = [
|
32
|
-
s.summary =
|
29
|
+
s.homepage = 'http://github.com/joeyAghion/delayed_job_shallow_mongoid'
|
30
|
+
s.licenses = ['MIT']
|
31
|
+
s.require_paths = ['lib']
|
32
|
+
s.summary = 'More efficient Mongoid document serialization for delayed_job.'
|
33
33
|
|
34
34
|
s.specification_version = 3
|
35
|
-
s.add_runtime_dependency(
|
36
|
-
s.add_runtime_dependency(
|
37
|
-
s.add_runtime_dependency(
|
38
|
-
s.add_runtime_dependency(
|
39
|
-
s.add_development_dependency(
|
40
|
-
s.add_development_dependency(
|
41
|
-
s.add_development_dependency(
|
42
|
-
s.add_development_dependency(
|
35
|
+
s.add_runtime_dependency('delayed_job', ['>= 3.0'])
|
36
|
+
s.add_runtime_dependency('delayed_job_mongoid', ['>= 2.0'])
|
37
|
+
s.add_runtime_dependency('mongoid', ['>= 3.0'])
|
38
|
+
s.add_runtime_dependency('activesupport', ['>= 3.2'])
|
39
|
+
s.add_development_dependency('actionmailer', ['>= 0'])
|
40
|
+
s.add_development_dependency('shoulda', ['>= 0'])
|
41
|
+
s.add_development_dependency('rake', ['~> 10.0'])
|
42
|
+
s.add_development_dependency('rspec', ['>= 3.0'])
|
43
|
+
s.add_development_dependency('rubocop', ['0.34.2'])
|
43
44
|
end
|
44
|
-
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Delayed
|
2
2
|
module ShallowMongoid
|
3
|
-
|
4
3
|
module Errors
|
5
4
|
class DocumentNotFound < StandardError
|
6
5
|
end
|
@@ -20,14 +19,14 @@ module Delayed
|
|
20
19
|
return arg unless arg.is_a?(Delayed::ShallowMongoid::DocumentStub)
|
21
20
|
begin
|
22
21
|
result = arg.klass.find(arg.id)
|
23
|
-
|
22
|
+
fail Delayed::ShallowMongoid::Errors::DocumentNotFound unless result
|
24
23
|
rescue Mongoid::Errors::DocumentNotFound
|
25
24
|
raise Delayed::ShallowMongoid::Errors::DocumentNotFound
|
26
25
|
end
|
27
26
|
(arg.selector || []).each do |message|
|
28
27
|
result = result.send(*message)
|
29
28
|
end
|
30
|
-
|
29
|
+
fail Delayed::ShallowMongoid::Errors::DocumentNotFound unless result
|
31
30
|
result
|
32
31
|
end
|
33
32
|
|
@@ -35,7 +34,7 @@ module Delayed
|
|
35
34
|
# E.g., ['images', ['find', '4eef..678'], 'width']
|
36
35
|
def self.selector_from(doc)
|
37
36
|
[].tap do |selector|
|
38
|
-
while doc._parent
|
37
|
+
while doc._parent
|
39
38
|
selector.unshift ['find', doc._id.to_s] if Delayed::ShallowMongoid.metadata(doc).macro == :embeds_many
|
40
39
|
selector.unshift Delayed::ShallowMongoid.metadata(doc).key
|
41
40
|
doc = doc._parent
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Delayed
|
2
2
|
module ShallowMongoid
|
3
|
-
|
3
|
+
DocumentStub = Struct.new(:klass, :id, :selector) do
|
4
4
|
def description
|
5
5
|
"#{klass}[#{id}]".tap do |desc|
|
6
|
-
desc <<
|
6
|
+
desc << '.' + selector.map do |s|
|
7
7
|
s.is_a?(Array) ? "#{s.first}(#{s[1..-1].map(&:inspect).join(', ')})" : s
|
8
|
-
|
8
|
+
end.join('.') if selector && selector.any?
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -2,10 +2,10 @@ module Delayed
|
|
2
2
|
class PerformableMailer < PerformableMethod
|
3
3
|
def perform
|
4
4
|
klass = ShallowMongoid.load(object)
|
5
|
-
delayed_arguments = *args.map{|a| ShallowMongoid.load(a) }
|
5
|
+
delayed_arguments = *args.map { |a| ShallowMongoid.load(a) }
|
6
6
|
klass.send(method_name, *delayed_arguments).deliver
|
7
7
|
rescue Delayed::ShallowMongoid::Errors::DocumentNotFound
|
8
|
-
return true
|
8
|
+
return true # do nothing if document has been removed
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -3,19 +3,19 @@ module Delayed
|
|
3
3
|
attr_accessor :object, :method_name, :args
|
4
4
|
|
5
5
|
def initialize(object, method_name, args)
|
6
|
-
|
6
|
+
fail NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true)
|
7
7
|
|
8
8
|
self.object = ShallowMongoid.dump(object)
|
9
|
-
self.args = args.map{|a| ShallowMongoid.dump(a) }
|
9
|
+
self.args = args.map { |a| ShallowMongoid.dump(a) }
|
10
10
|
self.method_name = method_name.to_sym
|
11
11
|
end
|
12
12
|
|
13
13
|
def perform
|
14
14
|
klass = ShallowMongoid.load(object)
|
15
|
-
delayed_arguments = *args.map{|a| ShallowMongoid.load(a) }
|
15
|
+
delayed_arguments = *args.map { |a| ShallowMongoid.load(a) }
|
16
16
|
klass.send(method_name, *delayed_arguments)
|
17
17
|
rescue Delayed::ShallowMongoid::Errors::DocumentNotFound
|
18
|
-
return true
|
18
|
+
return true # do nothing if document has been removed
|
19
19
|
end
|
20
20
|
|
21
21
|
def display_name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_job_shallow_mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joey Aghion
|
@@ -9,120 +9,134 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: delayed_job
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.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
27
|
version: '3.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: delayed_job_mongoid
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2.0'
|
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
41
|
version: '2.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mongoid
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '3.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: activesupport
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '3.2'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3.2'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: actionmailer
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: shoulda
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: rake
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - ~>
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '10.0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - ~>
|
109
|
+
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '10.0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: rspec
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '3.0'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '3.0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 0.34.2
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.34.2
|
126
140
|
description: When the object or arg to a delayed_job is a Mongoid document, store
|
127
141
|
only a small stub of the object instead of the full serialization.
|
128
142
|
email: joey@aghion.com
|
@@ -132,20 +146,20 @@ extra_rdoc_files:
|
|
132
146
|
- LICENSE.txt
|
133
147
|
- README.md
|
134
148
|
files:
|
135
|
-
- .document
|
136
|
-
- .travis.yml
|
149
|
+
- ".document"
|
150
|
+
- ".travis.yml"
|
137
151
|
- CHANGELOG.md
|
138
152
|
- Gemfile
|
139
153
|
- LICENSE.txt
|
140
154
|
- README.md
|
141
155
|
- Rakefile
|
142
156
|
- delayed_job_shallow_mongoid.gemspec
|
157
|
+
- lib/delayed/shallow_mongoid.rb
|
143
158
|
- lib/delayed/shallow_mongoid/document_stub.rb
|
144
159
|
- lib/delayed/shallow_mongoid/mongoid.rb
|
145
160
|
- lib/delayed/shallow_mongoid/performable_mailer.rb
|
146
161
|
- lib/delayed/shallow_mongoid/performable_method.rb
|
147
162
|
- lib/delayed/shallow_mongoid/version.rb
|
148
|
-
- lib/delayed/shallow_mongoid.rb
|
149
163
|
- lib/delayed_job_shallow_mongoid.rb
|
150
164
|
homepage: http://github.com/joeyAghion/delayed_job_shallow_mongoid
|
151
165
|
licenses:
|
@@ -157,17 +171,17 @@ require_paths:
|
|
157
171
|
- lib
|
158
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
159
173
|
requirements:
|
160
|
-
- -
|
174
|
+
- - ">="
|
161
175
|
- !ruby/object:Gem::Version
|
162
176
|
version: '0'
|
163
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
178
|
requirements:
|
165
|
-
- -
|
179
|
+
- - ">="
|
166
180
|
- !ruby/object:Gem::Version
|
167
181
|
version: '0'
|
168
182
|
requirements: []
|
169
183
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.2.2
|
171
185
|
signing_key:
|
172
186
|
specification_version: 3
|
173
187
|
summary: More efficient Mongoid document serialization for delayed_job.
|