mail-x_smtpapi 1.0.0.alpha2 → 1.0.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: 2aa241982d4d0042b269a45812005b55639ed5aa
4
- data.tar.gz: c3287e3ae8bf85afc9a29ea472f8830926bb78d0
3
+ metadata.gz: ff36feee769b1735b03c6334a653e02eba9b0866
4
+ data.tar.gz: 5e54b8c395024ca89d1df5f4930118905a7f6aee
5
5
  SHA512:
6
- metadata.gz: 12e2dd0e22ee789a2c4e37fb26245f900dde5125a9d2d4d4209a13f8b8c4b390df8c77e0b578e34e39b6d16c73f4df629d1ff0936d730d13830960fd146a8874
7
- data.tar.gz: c8e86d4849d4f7ed2eb6af0674c39709695b2c10b1ff4abad333856c2f61c7b0357c2de4e90823eb385b64edc33c5a69faf04077ada9e4c9fece2b6005f70d44
6
+ metadata.gz: f6e9b53cec3cba4b2af9574f850eb1eda94064c3e5fcc0e73a58dd51270171639948987cd7b81c3f156cff4c676d06bbc557562e1f322f175fa10b99720bd41d
7
+ data.tar.gz: efb9fdc5fc2c6bb3f61f70ec6d4bf64cfc1bfe49c776099bd53198c78ab49a59315cafd304c0d35dfa5ab2985ccbc6785793cac120fc2da8b4376cf57e810004
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Mail::X::Smtpapi
2
2
 
3
- Integrates a custom X-SMTPAPI field into the [Mail](https://github.com/mikel/mail) gem.
3
+ Integrates support for SendGrid's X-SMTPAPI field into the [Mail](https://github.com/mikel/mail) gem.
4
+
5
+ Please refer to [SendGrid docs](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html) for ideas of what you can do with the X-SMTPAPI header!
4
6
 
5
7
  ## Installation
6
8
 
@@ -20,19 +22,51 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- Write into the SMTPAPI header from anywhere with access to the `mail` object.
25
+ Write into the X-SMTPAPI header from anywhere with access to the `mail` object.
24
26
 
25
27
  ### Example: Rails Mailer
26
28
 
27
- (TODO)
29
+ Adapting the [Rails Guide example](http://guides.rubyonrails.org/v4.0.8/action_mailer_basics.html#edit-the-mailer):
28
30
 
29
- ### Example: Template Helper
31
+ ```ruby
32
+ class UserMailer < ActionMailer::Base
33
+
34
+ def welcome(user)
35
+ @user = user
30
36
 
31
- (TODO)
37
+ mail.smtpapi.category = 'welcome'
38
+ mail.smtpapi.unique_args['user_id'] = @user.id
39
+
40
+ mail(to: @user.email, subject: 'Welcome to My Awesome Site')
41
+ end
42
+
43
+ end
44
+ ```
32
45
 
33
46
  ### Example: Mail Interceptor
34
47
 
35
- (TODO)
48
+ Adapting the [Rails Guide example](http://guides.rubyonrails.org/v4.0.8/action_mailer_basics.html#intercepting-emails):
49
+
50
+ ```ruby
51
+ class SandboxEmailInterceptor
52
+ def self.delivering_email(message)
53
+ message.smtpapi.unique_args['original'] = message.to
54
+ message.to = ['sandbox@example.com']
55
+ end
56
+ end
57
+ ```
58
+
59
+ ### Example: Template Helper
60
+
61
+ ```ruby
62
+ module MailerABHelper
63
+ def show_variant?(name)
64
+ variant = rand(2) == 0 ? 'main' : 'alternate'
65
+ mail.smtpapi.unique_args["#{name}_variant"] = variant
66
+ return variant == 'alternate'
67
+ end
68
+ end
69
+ ```
36
70
 
37
71
  ## Contributing
38
72
 
@@ -55,4 +55,10 @@ module MailXSMTPAPI
55
55
  end
56
56
  end
57
57
 
58
+ module Sections
59
+ def sections
60
+ value['sections'] ||= {}
61
+ end
62
+ end
63
+
58
64
  end
@@ -12,6 +12,7 @@ module MailXSMTPAPI
12
12
  include UniqueArguments
13
13
  include Category
14
14
  include Filters
15
+ include Sections
15
16
 
16
17
  def initialize(value = nil, charset = 'utf-8')
17
18
  self.charset = charset
@@ -27,8 +28,8 @@ module MailXSMTPAPI
27
28
  end
28
29
  end
29
30
 
30
- # to take advantage of folding, decoded must return a string with
31
- # emits JSON with extra spaces inserted for line wrapping.
31
+ # to take advantage of folding, decoded must return a string of
32
+ # JSON with extra spaces inserted for line wrapping.
32
33
  def decoded
33
34
  JSON.generate(value).gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module MailXSMTPAPI
2
- VERSION = '1.0.0.alpha2'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail-x_smtpapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lance Ivy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,9 +88,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ">"
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
- version: 1.3.1
93
+ version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
96
  rubygems_version: 2.2.2