sanitize_email 0.3.9 → 1.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/CHANGELOG ADDED
@@ -0,0 +1,23 @@
1
+ Version 1.0.0.alpha1
2
+ - Implementing initial support for Rails >= 3.0 (new ActionMailer API)
3
+ - Support for Rails <= 2.X remains in version 0.X.X releases.
4
+
5
+ XXXXXXXXXXXXXXXXXXXXXXX Rail 3.0+ Only Form here on up! XXXXXXXXXXXXXXXXXXXXXXX
6
+
7
+ Version 0.3.8
8
+ - Update specs, note requirement of Rails 2.3 or below to run spec quite.
9
+ - Support use_actual_email_prepended_to_subject
10
+ - Fix environment check for old versions of Rails
11
+ - Improved Readme
12
+
13
+ Version 0.3.7
14
+ - Improved Installation instructions
15
+ - Fixed so tests run from inside a rails app (previously only ran standalone)
16
+
17
+ Version 0.3.6
18
+ - Fixed Installation instructions
19
+ - Improved README
20
+
21
+ Old version?
22
+ - Fixed require paths
23
+ - added about.yml and this CHANGELOG
data/Gemfile CHANGED
@@ -1,15 +1,15 @@
1
- source 'https://rubygems.org'
1
+ source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in sanitize_email.gemspec
4
- gemspec
3
+ gem 'rails', '> 3'
4
+ gem 'actionmailer', '> 3'
5
5
 
6
- # Development dependencies (everything needed to run rake, tests, features, etc.)
7
6
  group :development, :test do
8
- # To use debugger
9
- # gem 'ruby-debug19', :require => 'ruby-debug'
10
-
11
- gem "rdoc", ">= 3.12"
12
- gem "bundler", ">= 1.0.24"
13
- gem "reek", ">= 1.2.8"
14
- gem "roodi", ">= 2.1.0"
7
+ gem 'jeweler'
8
+ gem 'letter_opener'
9
+ gem 'launchy'
10
+ gem 'rspec'
11
+ gem 'mail'
12
+ gem 'rdoc', '>= 3.12'
13
+ gem 'reek', '>= 1.2.8'
14
+ gem 'roodi', '>= 2.1.0'
15
15
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,129 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.6)
5
+ actionpack (= 3.2.6)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.6)
8
+ activemodel (= 3.2.6)
9
+ activesupport (= 3.2.6)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.6)
18
+ activesupport (= 3.2.6)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.6)
21
+ activemodel (= 3.2.6)
22
+ activesupport (= 3.2.6)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.6)
26
+ activemodel (= 3.2.6)
27
+ activesupport (= 3.2.6)
28
+ activesupport (3.2.6)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ addressable (2.2.8)
32
+ arel (3.0.2)
33
+ builder (3.0.0)
34
+ diff-lcs (1.1.3)
35
+ erubis (2.7.0)
36
+ git (1.2.5)
37
+ hike (1.2.1)
38
+ i18n (0.6.0)
39
+ jeweler (1.8.4)
40
+ bundler (~> 1.0)
41
+ git (>= 1.2.5)
42
+ rake
43
+ rdoc
44
+ journey (1.0.4)
45
+ json (1.7.3)
46
+ launchy (2.1.0)
47
+ addressable (~> 2.2.6)
48
+ letter_opener (0.0.2)
49
+ launchy
50
+ mail (2.4.4)
51
+ i18n (>= 0.4.0)
52
+ mime-types (~> 1.16)
53
+ treetop (~> 1.4.8)
54
+ mime-types (1.19)
55
+ multi_json (1.3.6)
56
+ polyglot (0.3.3)
57
+ rack (1.4.1)
58
+ rack-cache (1.2)
59
+ rack (>= 0.4)
60
+ rack-ssl (1.3.2)
61
+ rack
62
+ rack-test (0.6.1)
63
+ rack (>= 1.0)
64
+ rails (3.2.6)
65
+ actionmailer (= 3.2.6)
66
+ actionpack (= 3.2.6)
67
+ activerecord (= 3.2.6)
68
+ activeresource (= 3.2.6)
69
+ activesupport (= 3.2.6)
70
+ bundler (~> 1.0)
71
+ railties (= 3.2.6)
72
+ railties (3.2.6)
73
+ actionpack (= 3.2.6)
74
+ activesupport (= 3.2.6)
75
+ rack-ssl (~> 1.3.2)
76
+ rake (>= 0.8.7)
77
+ rdoc (~> 3.4)
78
+ thor (>= 0.14.6, < 2.0)
79
+ rake (0.9.2.2)
80
+ rdoc (3.12)
81
+ json (~> 1.4)
82
+ reek (1.2.12)
83
+ ripper_ruby_parser (~> 0.0.7)
84
+ ruby2ruby (~> 1.2.5)
85
+ ruby_parser (~> 2.0)
86
+ sexp_processor (~> 3.0)
87
+ ripper_ruby_parser (0.0.7)
88
+ sexp_processor (~> 3.0)
89
+ roodi (2.1.0)
90
+ ruby_parser
91
+ rspec (2.10.0)
92
+ rspec-core (~> 2.10.0)
93
+ rspec-expectations (~> 2.10.0)
94
+ rspec-mocks (~> 2.10.0)
95
+ rspec-core (2.10.1)
96
+ rspec-expectations (2.10.0)
97
+ diff-lcs (~> 1.1.3)
98
+ rspec-mocks (2.10.1)
99
+ ruby2ruby (1.2.5)
100
+ ruby_parser (~> 2.0)
101
+ sexp_processor (~> 3.0)
102
+ ruby_parser (2.3.1)
103
+ sexp_processor (~> 3.0)
104
+ sexp_processor (3.2.0)
105
+ sprockets (2.1.3)
106
+ hike (~> 1.2)
107
+ rack (~> 1.0)
108
+ tilt (~> 1.1, != 1.3.0)
109
+ thor (0.15.3)
110
+ tilt (1.3.3)
111
+ treetop (1.4.10)
112
+ polyglot
113
+ polyglot (>= 0.3.1)
114
+ tzinfo (0.3.33)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ actionmailer (> 3)
121
+ jeweler
122
+ launchy
123
+ letter_opener
124
+ mail
125
+ rails (> 3)
126
+ rdoc (>= 3.12)
127
+ reek (>= 1.2.8)
128
+ roodi (>= 2.1.0)
129
+ rspec
@@ -1,6 +1,4 @@
1
- Copyright (c) 2008-2014 Peter Boling
2
-
3
- MIT License
1
+ Copyright (c) 2008 Peter H. Boling of 9thBit LLC
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
6
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,7 +1,5 @@
1
1
  = sanitize_email
2
2
 
3
- NOTE ABOUT THIS VERSION: Sanitize email versions < 1 (i.e. major version 0) are to be kept compatible with Rails versions 3.1 and under. They will be built and released from the rails_3_1_and_below branch.
4
-
5
3
  This gem allows you to globally override your mail delivery settings. It's particularly helpful when you want to omit the delivery of email (e.g. in development/test environments) or alter the to/cc/bcc (e.g. in staging or demo environments) of all email generated from your application.
6
4
 
7
5
  It is a "configure it and forget it" type gem that requires very little setup. It includes some very innocuous monkey patching of ActionMailer::Base to work its magic.
@@ -25,51 +23,34 @@ Another very important use case for me is to transparently re-route email genera
25
23
 
26
24
  If you install this gem on a production server (which I don't always do), you can load up script/console and override the to/cc/bcc on all emails for the duration of your console session. This allows you to poke and prod a live production instance, and route all email to your own inbox for inspection. The best part is that this can all be accomplished without changing a single line of your application code.
27
25
 
28
- == Install as a RubyGem
29
-
30
- Releases on the rails_3_1_and_below branch will remain within major version 0 and support Rails 2:
31
-
32
- [sudo] gem install sanitize_email -v 0.3.9
33
-
34
- The master branch (*which is not this one*) has moved on to support Rails 3 and 4, and the API is somewhat different.
35
-
36
- == Setup
37
-
38
- It only requires a few lines of configuration:
26
+ == Install Like a Boss
39
27
 
40
- * Rails 1.x: Add to bottom of environment.rb
28
+ [sudo] gem install sanitize_email
41
29
 
42
- * Rails 2.x: Use an initializer, stick it in any initializer file, or create a new one for sanitize_email
30
+ == Setup With An Axe
43
31
 
44
- Add this bit and customize for your app:
32
+ Customize and add to an initializer:
45
33
 
46
- # Settings for sanitize_email gem. These can be overridden in individual config/%env%/environment.rb files.
47
-
48
- require 'sanitize_email'
49
- ActionMailer::Base.sanitized_recipients = "jtrupiano@gmail.com"
50
- ActionMailer::Base.sanitized_bcc = nil
51
- ActionMailer::Base.sanitized_cc = nil
52
-
53
- # optionally, you can configure sanitize_email to to include the "real" email address as the 'user name' of the
54
- # "sanitized" email (e.g. "real@address.com <sanitized@email.com>")
55
- ActionMailer::Base.use_actual_email_as_sanitized_user_name = true # defaults to false
56
-
57
- # These are the environments whose outgoing email BCC, CC and recipients fields will be overridden!
58
- # All environments not listed will be treated as normal.
59
- ActionMailer::Base.local_environments = %w( development test staging )
34
+ SanitizeEmail::Config.configure do |config|
35
+ config[:sanitized_recipients] = 'to@sanitize_email.org'
36
+ config[:sanitized_bcc] = 'bcc@sanitize_email.org'
37
+ config[:sanitized_cc] = 'cc@sanitize_email.org'
38
+ config[:local_environments] = %w(development test
39
+ config[:use_actual_email_prepended_to_subject] = true # or false
40
+ config[:use_actual_email_as_sanitized_user_name] = true # or false
41
+ end
60
42
 
61
43
  Keep in mind, this is ruby (and possibly rails), so you can add conditionals or utilize different environment.rb files to customize these settings on a per-environment basis.
62
44
 
63
45
  But wait there's more:
64
46
 
65
- Let's say you have a method in your model that you can call to test the signup email.
66
- You want to be able to test sending it to any user at any time... but you don't want
67
- the user to ACTUALLY get the email, even in production. A dilemma, yes? Not anymore!
47
+ Let's say you have a method in your model that you can call to test the signup email. You want to be able to test sending it to any user at any time... but you don't want the user to ACTUALLY get the email, even in production. A dilemma, yes? Not anymore!
68
48
 
69
- All your mailers get a force_sanitize class method which takes precedence over the environment override.
70
-
71
- When force_sanitize is nil it will not be used by sanitize_email to determine if it should override the recipients, bcc, and cc.
49
+ To override the environment based switch use force_sanitize, which is nil, and ignored by default. When set to true or false it will turn sanitization on or off:
72
50
 
51
+ SanitizeEmail::Config.configure do |config|
52
+ config[:force_sanitize] = true
53
+ end
73
54
 
74
55
  == Example
75
56
 
@@ -83,18 +64,22 @@ and are in the development environment, you can override the override anywhere i
83
64
 
84
65
  class User < ActiveRecord::Base
85
66
  def test_signup_email_me_only
86
- UserMailer.force_sanitize = true
67
+ SanitizeEmail::Config.configure do |config|
68
+ config[:force_sanitize] = true
69
+ end
87
70
  UserMailer.deliver_signup_notification(self)
88
71
  UserMailer.force_sanitize = nil
89
72
  end
90
73
 
91
74
  def test_signup_email_user_only
92
- UserMailer.force_sanitize = false
75
+ SanitizeEmail::Config.configure do |config|
76
+ config[:force_sanitize] = false
77
+ end
93
78
  UserMailer.deliver_signup_notification(self)
94
79
  UserMailer.force_sanitize = nil
95
80
  end
96
81
 
97
- # this third method would conditionally use the overridden recipients based on current Rails environment
82
+ # this third method would conditionally use the overridden recipients based on inclusion of current Rails environment in the local_environments configuration option.
98
83
  def test_signup_email_environment
99
84
  UserMailer.deliver_signup_notification(self)
100
85
  end
@@ -109,27 +94,6 @@ Then if you want to send it to the actual user, instead of yourself
109
94
 
110
95
  > User.find(4).test_signup_email_user_only
111
96
 
112
- == Alternate Installation Methods
113
-
114
- Some of these are Rails version dependent.
115
-
116
- Source Install:
117
-
118
- mkdir -p ~/src
119
- cd ~/src
120
- git clone git://github.com/pboling/sanitize_email.git
121
- cd sanitize_email
122
- gem build sanitize_email.gemspec
123
- sudo gem install sanitize_email-X.X.X.gem # (whatever version gets built)
124
-
125
- Then in your environment.rb (if you are just going to use it from the console, you can require it as needed there, and skip the config.gem):
126
-
127
- config.gem 'sanitize_email'
128
-
129
- Then cd to your rails app to optionally freeze the gem into your app (if you roll this way):
130
-
131
- rake gems:freeze GEM=sanitize_email
132
-
133
97
  == Install as a Plugin
134
98
 
135
99
  Plugin using Git:
@@ -141,17 +105,10 @@ Plugin using Git:
141
105
 
142
106
  git submodule add git://github.com/pboling/sanitize_email.git vendor/plugins/sanitize_email
143
107
 
144
- == Run the Test Suite
145
-
146
- The test suite must be run against Rails 2.3.X or below as it is coded to expect the Tmail objects under the hood.
147
-
148
- rake test
149
-
150
108
  == Authors
151
109
 
152
- Peter Boling is the original author of the code.
153
- John Trupiano gemified and improved the code.
154
- John kindly returned gem ownership to Peter, who currently maintains it.
110
+ Peter Boling is the original author of the code, and current maintainer of both the rails 2 and rails 3 development tracks.
111
+ John Trupiano did the initial gemification and some refactoring.
155
112
 
156
113
  == Contributors
157
114
 
@@ -163,6 +120,6 @@ George Anderson's work / improvements have been pulled in, along with several ot
163
120
  * {Peter's Original Writeup}[http://galtzo.blogspot.com/2008/11/sanitize-email-never-worry-about.html]
164
121
  * {Using sanitize_email to Preview HTML Emails Locally}[http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/]
165
122
 
166
- Copyright (c) 2008-2014 {Peter H. Boling}[http://railsbling.com]
123
+ Copyright (c) 2008-2012 {Peter H. Boling}[http://www.peterboling.com/about.html] of {9thBit LLC}[http://www.peterboling.com/]
167
124
  Copyright (c) 2009 {John Trupiano}[http://smartlogicsolutions.com/wiki/John_Trupiano] of {SmartLogic Solutions, LLC}[http://www.smartlogicsolutions.com]
168
- Released under the MIT license, see LICENSE.txt in this directory
125
+ Released under the MIT license
data/Rakefile CHANGED
@@ -1,14 +1,59 @@
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
1
12
  require 'rake'
2
- require 'rake/testtask'
3
13
 
4
- desc 'Default: run unit tests.'
5
- task :default => :test
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 = "sanitize_email"
18
+ gem.homepage = "http://github.com/pboling/sanitize_email"
19
+ gem.license = "MIT"
20
+ gem.summary = %q{Test an application's email abilities without ever sending a message to actual live addresses}
21
+ gem.description = "Tool to aid in development, testing, qa, and production troubleshooting of email issues without worrying that emails will get sent to actual live addresses."
22
+ gem.email = ['peter.boling@gmail.com', 'jtrupiano@gmail.com', 'george@benevolentcode.com']
23
+ gem.authors = ["Peter Boling", "John Trupiano", "George Anderson"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ require 'reek/rake/task'
35
+ Reek::Rake::Task.new do |t|
36
+ t.fail_on_error = true
37
+ t.verbose = false
38
+ t.source_files = 'lib/**/*.rb'
39
+ end
40
+
41
+ require 'roodi'
42
+ require 'roodi_task'
43
+ RoodiTask.new do |t|
44
+ t.verbose = false
45
+ end
46
+
47
+ task :default => :spec
6
48
 
7
- desc 'Test the sanitize_email plugin.'
8
- Rake::TestTask.new(:test) do |t|
9
- t.libs << 'lib'
10
- t.pattern = 'test/**/*_test.rb'
11
- t.verbose = true
49
+ require 'rdoc/task'
50
+ Rake::RDocTask.new do |rdoc|
51
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "SanitizeEmail #{version}"
54
+ rdoc.options << '--line-numbers'
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
12
57
  end
13
58
 
14
- require "bundler/gem_tasks"
59
+ Bundler::GemHelper.install_tasks
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :major: 0
3
- :minor: 3
4
- :patch: 8
5
- :build:
2
+ :major: 1
3
+ :minor: 0
4
+ :patch: 0
5
+ :build: alpha2
@@ -1,12 +1,31 @@
1
- # Versions of sanitize_email > 1 no longer require actionmailer, and can be used sans-rails.
2
- require 'actionmailer'
3
-
4
- require "sanitize_email/version"
5
- require 'sanitize_email/sanitize_email'
6
- require 'sanitize_email/custom_environments'
1
+ #Copyright (c) 2008-12 Peter H. Boling of 9thBit LLC
2
+ #Released under the MIT license
3
+ require 'rails'
4
+ require 'action_mailer'
7
5
 
8
6
  module SanitizeEmail
9
- end
7
+ if defined?(Rails) && ::Rails::VERSION::MAJOR >= 3
8
+ require 'sanitize_email/version'
9
+ require 'sanitize_email/config'
10
+ require 'sanitize_email/sanitizer'
11
+ require 'sanitize_email/hook'
12
+
13
+ if ::Rails::VERSION::MINOR >= 1
14
+ require 'sanitize_email/engine'
15
+ elsif ::Rails::VERSION::MINOR == 0
16
+ require 'sanitize_email/railtie'
17
+ end
18
+ else
19
+ raise "Please use the 0.X.X versions of sanitize_email for Rails 2.X and below."
20
+ end
10
21
 
11
- ActionMailer::Base.send :include, NinthBit::CustomEnvironments
12
- ActionMailer::Base.send :include, NinthBit::SanitizeEmail
22
+ def self.[](key)
23
+ return nil unless key.respond_to?(:to_sym)
24
+ SanitizeEmail::Config.config[key.to_sym]
25
+ end
26
+
27
+ def self.method_missing(name, *args)
28
+ SanitizeEmail[name]
29
+ end
30
+
31
+ end