sendable_rails 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +67 -5
- data/lib/sendable_rails/action_mailer_ext.rb +3 -5
- data/lib/sendable_rails/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9e9e521042a8bf3db008f622668562847b2ba2c
|
4
|
+
data.tar.gz: 0cc6c5805c2481df347ae0ba19e4d5ff62cb8a31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359a6138c45b2b09389cc8fa60838fa4158ac36da381b09e6b172fe7ee1e57f27dec7dbf73744220e4fc012c2e22762ef43e4bf0cf765973a4c72952baa0a6dc
|
7
|
+
data.tar.gz: d6ea909e2967eb27f41d77b43c7052bedbdf1508ef0ed62b0d53c9675f960a7dd5d3f8df8feacb158f299bc9935e60d06b5b9359cabb21c8d977bf14a5dcf076
|
data/README.md
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
#
|
2
|
-
Short description and motivation.
|
1
|
+
# Sendable Rails ActionMailer Client
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
[Sendable](https://sendable.io) is a service that makes it simpler to design, manage and optimize your Transactional Emails. Sendable has created a Ruby gem `sendable` that communicates with our REST API for sending your transactional emails.
|
4
|
+
|
5
|
+
Ruby on Rails developers use the ActionMailer interface for sending emails. This gem, `sendable_rails` implements a small layer over the `sendable` gem that provides an API similar to ActionMailer.
|
6
6
|
|
7
7
|
## Installation
|
8
|
+
|
8
9
|
Add this line to your application's Gemfile:
|
9
10
|
|
10
11
|
```ruby
|
@@ -20,9 +21,70 @@ Or install it yourself as:
|
|
20
21
|
```bash
|
21
22
|
$ gem install sendable_rails
|
22
23
|
```
|
24
|
+
## Setup
|
25
|
+
|
26
|
+
There are 2 ways to set up Sendable. You can either set the API key in an environment variable, or pass it in an initializer.
|
27
|
+
|
28
|
+
### Option 1 - Environment Variable
|
29
|
+
|
30
|
+
Add the following environment variable to your application. You can get your API key from the settings page of your Sendable project dashboard.
|
31
|
+
|
32
|
+
`SENDABLE_API_KEY`=`YOUR API KEY`
|
33
|
+
|
34
|
+
### Option 2 - Initializer
|
35
|
+
|
36
|
+
If you don't want to set an environment variable, create a file `config/initializers/sendable.rb` and put this in there:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Sendable.config do |config|
|
40
|
+
config.api_key = 'YOUR API KEY'
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
The only changes required in your existing `mail` method are:
|
47
|
+
|
48
|
+
- Replace `mail` with `sendable_mail`
|
49
|
+
- Pass a `template` key that you can get from your Sendable project dashboard
|
50
|
+
- Instance variables will be available in your templates as `mustache` attributes
|
51
|
+
|
52
|
+
Everything else will work as expected. Here is a before and after comparison:
|
53
|
+
|
54
|
+
### Before (Without Sendable)
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
class UserMailer < ActionMailer::Base
|
58
|
+
default from: 'no-reply@example.com'
|
59
|
+
|
60
|
+
def welcome(user)
|
61
|
+
@user = user
|
62
|
+
mail( to: @user.email, subject: "Welcome to My Awesome Site!" )
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
### After (Using Sendable)
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
class UserMailer < ActionMailer::Base
|
72
|
+
default from: 'no-reply@example.com'
|
73
|
+
|
74
|
+
def welcome(user)
|
75
|
+
@user = user
|
76
|
+
sendable_mail to: @user.email, template: 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
23
80
|
|
24
81
|
## Contributing
|
25
|
-
|
82
|
+
|
83
|
+
1. Fork it
|
84
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
85
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
87
|
+
5. Create new Pull Request
|
26
88
|
|
27
89
|
## License
|
28
90
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -3,17 +3,15 @@ require 'sendable'
|
|
3
3
|
module SendableRails
|
4
4
|
module ActionMailerWithSendable
|
5
5
|
def sendable_mail(params = {})
|
6
|
-
|
7
|
-
|
8
|
-
assigns = {}
|
6
|
+
data = {}
|
9
7
|
instance_variables.each do |key|
|
10
8
|
if key[0..1] != '@_'
|
11
9
|
name = key[1..-1]
|
12
|
-
|
10
|
+
data[name] = instance_variable_get(key)
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
Sendable.client.email(
|
14
|
+
Sendable.client.email(params.merge(default_params).merge(data: data))
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendable_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umair Siddique
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sendable
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|