mandriller 0.0.6 → 0.0.7

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: c57d0cef20fb012f1d81d456f5fd1d672ffe29c7
4
- data.tar.gz: f648f0400cbf9955bf54ff1a52f33480219e547a
3
+ metadata.gz: e6471be440ee6fe69a9383bebf2ea69fb6d05ad5
4
+ data.tar.gz: 88888794cc5c8b1528b1a1e34d9fa81b74c48744
5
5
  SHA512:
6
- metadata.gz: d1e81dba186fe87e613128cf97b7abc1b020454037b3beefd75fcee4323476fa9bc66803cab7b026c8b00cd0e4002da96ae7e63011a7f169e1a46a203ad2c20a
7
- data.tar.gz: a7d2e3e3149847839731f4347bf9d51fe67f48043fa71efe840964632f3d3a2c41735dd0dd83a3681352c1dd8cf02d1754d25a3b1a44269b2f8638d111738aa8
6
+ metadata.gz: 8884f892a5f9531decc1c96e9eccbecd222cab9a00d2b9df82c8842caf982f1b44595b6afa268c27b95b2221d12efd3eae19e7ae904d280e1e88cb782082fbe4
7
+ data.tar.gz: a485da59610919903d1ff3b123cde479f22240ca7d79e6e060a9279fc7d0af96811a2ed4ca49d1e16d38c4f96b4366c2f2ea340188e2d2c255f8fa9da448aaca
data/README.md CHANGED
@@ -40,7 +40,7 @@ class UserMailer < Mandriller::Base
40
40
 
41
41
  set_open_track
42
42
  set_click_track
43
- set_google_analytics Settings.root_host, Settings.admin.host
43
+ set_google_analytics [Settings.root_host, Settings.admin.host].uniq
44
44
 
45
45
  before_filter do
46
46
  set_google_analytics_campaign "#{mailer_name.gsub(/_mailer$/, '')}/#{action_name.gsub(/_email$/, '')}"
@@ -109,7 +109,7 @@ Add dynamic data to replace mergetags that appear in your message content.
109
109
 
110
110
  Add Google Analytics tracking to links in your email for the specified domains.
111
111
 
112
- - `set_google_analytics 'foo.com', 'bar.com'`
112
+ - `set_google_analytics ['foo.com', 'bar.com'`]
113
113
 
114
114
  ### set_google_analytics_campaign
115
115
 
@@ -204,6 +204,12 @@ Specify a future date/time that the message should be [scheduled](http://help.ma
204
204
 
205
205
  __Only available for paid accounts__
206
206
 
207
+ ### set_tags
208
+
209
+ Add tags to your emails.
210
+
211
+ - `set_tags ['tag1', 'tag2'`]
212
+
207
213
  ## Contributing
208
214
 
209
215
  1. Fork it
@@ -27,34 +27,30 @@ class Mandriller::Base < ActionMailer::Base
27
27
  metadata: 'X-MC-Metadata',
28
28
  merge_vars: 'X-MC-MergeVars',
29
29
  }
30
+ ARRAY_SETTINGS = {
31
+ google_analytics: 'X-MC-GoogleAnalytics',
32
+ tags: 'X-MC-Tags',
33
+ }
30
34
  define_settings_methods BOOLEAN_SETTINGS.keys, default: true
31
35
  define_settings_methods STRING_SETTINGS.keys
32
36
  define_settings_methods JSON_SETTINGS.keys
37
+ define_settings_methods ARRAY_SETTINGS.keys
33
38
  define_settings_methods :open_track, default: true
34
39
  define_settings_methods :click_track, default: 'all'
35
40
  define_settings_methods :send_at
36
41
 
37
- class_attribute :mandrill_template, :mandrill_google_analytics
42
+ class_attribute :mandrill_template
38
43
 
39
44
  class << self
40
45
  def set_template(template_name, block_name = nil)
41
46
  self.mandrill_template = [template_name, block_name]
42
47
  end
43
-
44
- def set_google_analytics(*domains)
45
- self.mandrill_google_analytics = domains.flatten
46
- end
47
48
  end
48
49
 
49
50
  def set_template(template_name, block_name = nil)
50
51
  @mandrill_template = [template_name, block_name].compact
51
52
  end
52
53
 
53
- def set_google_analytics(*domains)
54
- domains = domains.flatten.compact
55
- @mandrill_google_analytics = domains
56
- end
57
-
58
54
  def mail(*args)
59
55
  tracks = []
60
56
  tracks << (get_mandrill_setting("open_track") ? 'opens' : nil)
@@ -72,9 +68,6 @@ class Mandriller::Base < ActionMailer::Base
72
68
  v = get_mandrill_setting("template")
