pboling-sanitize_email 0.3.1 → 0.3.2

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 1
4
+ :patch: 2
@@ -9,18 +9,12 @@ module NinthBit
9
9
 
10
10
  base.cattr_accessor :local_environments
11
11
  base.local_environments = %w( development test )
12
-
13
- base.cattr_accessor :deployed_environments
14
- base.deployed_environments = %w( production staging )
15
12
  end
16
13
 
17
14
  module ClassMethods
18
15
  def consider_local?
19
16
  local_environments.include?(defined?(Rails) ? Rails.env : RAILS_ENV)
20
17
  end
21
- def consider_deployed?
22
- deployed_environments.include?(defined?(Rails) ? Rails.env : RAILS_ENV)
23
- end
24
18
  end
25
19
 
26
20
  end
@@ -24,15 +24,21 @@ module NinthBit
24
24
  base.sanitized_recipients = nil
25
25
 
26
26
  # Use the 'real' email address as the username for the sanitized email address
27
- # e.g. "real@email.com <sanitized@email.com>"
27
+ # e.g. "real@example.com <sanitized@example.com>"
28
28
  base.cattr_accessor :use_actual_email_as_sanitized_user_name
29
29
  base.use_actual_email_as_sanitized_user_name = false
30
-
30
+
31
+ # Prepend the 'real' email address onto the Subject line of the message
32
+ # e.g. "real@example.com rest of subject"
33
+ base.cattr_accessor :use_actual_email_prepended_to_subject
34
+ base.use_actual_email_prepended_to_subject = false
35
+
31
36
  base.class_eval do
32
37
  # We need to alias these methods so that our new methods get used instead
33
38
  alias :real_bcc :bcc
34
39
  alias :real_cc :cc
35
40
  alias :real_recipients :recipients
41
+ alias :real_subject :subject
36
42
 
37
43
  def localish?
38
44
  # consider_local is a method in sanitize_email/lib/custom_environments.rb
@@ -40,11 +46,16 @@ module NinthBit
40
46
  !self.class.force_sanitize.nil? ? self.class.force_sanitize : self.class.consider_local?
41
47
  end
42
48
 
49
+ def subject(*lines)
50
+ real_subject(*lines)
51
+ localish? ? override_subject : real_subject
52
+ end
53
+
43
54
  def recipients(*addresses)
44
55
  real_recipients(*addresses)
45
56
  if localish?
46
57
  puts "sanitize_email error: sanitized_recipients is not set" if self.class.sanitized_recipients.nil?
47
- override(:recipients)
58
+ override_email(:recipients)
48
59
  else
49
60
  real_recipients
50
61
  end
@@ -52,19 +63,23 @@ module NinthBit
52
63
 
53
64
  def cc(*addresses)
54
65
  real_cc(*addresses)
55
- localish? ? override(:cc) : real_cc
66
+ localish? ? override_email(:cc) : real_cc
56
67
  end
57
68
 
58
69
  def bcc(*addresses)
59
70
  real_bcc(*addresses)
60
- localish? ? override(:bcc) : real_bcc
71
+ localish? ? override_email(:bcc) : real_bcc
61
72
  end
62
73
 
63
74
  #######
64
75
  private
65
76
  #######
66
77
 
67
- def override(type)
78
+ def override_subject
79
+ real_recipients.nil? ? real_subject : "(#{real_recipients}) #{real_subject}"
80
+ end
81
+
82
+ def override_email(type)
68
83
  real_addresses, sanitized_addresses =
69
84
  case type
70
85
  when :recipients
@@ -75,7 +90,9 @@ module NinthBit
75
90
  [real_bcc, self.class.sanitized_bcc]
76
91
  else raise "sanitize_email error: unknown email override"
77
92
  end
78
-
93
+
94
+ # If there were no original recipients, then we DO NOT override the nil with the sanitized recipients
95
+ return nil if real_addresses.nil?
79
96
  return sanitized_addresses if sanitized_addresses.nil? || !self.class.use_actual_email_as_sanitized_user_name
80
97
 
81
98
  out = real_addresses.inject([]) do |result, real_recipient|
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
4
4
  s.name = %q{sanitize_email}
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.extra_rdoc_files = ["README.rdoc"]
7
- s.version = "0.3.1"
7
+ s.version = "0.3.2"
8
8
  s.authors = ["Peter Boling", "John Trupiano", "George Anderson"]
9
9
  s.date = %q{2009-08-13}
10
10
  s.description = %q{allows you to play with your application's email abilities without worrying that emails will get sent to actual live addresses}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pboling-sanitize_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling