ahoy_email 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +21 -3
- data/lib/ahoy_email/mailer.rb +5 -12
- data/lib/ahoy_email/processor.rb +20 -4
- data/lib/ahoy_email/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe2130c231eb69814fa0ad0f3afd38560b7186e9
|
4
|
+
data.tar.gz: 83cd45ecac4cd1345c49c0e798c23cfcc4eb646d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 310069adf7575599950544584a1452ea43557862cb0e692191d5ea4b9132b9681681fa8dd62d87a75d1072d5e6ba92ee0848ac7b8183d5100335d355b3fce102
|
7
|
+
data.tar.gz: 6304688a168126a1d6af7d6a92a17cc830488f2109ade62bf092022895c22f1314365cec25e53ccd556a9134f1bb1c534bac8fb998d7eb0d804a25fb4b1d9c1f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -116,9 +116,20 @@ Use `track utm_params: false` to skip tagging, or skip specific links with:
|
|
116
116
|
|
117
117
|
## Customize
|
118
118
|
|
119
|
+
### Tracking
|
120
|
+
|
121
|
+
Skip tracking of attributes by removing them from your model. You can safely remove:
|
122
|
+
|
123
|
+
- to
|
124
|
+
- mailer
|
125
|
+
- subject
|
126
|
+
- content
|
127
|
+
|
128
|
+
### Configuration
|
129
|
+
|
119
130
|
There are 3 places to set options. Here’s the order of precedence.
|
120
131
|
|
121
|
-
|
132
|
+
#### Action
|
122
133
|
|
123
134
|
``` ruby
|
124
135
|
class UserMailer < ActionMailer::Base
|
@@ -130,7 +141,7 @@ class UserMailer < ActionMailer::Base
|
|
130
141
|
end
|
131
142
|
```
|
132
143
|
|
133
|
-
|
144
|
+
#### Mailer
|
134
145
|
|
135
146
|
```ruby
|
136
147
|
class UserMailer < ActionMailer::Base
|
@@ -138,7 +149,7 @@ class UserMailer < ActionMailer::Base
|
|
138
149
|
end
|
139
150
|
```
|
140
151
|
|
141
|
-
|
152
|
+
#### Global
|
142
153
|
|
143
154
|
```ruby
|
144
155
|
AhoyEmail.track open: false
|
@@ -182,6 +193,13 @@ Disable tracking for an email
|
|
182
193
|
track message: false
|
183
194
|
```
|
184
195
|
|
196
|
+
Or specific actions
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
track only: [:welcome_email]
|
200
|
+
track except: [:welcome_email]
|
201
|
+
```
|
202
|
+
|
185
203
|
Or by default
|
186
204
|
|
187
205
|
```ruby
|
data/lib/ahoy_email/mailer.rb
CHANGED
@@ -4,6 +4,7 @@ module AhoyEmail
|
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
6
6
|
base.class_eval do
|
7
|
+
attr_accessor :ahoy_options
|
7
8
|
class_attribute :ahoy_options
|
8
9
|
self.ahoy_options = {}
|
9
10
|
alias_method_chain :mail, :ahoy
|
@@ -11,26 +12,18 @@ module AhoyEmail
|
|
11
12
|
end
|
12
13
|
|
13
14
|
module ClassMethods
|
14
|
-
def track(options)
|
15
|
+
def track(options = {})
|
15
16
|
self.ahoy_options = ahoy_options.merge(message: true).merge(options)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
def track(options)
|
20
|
-
|
20
|
+
def track(options = {})
|
21
|
+
self.ahoy_options = (ahoy_options || {}).merge(message: true).merge(options)
|
21
22
|
end
|
22
23
|
|
23
24
|
def mail_with_ahoy(headers = {}, &block)
|
24
25
|
message = mail_without_ahoy(headers, &block)
|
25
|
-
|
26
|
-
options = AhoyEmail.options.merge(self.class.ahoy_options).merge(@ahoy_options || {})
|
27
|
-
options.each do |k, v|
|
28
|
-
if v.respond_to?(:call)
|
29
|
-
options[k] = v.call(message, self)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
AhoyEmail::Processor.new(message, options).process
|
33
|
-
|
26
|
+
AhoyEmail::Processor.new(message, self).process
|
34
27
|
message
|
35
28
|
end
|
36
29
|
|
data/lib/ahoy_email/processor.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module AhoyEmail
|
2
2
|
class Processor
|
3
|
-
attr_reader :message, :
|
3
|
+
attr_reader :message, :mailer, :ahoy_message
|
4
4
|
|
5
|
-
def initialize(message,
|
5
|
+
def initialize(message, mailer = nil)
|
6
6
|
@message = message
|
7
|
-
@
|
7
|
+
@mailer = mailer
|
8
8
|
end
|
9
9
|
|
10
10
|
def process
|
11
|
-
|
11
|
+
action_name = mailer.action_name.to_sym
|
12
|
+
if options[:message] and (!options[:only] or options[:only].include?(action_name)) and !options[:except].to_a.include?(action_name)
|
12
13
|
@ahoy_message = AhoyEmail.message_model.new
|
13
14
|
ahoy_message.token = generate_token
|
14
15
|
ahoy_message.to = message.to.join(", ") if ahoy_message.respond_to?(:to=)
|
@@ -43,6 +44,21 @@ module AhoyEmail
|
|
43
44
|
|
44
45
|
protected
|
45
46
|
|
47
|
+
def options
|
48
|
+
@options ||= begin
|
49
|
+
options = AhoyEmail.options.merge(mailer.class.ahoy_options)
|
50
|
+
if mailer.ahoy_options
|
51
|
+
options = options.except(:only, :except).merge(mailer.ahoy_options)
|
52
|
+
end
|
53
|
+
options.each do |k, v|
|
54
|
+
if v.respond_to?(:call)
|
55
|
+
options[k] = v.call(message, mailer)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
options
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
46
62
|
def generate_token
|
47
63
|
SecureRandom.urlsafe_base64(32).gsub(/[\-_]/, "").first(32)
|
48
64
|
end
|
data/lib/ahoy_email/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|