per_mailer_smtp_settings 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 James Golick
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.
@@ -0,0 +1,13 @@
1
+ = per_mailer_smtp_settings
2
+
3
+ Currently, action_mailer's smtp settings are on a per application basis. For various reasons, it may be desirable to send different mailings from different mailers. This plugin enables that functionality.
4
+
5
+ = Why would I want that?
6
+
7
+ FetLife.com (NSFW) sends out mailings for a variety of different reasons. We send out a mailer when you sign up, or somebody adds you as a friend, for example. Our biggest volume mailing is the one that goes out when somebody creates a new post in a group. Some of our groups have over 10k members. So, that particular mailing can be quite high volume.
8
+
9
+ Because it's so high volume, the new group post notification is a lot more likely to get our smtp servers deferred by the major email providers. The deliverability of that mail is also less important than most of the others. So, sending it from a different cluster of smtp servers is a great way to decouple its deliverability from the rest of our mailers.
10
+
11
+ == Copyright
12
+
13
+ Copyright (c) 2009 James Golick. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "per_mailer_smtp_settings"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "james@giraffesoft.ca"
10
+ gem.homepage = "http://github.com/giraffesoft/per_mailer_smtp_settings"
11
+ gem.authors = ["James Golick"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "per_mailer_smtp_settings #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ class ActionMailer::Base
2
+ class_inheritable_accessor :smtp_settings
3
+ self.smtp_settings = @@smtp_settings
4
+ end
5
+
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class PerMailerSmtpSettingsTest < Test::Unit::TestCase
4
+ context "Sending a normal mailing" do
5
+ should "deliver through the settings on Base" do
6
+ Net::SMTP.expects(:new).with("smtp.example.com", 25).
7
+ returns(stub_everything)
8
+ NormalMailer.deliver_something
9
+ end
10
+ end
11
+
12
+ context "Sending from a mailer with overridden settings" do
13
+ should "deliver with the overridden settings" do
14
+ Net::SMTP.expects(:new).
15
+ with("highpriority.example.com", 25).
16
+ returns(stub_everything)
17
+ HighPriorityMailer.deliver_something
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+ require 'actionmailer'
6
+
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'per_mailer_smtp_settings'
10
+
11
+ ActionMailer::Base.smtp_settings = {
12
+ :address => "smtp.example.com",
13
+ :port => 25
14
+ }
15
+ ActionMailer::Base.template_root =
16
+ File.dirname(__FILE__) + "/fixtures"
17
+
18
+ class NormalMailer < ActionMailer::Base
19
+ def something; end
20
+ end
21
+
22
+ class HighPriorityMailer < ActionMailer::Base
23
+ self.smtp_settings = {
24
+ :address => "highpriority.example.com",
25
+ :port => 25
26
+ }
27
+
28
+ def something; end
29
+ end
30
+
31
+ class Test::Unit::TestCase
32
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: per_mailer_smtp_settings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Golick
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-08 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: james@giraffesoft.ca
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - lib/per_mailer_smtp_settings.rb
33
+ - test/fixtures/high_priority_mailer/something.erb
34
+ - test/fixtures/normal_mailer/something.erb
35
+ - test/per_mailer_smtp_settings_test.rb
36
+ - test/test_helper.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/giraffesoft/per_mailer_smtp_settings
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.3.1
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: TODO
63
+ test_files:
64
+ - test/per_mailer_smtp_settings_test.rb
65
+ - test/test_helper.rb