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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dd6f9a2111c569b2e00393a14810d6135ea27af
4
- data.tar.gz: d4b5197e66c5257c2e5aff86ba48a5d400ed2d1b
3
+ metadata.gz: d9e9e521042a8bf3db008f622668562847b2ba2c
4
+ data.tar.gz: 0cc6c5805c2481df347ae0ba19e4d5ff62cb8a31
5
5
  SHA512:
6
- metadata.gz: 9cd77b0c7d80629b36b64dc67bea00d8979cbc8c24a79f33cc42d5353852618a0c1b74dae4a266fc4160d183e2b650432823dfa9ad015d055cfc32757b906a49
7
- data.tar.gz: 66bdf6b00ffbff2bcf928d6f7d1b9ac92114cdc4807ee83516d435f0496e36019b534a80c4da648f098551f83fffb0b10fab43f7dac989e622ad9c8c80787e1a
6
+ metadata.gz: 359a6138c45b2b09389cc8fa60838fa4158ac36da381b09e6b172fe7ee1e57f27dec7dbf73744220e4fc012c2e22762ef43e4bf0cf765973a4c72952baa0a6dc
7
+ data.tar.gz: d6ea909e2967eb27f41d77b43c7052bedbdf1508ef0ed62b0d53c9675f960a7dd5d3f8df8feacb158f299bc9935e60d06b5b9359cabb21c8d977bf14a5dcf076
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
- # SendableRails
2
- Short description and motivation.
1
+ # Sendable Rails ActionMailer Client
3
2
 
4
- ## Usage
5
- How to use my plugin.
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
- Contribution directions go here.
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
- template_id = params.delete(:template_id)
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
- assigns[name] = instance_variable_get(key)
10
+ data[name] = instance_variable_get(key)
13
11
  end
14
12
  end
15
13
 
16
- Sendable.client.email(template_id, params.merge(default_params).merge(assigns: assigns))
14
+ Sendable.client.email(params.merge(default_params).merge(data: data))
17
15
  end
18
16
  end
19
17
  end
@@ -1,3 +1,3 @@
1
1
  module SendableRails
2
- VERSION = '0.4.5'
2
+ VERSION = '0.5.0'
3
3
  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.5
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-25 00:00:00.000000000 Z
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.1.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.1.0
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement