ses-proxy-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/.document +5 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.md +41 -0
  5. data/Rakefile +26 -0
  6. data/VERSION +1 -0
  7. data/lib/ses-proxy-rails.rb +70 -0
  8. metadata +108 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Add dependencies to develop your gem here.
4
+ # Include everything needed to run rake, tests, features, etc.
5
+ group :development do
6
+ gem "rdoc", ">= 3.12"
7
+ gem "bundler", ">= 1.0.0"
8
+ gem "jeweler", ">= 1.8.4"
9
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Massimo Maino
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,41 @@
1
+ #SES Proxy for Rails
2
+
3
+ This gem allow you to send an header that contain the application name to ses-proxy. So you can see, in the SES Proxy WebPanel, the system from which you sent your emails.
4
+
5
+ ##Install
6
+
7
+ Include `ses-proxy-rails` in your Gemfile and run `bundle install`
8
+
9
+ gem 'ses-proxy-rails'
10
+
11
+ There is no problem if you still use Rails 2. Just add `config.gem 'ses-proxy-rails'` to `config/environment.rb`
12
+
13
+ ##Usage
14
+
15
+ In many cases no configuration is necessary, but if you want you can customize the default settings by creating an initializer with this content:
16
+
17
+ # The default application name is automatically discovered
18
+ SesProxyRails::Config.application_name = "your_application_name"
19
+
20
+ # With this option you can override the standard recipient with a test address.
21
+ # This works only in development environment
22
+ # The default value is 'false'.
23
+ SesProxyRails::Config.replace_recipient = true
24
+
25
+ # The default address is taken by "git config user.email" command
26
+ SesProxyRails::Config.replacement_address = "your_email_address"
27
+
28
+ ##Contributing to ses-proxy-rails
29
+
30
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
31
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
32
+ * Fork the project.
33
+ * Start a feature/bugfix branch.
34
+ * Commit and push until you are happy with your contribution.
35
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
36
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
37
+
38
+ ##Copyright
39
+
40
+ Copyright (c) 2013 Massimo Maino. See LICENSE.txt for
41
+ further details.
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ses-proxy-rails"
18
+ gem.homepage = "http://github.com/maintux/ses-proxy-rails"
19
+ gem.license = "MIT"
20
+ gem.summary = "Add support to send a custom header when you use ActionMailer and ses-proxy gem."
21
+ gem.description = "This gem allow you to send an header that contain the application name to ses-proxy. So you can see, in the SES Proxy WebPanel, the system from which you sent your emails"
22
+ gem.email = "maintux@gmail.com"
23
+ gem.authors = ["Massimo Maino"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,70 @@
1
+ require 'action_mailer'
2
+ require 'action_mailer/version'
3
+
4
+ module SesProxyRails
5
+ class Config
6
+ cattr_accessor :replacement_address
7
+ cattr_accessor :application_name
8
+ cattr_accessor :replace_recipient
9
+
10
+ def self.get_application_name
11
+ if application_name
12
+ return application_name.to_s
13
+ else
14
+ if ActionMailer::VERSION::MAJOR < 3
15
+ #This is the unique way to get the Application Name in Rails 2
16
+ return File.basename(Rails.root.to_s)
17
+ else
18
+ return Rails.application.class.parent.to_s
19
+ end
20
+ end
21
+ end
22
+
23
+ def self.get_replacement_address
24
+ if replacement_address
25
+ return replacement_address.to_s
26
+ elsif developer_email_address
27
+ return developer_email_address
28
+ else
29
+ nil
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def self.developer_email_address
36
+ unless defined?(@@developer_email_address)
37
+ @@developer_email_address = begin
38
+ `git config user.email`.chomp
39
+ rescue
40
+ nil
41
+ end
42
+ end
43
+ @@developer_email_address
44
+ end
45
+ end
46
+ end
47
+
48
+ if ActionMailer::VERSION::MAJOR < 3
49
+ class ActionMailer::Base
50
+ def create_mail_with_ses_proxy_header
51
+ mail = create_mail_without_ses_proxy_header
52
+ mail['X-Sender-System'] = SesProxyRails::Config.get_application_name
53
+ if SesProxyRails::Config.replace_recipient and Rails.env.development?
54
+ mail.to = SesProxyRails::Config.get_replacement_address
55
+ end
56
+ mail
57
+ end
58
+ alias_method_chain :create_mail, :ses_proxy_header
59
+ end
60
+ else
61
+ class SesProxyHeader
62
+ def self.delivering_email(mail)
63
+ mail['X-Sender-System'] = SesProxyRails::Config.get_application_name
64
+ if SesProxyRails::Config.replace_recipient and Rails.env.development?
65
+ mail.to = SesProxyRails::Config.get_replacement_address
66
+ end
67
+ end
68
+ end
69
+ ActionMailer::Base.register_interceptor(SesProxyHeader)
70
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ses-proxy-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Massimo Maino
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.12'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.12'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ description: This gem allow you to send an header that contain the application name
63
+ to ses-proxy. So you can see, in the SES Proxy WebPanel, the system from which you
64
+ sent your emails
65
+ email: maintux@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files:
69
+ - LICENSE.txt
70
+ - README.md
71
+ files:
72
+ - .document
73
+ - Gemfile
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - VERSION
78
+ - lib/ses-proxy-rails.rb
79
+ homepage: http://github.com/maintux/ses-proxy-rails
80
+ licenses:
81
+ - MIT
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ segments:
93
+ - 0
94
+ hash: 3671105193068051362
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.24
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Add support to send a custom header when you use ActionMailer and ses-proxy
107
+ gem.
108
+ test_files: []