redis_cache_mailer_delivery 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/lib/redis_cache_mailer_delivery.rb +1 -1
- data/lib/redis_cache_mailer_delivery/deliveries.rb +19 -0
- data/lib/redis_cache_mailer_delivery/version.rb +1 -1
- data/spec/redis_cache_mailer_delivery/deliveries_spec.rb +30 -0
- metadata +118 -77
- data/lib/redis_cache_mailer_delivery/action_mailer/base.rb +0 -26
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm
|
1
|
+
rvm ree@redis_cache_mailer_delivery
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'action_mailer'
|
2
2
|
require 'redis_cache_mailer_delivery/version'
|
3
3
|
require 'redis_cache_mailer_delivery/mail/cache_delivery'
|
4
|
-
require 'redis_cache_mailer_delivery/
|
4
|
+
require 'redis_cache_mailer_delivery/deliveries'
|
5
5
|
|
6
6
|
module RedisCacheMailerDelivery
|
7
7
|
class << self
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'redis'
|
2
|
+
require 'redis/objects'
|
3
|
+
require 'redis/list'
|
4
|
+
module RedisCacheMailerDelivery
|
5
|
+
module Deliveries
|
6
|
+
class << self
|
7
|
+
|
8
|
+
#
|
9
|
+
# Returns an array of delivered mails.
|
10
|
+
#
|
11
|
+
# @return [Array] array of mails (each mail is an instance of Mail.)
|
12
|
+
#
|
13
|
+
def all
|
14
|
+
list = Redis::List.new ActionMailer::Base.redis_cache_settings[:redis_key_name], :marshal => true
|
15
|
+
list.values
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
|
2
|
+
|
3
|
+
module RedisCacheMailerDelivery
|
4
|
+
describe Deliveries do
|
5
|
+
before(:each) do
|
6
|
+
RedisCacheMailerDelivery.install
|
7
|
+
Redis.current = Redis.new(:host => '127.0.0.1', :port => 6379)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".all" do
|
11
|
+
let(:object) { Mail::Message.new}
|
12
|
+
before(:each) do
|
13
|
+
list = Redis::List.new "redis_cache_mailer_delivery:mail_messages", :marshal => true
|
14
|
+
list << object
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:each) do
|
18
|
+
Redis.current.del "redis_cache_mailer_delivery:mail_messages"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "fetches all contents from redis" do
|
22
|
+
described_class.all.size.should eq(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "deserizlize the data" do
|
26
|
+
described_class.all[0].should eq(object)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,100 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_cache_mailer_delivery
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Yi Wen
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-03-21 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: redis
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
22
32
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
26
35
|
name: redis-objects
|
27
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
38
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
33
46
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
37
49
|
name: actionmailer
|
38
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
52
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
44
60
|
type: :runtime
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
66
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
55
74
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
59
77
|
name: guard-rspectacle
|
60
|
-
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
80
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
66
88
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
89
|
+
version_requirements: *id005
|
90
|
+
- !ruby/object:Gem::Dependency
|
70
91
|
name: growl
|
71
|
-
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
72
94
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
77
102
|
type: :development
|
78
|
-
|
79
|
-
|
80
|
-
- !ruby/object:Gem::Dependency
|
103
|
+
version_requirements: *id006
|
104
|
+
- !ruby/object:Gem::Dependency
|
81
105
|
name: rb-fsevent
|
82
|
-
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
83
108
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
88
116
|
type: :development
|
89
|
-
|
90
|
-
version_requirements: *70203010830820
|
117
|
+
version_requirements: *id007
|
91
118
|
description: Use Redis to store the Mail::Message when using in Rails
|
92
|
-
email:
|
119
|
+
email:
|
93
120
|
- hayafirst@gmail.com
|
94
121
|
executables: []
|
122
|
+
|
95
123
|
extensions: []
|
124
|
+
|
96
125
|
extra_rdoc_files: []
|
97
|
-
|
126
|
+
|
127
|
+
files:
|
98
128
|
- .gitignore
|
99
129
|
- .rspec
|
100
130
|
- .rvmrc
|
@@ -104,39 +134,50 @@ files:
|
|
104
134
|
- README.md
|
105
135
|
- Rakefile
|
106
136
|
- lib/redis_cache_mailer_delivery.rb
|
107
|
-
- lib/redis_cache_mailer_delivery/
|
137
|
+
- lib/redis_cache_mailer_delivery/deliveries.rb
|
108
138
|
- lib/redis_cache_mailer_delivery/mail/cache_delivery.rb
|
109
139
|
- lib/redis_cache_mailer_delivery/railtie.rb
|
110
140
|
- lib/redis_cache_mailer_delivery/version.rb
|
111
141
|
- redis_cache_mailer_delivery.gemspec
|
142
|
+
- spec/redis_cache_mailer_delivery/deliveries_spec.rb
|
112
143
|
- spec/redis_cache_mailer_delivery_spec.rb
|
113
144
|
- spec/spec_helper.rb
|
114
145
|
- spec/support/faked_rails.rb
|
115
146
|
homepage: https://github.com/ywen/redis_cache_mailer_delivery
|
116
147
|
licenses: []
|
148
|
+
|
117
149
|
post_install_message:
|
118
150
|
rdoc_options: []
|
119
|
-
|
151
|
+
|
152
|
+
require_paths:
|
120
153
|
- lib
|
121
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
155
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
hash: 3
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
version: "0"
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
164
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
hash: 3
|
169
|
+
segments:
|
170
|
+
- 0
|
171
|
+
version: "0"
|
133
172
|
requirements: []
|
173
|
+
|
134
174
|
rubyforge_project:
|
135
175
|
rubygems_version: 1.8.17
|
136
176
|
signing_key:
|
137
177
|
specification_version: 3
|
138
178
|
summary: Use Redis to store the Mail::Message when using in Rails
|
139
|
-
test_files:
|
179
|
+
test_files:
|
180
|
+
- spec/redis_cache_mailer_delivery/deliveries_spec.rb
|
140
181
|
- spec/redis_cache_mailer_delivery_spec.rb
|
141
182
|
- spec/spec_helper.rb
|
142
183
|
- spec/support/faked_rails.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module ActionMailer
|
2
|
-
class Base
|
3
|
-
class << self
|
4
|
-
|
5
|
-
#
|
6
|
-
# Returns an array of delivered mails.
|
7
|
-
#
|
8
|
-
# @return [Array] array of mails (each mail is an instance of Mail.)
|
9
|
-
#
|
10
|
-
def cached_deliveries
|
11
|
-
list = Redis::List.new redis_cache_settings[:redis_key_name], :marshal => true
|
12
|
-
list.values.map{|m|Marshal.load(m)}
|
13
|
-
end
|
14
|
-
|
15
|
-
#
|
16
|
-
# Clears delivered mails.
|
17
|
-
#
|
18
|
-
# It also cleans ActionMailer::Base.deliveries
|
19
|
-
#
|
20
|
-
def clear_cache
|
21
|
-
$redis.del redis_cache_settings[:redis_key_name]
|
22
|
-
end
|
23
|
-
|
24
|
-
end # << self
|
25
|
-
end # Base
|
26
|
-
end # ActionMailer
|