73
69
  self.headers['X-MC-Template'] = v.join('|') unless v.nil? || v.empty?
74
70
 
75
- v = get_mandrill_setting("google_analytics")
76
- self.headers['X-MC-GoogleAnalytics'] = v.join(',') unless v.nil? || v.empty?
77
-
78
71
  v = get_mandrill_setting("send_at")
79
72
  self.headers['X-MC-SendAt'] = v.to_time.utc.strftime('%Y-%m-%d %H:%M:%S') unless v.nil?
80
73
 
@@ -93,6 +86,11 @@ class Mandriller::Base < ActionMailer::Base
93
86
  self.headers[header_name] = MultiJson.dump(v) unless v.nil?
94
87
  end
95
88
 
89
+ ARRAY_SETTINGS.each do |key, header_name|
90
+ v = get_mandrill_setting(key)
91
+ self.headers[header_name] = Array(v).join(',') unless v.nil?
92
+ end
93
+
96
94
  super(*args)
97
95
  end
98
96
 
@@ -1,3 +1,3 @@
1
1
  module Mandriller
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -149,6 +149,38 @@ describe Mandriller::Base do
149
149
  end
150
150
  end
151
151
 
152
+ ARRAY_SETTINGS = {
153
+ google_analytics: 'X-MC-GoogleAnalytics',
154
+ tags: 'X-MC-Tags',
155
+ }
156
+ ARRAY_SETTINGS.each do |key, header|
157
+ describe "X-MC-GoogleAnalytics header" do
158
+ context "no set" do
159
+ it_behaves_like "without header", header
160
+ end
161
+ context "set by #set_#{key}" do
162
+ let(:local_settings) { lambda{ __send__("set_#{key}", ['string1', 'string2']) } }
163
+ it_behaves_like "with header", header, 'string1,string2'
164
+ end
165
+ context "set by ::set_#{key}" do
166
+ let(:global_settings) { lambda{ __send__("set_#{key}", ['string1', 'string2']) } }
167
+ it_behaves_like "with header", header, 'string1,string2'
168
+ end
169
+ context "set by both #set_#{key} and ::set_#{key}" do
170
+ context "set value globally and set value locally" do
171
+ let(:global_settings) { lambda{ __send__("set_#{key}", ['string1', 'string2']) } }
172
+ let(:local_settings) { lambda{ __send__("set_#{key}", ['string2', 'string3']) } }
173
+ it_behaves_like "with header", header, 'string2,string3'
174
+ end
175
+ context "set value globally but set nil locally" do
176
+ let(:global_settings) { lambda{ __send__("set_#{key}", ['string1', 'string2']) } }
177
+ let(:local_settings) { lambda{ __send__("set_#{key}", nil) } }
178
+ it_behaves_like "without header", header
179
+ end
180
+ end
181
+ end
182
+ end
183
+
152
184
  describe "X-MC-Track header" do
153
185
  header = "X-MC-Track"
154
186
  context "no set" do
@@ -210,34 +242,6 @@ describe Mandriller::Base do
210
242
  end
211
243
  end
212
244
 
213
- describe "X-MC-GoogleAnalytics header" do
214
- key = "google_analytics"
215
- header = "X-MC-GoogleAnalytics"
216
- context "no set" do
217
- it_behaves_like "without header", header
218
- end
219
- context "set by #set_#{key}" do
220
- let(:local_settings) { lambda{ __send__("set_#{key}", 'domain1', 'domain2') } }
221
- it_behaves_like "with header", header, 'domain1,domain2'
222
- end
223
- context "set by ::set_#{key}" do
224
- let(:global_settings) { lambda{ __send__("set_#{key}", 'domain1', 'domain2') } }
225
- it_behaves_like "with header", header, 'domain1,domain2'
226
- end
227
- context "set by both #set_#{key} and ::set_#{key}" do
228
- context "set value globally and set value locally" do
229
- let(:global_settings) { lambda{ __send__("set_#{key}", 'domain1', 'domain2') } }
230
- let(:local_settings) { lambda{ __send__("set_#{key}", 'domain2', 'domain3') } }
231
- it_behaves_like "with header", header, 'domain2,domain3'
232
- end
233
- context "set value globally but set nil locally" do
234
- let(:global_settings) { lambda{ __send__("set_#{key}", 'domain1', 'domain2') } }
235
- let(:local_settings) { lambda{ __send__("set_#{key}", nil) } }
236
- it_behaves_like "without header", header
237
- end
238
- end
239
- end
240
-
241
245
  describe "X-MC-SendAt header" do
242
246
  key = 'send_at'
243
247
  header = "X-MC-SendAt"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandriller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Taniwaki