whitelist_mail_proxy 0.1.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/MIT-LICENSE +20 -0
- data/README +19 -0
- data/Rakefile +99 -0
- data/lib/whitelist_mail_proxy.rb +25 -0
- metadata +71 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [Matthew Rudy Jacobs]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
WhitelistMailProxy
|
2
|
+
==================
|
3
|
+
|
4
|
+
A simple wrapper for the Mail gem / ActionMailer.
|
5
|
+
Allow regexp based whitelisting
|
6
|
+
|
7
|
+
Example
|
8
|
+
=======
|
9
|
+
|
10
|
+
Gemfile
|
11
|
+
|
12
|
+
gem "whitelist_mail_proxy"
|
13
|
+
|
14
|
+
config/staging.rb
|
15
|
+
|
16
|
+
config.action_mailer.delivery_method = WhitelistMailerProxy.new(:delivery_method => Mail::SMTP.new, :regexp => /hotmail\.com/)
|
17
|
+
|
18
|
+
|
19
|
+
Copyright (c) 2010 [Matthew Rudy Jacobs], released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the whitelist_mail_proxy plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the whitelist_mail_proxy plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'WhitelistMailProxy'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
require "rubygems"
|
26
|
+
require "rake/gempackagetask"
|
27
|
+
require "rake/rdoctask"
|
28
|
+
|
29
|
+
require "rake/testtask"
|
30
|
+
Rake::TestTask.new do |t|
|
31
|
+
t.libs << "test"
|
32
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
33
|
+
t.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task :default => ["test"]
|
38
|
+
|
39
|
+
# This builds the actual gem. For details of what all these options
|
40
|
+
# mean, and other ones you can add, check the documentation here:
|
41
|
+
#
|
42
|
+
# http://rubygems.org/read/chapter/20
|
43
|
+
#
|
44
|
+
spec = Gem::Specification.new do |s|
|
45
|
+
|
46
|
+
# Change these as appropriate
|
47
|
+
s.name = "whitelist_mail_proxy"
|
48
|
+
s.version = "0.1.0"
|
49
|
+
s.summary = "A thin proxy for Mail and ActionMailer to enable whitelisting"
|
50
|
+
s.author = "Matthew Rudy Jacobs"
|
51
|
+
s.email = "MatthewRudyJacobs@gmail.com"
|
52
|
+
s.homepage = "http://github.com/matthewrudy/whitelist-mail-proxy"
|
53
|
+
|
54
|
+
s.has_rdoc = true
|
55
|
+
s.extra_rdoc_files = %w(README)
|
56
|
+
s.rdoc_options = %w(--main README)
|
57
|
+
|
58
|
+
# Add any extra files to include in the gem
|
59
|
+
s.files = %w(MIT-LICENSE Rakefile README) + Dir.glob("{test,lib/**/*}")
|
60
|
+
s.require_paths = ["lib"]
|
61
|
+
|
62
|
+
# If you want to depend on other gems, add them here, along with any
|
63
|
+
# relevant versions
|
64
|
+
# s.add_dependency("some_other_gem", "~> 0.1.0")
|
65
|
+
|
66
|
+
# If your tests use any gems, include them here
|
67
|
+
# s.add_development_dependency("mocha") # for example
|
68
|
+
end
|
69
|
+
|
70
|
+
# This task actually builds the gem. We also regenerate a static
|
71
|
+
# .gemspec file, which is useful if something (i.e. GitHub) will
|
72
|
+
# be automatically building a gem for this project. If you're not
|
73
|
+
# using GitHub, edit as appropriate.
|
74
|
+
#
|
75
|
+
# To publish your gem online, install the 'gemcutter' gem; Read more
|
76
|
+
# about that here: http://gemcutter.org/pages/gem_docs
|
77
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
78
|
+
pkg.gem_spec = spec
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Build the gemspec file #{spec.name}.gemspec"
|
82
|
+
task :gemspec do
|
83
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
84
|
+
File.open(file, "w") {|f| f << spec.to_ruby }
|
85
|
+
end
|
86
|
+
|
87
|
+
task :package => :gemspec
|
88
|
+
|
89
|
+
# Generate documentation
|
90
|
+
Rake::RDocTask.new do |rd|
|
91
|
+
rd.main = "README"
|
92
|
+
rd.rdoc_files.include("README", "lib/**/*.rb")
|
93
|
+
rd.rdoc_dir = "rdoc"
|
94
|
+
end
|
95
|
+
|
96
|
+
desc 'Clear out RDoc and generated packages'
|
97
|
+
task :clean => [:clobber_rdoc, :clobber_package] do
|
98
|
+
rm "#{spec.name}.gemspec"
|
99
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class WhitelistMailProxy
|
2
|
+
|
3
|
+
def initialize(options)
|
4
|
+
@delivery_method = options[:delivery_method]
|
5
|
+
@regexp = options[:regexp]
|
6
|
+
end
|
7
|
+
attr_reader :delivery_method, :regexp
|
8
|
+
|
9
|
+
def block?(string)
|
10
|
+
string !~ regexp
|
11
|
+
end
|
12
|
+
|
13
|
+
def deliver!(mail)
|
14
|
+
blocked = mail.destinations.select do |destination|
|
15
|
+
block?(destination)
|
16
|
+
end
|
17
|
+
|
18
|
+
if blocked.any?
|
19
|
+
raise "cannot send to #{blocked.inspect}"
|
20
|
+
else
|
21
|
+
delivery_method.deliver!(mail)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whitelist_mail_proxy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Matthew Rudy Jacobs
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-07 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: MatthewRudyJacobs@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README
|
30
|
+
files:
|
31
|
+
- MIT-LICENSE
|
32
|
+
- Rakefile
|
33
|
+
- README
|
34
|
+
- lib/whitelist_mail_proxy.rb
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/matthewrudy/whitelist-mail-proxy
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --main
|
42
|
+
- README
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: A thin proxy for Mail and ActionMailer to enable whitelisting
|
70
|
+
test_files: []
|
71
|
+
|