delayed_job_shallow_mongoid 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile
CHANGED
@@ -1,14 +1,2 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gem "delayed_job", ">= 2.1.1"
|
4
|
-
gem "mongoid", "~> 2.0"
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem "actionmailer"
|
8
|
-
gem "shoulda", ">= 0"
|
9
|
-
gem "bundler", "~> 1.0.0"
|
10
|
-
gem "jeweler", "~> 1.6.4"
|
11
|
-
gem "rspec"
|
12
|
-
gem "ruby-debug19"
|
13
|
-
gem "bson_ext", "~> 1.5"
|
14
|
-
end
|
2
|
+
gemspec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "delayed_job_shallow_mongoid"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joey Aghion"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-10-27"
|
13
13
|
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."
|
14
14
|
s.email = "joey@aghion.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,39 +35,36 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.homepage = "http://github.com/joeyAghion/delayed_job_shallow_mongoid"
|
36
36
|
s.licenses = ["MIT"]
|
37
37
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = "1.8.
|
38
|
+
s.rubygems_version = "1.8.24"
|
39
39
|
s.summary = "More efficient Mongoid document serialization for delayed_job."
|
40
40
|
|
41
41
|
if s.respond_to? :specification_version then
|
42
42
|
s.specification_version = 3
|
43
43
|
|
44
44
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
-
s.add_runtime_dependency(%q<
|
46
|
-
s.add_runtime_dependency(%q<mongoid>, ["~> 2.0"])
|
45
|
+
s.add_runtime_dependency(%q<delayed_job_shallow_mongoid>, [">= 0"])
|
47
46
|
s.add_development_dependency(%q<actionmailer>, [">= 0"])
|
48
47
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
49
|
-
s.add_development_dependency(%q<bundler>, ["
|
48
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
50
49
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
51
50
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
52
51
|
s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
|
53
52
|
s.add_development_dependency(%q<bson_ext>, ["~> 1.5"])
|
54
53
|
else
|
55
|
-
s.add_dependency(%q<
|
56
|
-
s.add_dependency(%q<mongoid>, ["~> 2.0"])
|
54
|
+
s.add_dependency(%q<delayed_job_shallow_mongoid>, [">= 0"])
|
57
55
|
s.add_dependency(%q<actionmailer>, [">= 0"])
|
58
56
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
59
|
-
s.add_dependency(%q<bundler>, ["
|
57
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
60
58
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
59
|
s.add_dependency(%q<rspec>, [">= 0"])
|
62
60
|
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
63
61
|
s.add_dependency(%q<bson_ext>, ["~> 1.5"])
|
64
62
|
end
|
65
63
|
else
|
66
|
-
s.add_dependency(%q<
|
67
|
-
s.add_dependency(%q<mongoid>, ["~> 2.0"])
|
64
|
+
s.add_dependency(%q<delayed_job_shallow_mongoid>, [">= 0"])
|
68
65
|
s.add_dependency(%q<actionmailer>, [">= 0"])
|
69
66
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
70
|
-
s.add_dependency(%q<bundler>, ["
|
67
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
71
68
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
72
69
|
s.add_dependency(%q<rspec>, [">= 0"])
|
73
70
|
s.add_dependency(%q<ruby-debug19>, [">= 0"])
|
@@ -1,7 +1,13 @@
|
|
1
1
|
module Delayed
|
2
2
|
class PerformableMailer
|
3
3
|
def perform
|
4
|
-
|
4
|
+
begin
|
5
|
+
klass = ShallowMongoid.load(object)
|
6
|
+
delayed_arguments = *args.map{|a| ShallowMongoid.load(a) }
|
7
|
+
rescue Mongoid::Errors::DocumentNotFound
|
8
|
+
return true # do nothing if document has been removed
|
9
|
+
end
|
10
|
+
klass.send(method_name, *delayed_arguments).deliver
|
5
11
|
end
|
6
12
|
end
|
7
13
|
end
|
@@ -9,9 +9,13 @@ module Delayed
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def perform
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
begin
|
13
|
+
klass = ShallowMongoid.load(object)
|
14
|
+
delayed_arguments = *args.map{|a| ShallowMongoid.load(a) }
|
15
|
+
rescue Mongoid::Errors::DocumentNotFound
|
16
|
+
return true # do nothing if document has been removed
|
17
|
+
end
|
18
|
+
klass.send(method_name, *delayed_arguments)
|
15
19
|
end
|
16
20
|
|
17
21
|
def display_name
|
@@ -132,16 +132,39 @@ describe ::Delayed::PerformableMethod do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
describe ::Delayed::PerformableMailer do
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
135
|
+
context "successful mailer" do
|
136
|
+
before do
|
137
|
+
@model = TestModel.create
|
138
|
+
@email = mock('email', :deliver => true)
|
139
|
+
@mailer_class = mock('MailerClass', :signup => @email)
|
140
|
+
@mailer = ::Delayed::PerformableMailer.new(@mailer_class, :signup, [@model])
|
141
|
+
end
|
142
|
+
it "should call the method and #deliver on the mailer" do
|
143
|
+
TestModel.should_receive(:find).with(@model._id.to_s).and_return(@model)
|
144
|
+
@mailer_class.should_receive(:signup).with(@model)
|
145
|
+
@email.should_receive(:deliver)
|
146
|
+
@mailer.perform
|
147
|
+
end
|
148
|
+
it "should do nothing if an argument document is not found" do
|
149
|
+
error = ::Mongoid::Errors::DocumentNotFound.new(TestModel, @model._id)
|
150
|
+
TestModel.should_receive(:find).with(@model._id.to_s).and_raise(error)
|
151
|
+
@mailer.perform.should be_true
|
152
|
+
end
|
140
153
|
end
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
154
|
+
context "failing mailer from bad record" do
|
155
|
+
before do
|
156
|
+
@model = TestModel.create
|
157
|
+
error = ::Mongoid::Errors::DocumentNotFound.new(TestModel, @model._id)
|
158
|
+
@email = mock('email')
|
159
|
+
@email.stub(:deliver).and_raise(error)
|
160
|
+
@mailer_class = mock('MailerClass', :signup => @email)
|
161
|
+
@mailer = ::Delayed::PerformableMailer.new(@mailer_class, :signup, [@model])
|
162
|
+
end
|
163
|
+
it "should fail if an exception comes up" do
|
164
|
+
TestModel.stub(:find).with(@model._id.to_s).and_return(@model)
|
165
|
+
-> {
|
166
|
+
@mailer.perform
|
167
|
+
}.should raise_error(::Mongoid::Errors::DocumentNotFound)
|
168
|
+
end
|
146
169
|
end
|
147
170
|
end
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
15
|
+
name: delayed_job_shallow_mongoid
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: mongoid
|
27
|
-
requirement: &2153406140 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *2153406140
|
29
|
+
version: '0'
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: actionmailer
|
38
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
@@ -43,10 +37,15 @@ dependencies:
|
|
43
37
|
version: '0'
|
44
38
|
type: :development
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
47
|
name: shoulda
|
49
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
50
|
requirements:
|
52
51
|
- - ! '>='
|
@@ -54,21 +53,31 @@ dependencies:
|
|
54
53
|
version: '0'
|
55
54
|
type: :development
|
56
55
|
prerelease: false
|
57
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
58
62
|
- !ruby/object:Gem::Dependency
|
59
63
|
name: bundler
|
60
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
61
65
|
none: false
|
62
66
|
requirements:
|
63
|
-
- -
|
67
|
+
- - ! '>='
|
64
68
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
69
|
+
version: '0'
|
66
70
|
type: :development
|
67
71
|
prerelease: false
|
68
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: jeweler
|
71
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
72
81
|
none: false
|
73
82
|
requirements:
|
74
83
|
- - ~>
|
@@ -76,10 +85,15 @@ dependencies:
|
|
76
85
|
version: 1.6.4
|
77
86
|
type: :development
|
78
87
|
prerelease: false
|
79
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.6.4
|
80
94
|
- !ruby/object:Gem::Dependency
|
81
95
|
name: rspec
|
82
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
83
97
|
none: false
|
84
98
|
requirements:
|
85
99
|
- - ! '>='
|
@@ -87,10 +101,15 @@ dependencies:
|
|
87
101
|
version: '0'
|
88
102
|
type: :development
|
89
103
|
prerelease: false
|
90
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
91
110
|
- !ruby/object:Gem::Dependency
|
92
111
|
name: ruby-debug19
|
93
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
94
113
|
none: false
|
95
114
|
requirements:
|
96
115
|
- - ! '>='
|
@@ -98,10 +117,15 @@ dependencies:
|
|
98
117
|
version: '0'
|
99
118
|
type: :development
|
100
119
|
prerelease: false
|
101
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
102
126
|
- !ruby/object:Gem::Dependency
|
103
127
|
name: bson_ext
|
104
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
105
129
|
none: false
|
106
130
|
requirements:
|
107
131
|
- - ~>
|
@@ -109,7 +133,12 @@ dependencies:
|
|
109
133
|
version: '1.5'
|
110
134
|
type: :development
|
111
135
|
prerelease: false
|
112
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '1.5'
|
113
142
|
description: When the object or arg to a delayed_job is a Mongoid document, store
|
114
143
|
only a small stub of the object instead of the full serialization.
|
115
144
|
email: joey@aghion.com
|
@@ -148,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
177
|
version: '0'
|
149
178
|
segments:
|
150
179
|
- 0
|
151
|
-
hash: -
|
180
|
+
hash: -2014166991515156884
|
152
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
182
|
none: false
|
154
183
|
requirements:
|
@@ -157,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
186
|
version: '0'
|
158
187
|
requirements: []
|
159
188
|
rubyforge_project:
|
160
|
-
rubygems_version: 1.8.
|
189
|
+
rubygems_version: 1.8.24
|
161
190
|
signing_key:
|
162
191
|
specification_version: 3
|
163
192
|
summary: More efficient Mongoid document serialization for delayed_job.
|