ahoy_email 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 415951e068121b2192e3dbf6eb9c275bd2995ca9
4
- data.tar.gz: b1069426b1f037dd19b607befd21333bac1b511c
3
+ metadata.gz: c93fae59edb3ef7d69664769d7706673c09955ca
4
+ data.tar.gz: d4fcf110e9b0d31f27df464426c5b98ecd8c68a5
5
5
  SHA512:
6
- metadata.gz: 367f11ab4b6d77cdc985dd9036a42a18a3d024c489550e5335b615ba64497c2f52406373c1bc891fd546bc160639f6baf52533bd07ad193b972d4d472d033b8a
7
- data.tar.gz: d8016ae2167f7167be759f7c1a3850df9b5a905994186813c0ef037b247211f8421d9ce95c86595fd358640924ffd5f678318b25ea725bd1c8cea01c2739da7e
6
+ metadata.gz: 3c3be760d8cd4b4bbbb4d7f7c82124f0243b3234a0019a9bd041241cb0ca04c2880ed539e9f0868f248c2c1d6c45cc4cf06845e97c563b26b8d19ca6ebb91a28
7
+ data.tar.gz: e76a54879f082d10651fed3e82c3dcb969eb1fd7ca3bcca9b7ab46214e73152a244ce598ecd5b71165ace8b1867bc4baa65577537a1e998db2458c58df325025
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.0
2
+
3
+ - Enable tracking when track is called by default
4
+
1
5
  ## 0.1.5
2
6
 
3
7
  - Rails 3 fix
@@ -12,12 +12,12 @@ module AhoyEmail
12
12
 
13
13
  module ClassMethods
14
14
  def track(options)
15
- self.ahoy_options = ahoy_options.merge(options)
15
+ self.ahoy_options = ahoy_options.merge(message: true).merge(options)
16
16
  end
17
17
  end
18
18
 
19
19
  def track(options)
20
- @ahoy_options = (@ahoy_options || {}).merge(options)
20
+ @ahoy_options = (@ahoy_options || {}).merge(message: true).merge(options)
21
21
  end
22
22
 
23
23
  def mail_with_ahoy(headers = {}, &block)
@@ -1,7 +1,5 @@
1
1
  module AhoyEmail
2
2
  class Processor
3
- include ActionView::Helpers::AssetTagHelper
4
-
5
3
  attr_reader :message, :options, :ahoy_message
6
4
 
7
5
  def initialize(message, options = {})
@@ -54,15 +52,13 @@ module AhoyEmail
54
52
  raw_source = (message.html_part || message).body.raw_source
55
53
  regex = /<\/body>/i
56
54
  url =
57
- AhoyEmail::Engine.routes.url_helpers.url_for(
58
- Rails.application.config.action_mailer.default_url_options.merge(
59
- controller: "ahoy/messages",
60
- action: "open",
61
- id: ahoy_message.token,
62
- format: "gif"
63
- )
55
+ url_for(
56
+ controller: "ahoy/messages",
57
+ action: "open",
58
+ id: ahoy_message.token,
59
+ format: "gif"
64
60
  )
65
- pixel = image_tag(url, size: "1x1", alt: nil)
61
+ pixel = ActionController::Base.helpers.image_tag(url, size: "1x1", alt: nil)
66
62
 
67
63
  # try to add before body tag
68
64
  if raw_source.match(regex)
@@ -92,18 +88,14 @@ module AhoyEmail
92
88
 
93
89
  if options[:click] and !skip_attribute?(link, "click")
94
90
  signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), AhoyEmail.secret_token, link["href"])
95
- url =
96
- AhoyEmail::Engine.routes.url_helpers.url_for(
97
- Rails.application.config.action_mailer.default_url_options.merge(
98
- controller: "ahoy/messages",
99
- action: "click",
100
- id: ahoy_message.token,
101
- url: link["href"],
102
- signature: signature
103
- )
91
+ link["href"] =
92
+ url_for(
93
+ controller: "ahoy/messages",
94
+ action: "click",
95
+ id: ahoy_message.token,
96
+ url: link["href"],
97
+ signature: signature
104
98
  )
105
-
106
- link["href"] = url
107
99
  end
108
100
  end
109
101
 
@@ -130,6 +122,10 @@ module AhoyEmail
130
122
  end
131
123
  end
132
124
 
125
+ def url_for(options)
126
+ AhoyEmail::Engine.routes.url_helpers.url_for((ActionMailer::Base.default_url_options || {}).merge(options))
127
+ end
128
+
133
129
  # not a fan of quiet errors
134
130
  # but tracking should *not* break
135
131
  # email delivery in production
@@ -142,4 +138,4 @@ module AhoyEmail
142
138
  end
143
139
 
144
140
  end
145
- end
141
+ end
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.5
4
+ version: 0.2.0
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-09 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails