whitelist_mail_proxy 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/whitelist_mail_proxy.rb +12 -5
- metadata +3 -3
data/Rakefile
CHANGED
@@ -45,7 +45,7 @@ spec = Gem::Specification.new do |s|
|
|
45
45
|
|
46
46
|
# Change these as appropriate
|
47
47
|
s.name = "whitelist_mail_proxy"
|
48
|
-
s.version = "0.
|
48
|
+
s.version = "0.3.0"
|
49
49
|
s.summary = "A thin proxy for Mail and ActionMailer to enable whitelisting"
|
50
50
|
s.author = "Matthew Rudy Jacobs"
|
51
51
|
s.email = "MatthewRudyJacobs@gmail.com"
|
data/lib/whitelist_mail_proxy.rb
CHANGED
@@ -8,10 +8,6 @@ class WhitelistMailProxy
|
|
8
8
|
raise "must have :regexp" unless @regexp
|
9
9
|
end
|
10
10
|
attr_reader :delivery_method, :regexp
|
11
|
-
|
12
|
-
def block?(string)
|
13
|
-
string !~ regexp
|
14
|
-
end
|
15
11
|
|
16
12
|
def deliver!(mail)
|
17
13
|
blocked = mail.destinations.select do |destination|
|
@@ -21,10 +17,21 @@ class WhitelistMailProxy
|
|
21
17
|
if blocked.any?
|
22
18
|
raise "cannot send to #{blocked.inspect}, whitelist is #{regexp.inspect}"
|
23
19
|
else
|
24
|
-
|
20
|
+
real_delivery_method.deliver!(mail)
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
24
|
+
protected
|
25
|
+
|
26
|
+
def block?(string)
|
27
|
+
string !~ regexp
|
28
|
+
end
|
29
|
+
|
30
|
+
def real_delivery_method
|
31
|
+
settings = ActionMailer::Base.send(:"#{self.delivery_method}_settings")
|
32
|
+
ActionMailer::Base.delivery_methods[self.delivery_method].new(settings)
|
33
|
+
end
|
34
|
+
|
28
35
|
end
|
29
36
|
|
30
37
|
if defined?(Rails)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whitelist_mail_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew Rudy Jacobs
|