sms_carrier 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +23 -21
- data/lib/sms_carrier/base.rb +1 -0
- data/lib/sms_carrier/sms.rb +1 -1
- data/lib/sms_carrier/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bea90caa9579c390186c64fd2dbd159b8c4bfd70
|
4
|
+
data.tar.gz: 2ee0fe5ef2db5c818c86d257c42ad9807d10609c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4946aa528cd57098b66e4752f816f4ed9301a3a5036869fbd03e00b63e6207abeabfa53cfdd78997812226f701899bd3af7febfea97fe792fdcff170db190ecb
|
7
|
+
data.tar.gz: 31813632c3f42980ca391daaee909ba77c1a3ce5427d4e79cf2b8924a15e42a4528cced415935661d98cb5a4758fe17cc68d6fe1cacd87419c5669b357ff323f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
[![Build Status](https://api.travis-ci.org/emn178/sms_carrier.png)](https://travis-ci.org/emn178/sms_carrier)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/emn178/sms_carrier/badge.svg?branch=master)](https://coveralls.io/r/emn178/sms_carrier?branch=master)
|
5
5
|
|
6
|
-
SMS Carrier is a framework for designing SMS service layers.
|
7
|
-
|
8
|
-
SMS Carrier is in essence a wrapper around Action Controller. It provides a way to make SMSes using templates in the same way that Action Controller renders views using templates.
|
6
|
+
SMS Carrier is a framework for designing SMS service layers. This is modified from Action Mailer of Rails framework, so the most of usage is just like Action Mailer.
|
9
7
|
|
10
8
|
## Installation
|
11
9
|
|
@@ -25,11 +23,9 @@ Or install it yourself as:
|
|
25
23
|
|
26
24
|
## Usage
|
27
25
|
### Sending SMSes
|
28
|
-
|
29
|
-
|
30
|
-
This can be as simple as:
|
26
|
+
You can use carrier and template to send SMSes.
|
31
27
|
```Ruby
|
32
|
-
class
|
28
|
+
class RegistrationCarrier < SmsCarrier::Base
|
33
29
|
default from: '+886987654321'
|
34
30
|
|
35
31
|
def welcome(recipient, token)
|
@@ -38,44 +34,50 @@ class Notifier < SmsCarrier::Base
|
|
38
34
|
end
|
39
35
|
end
|
40
36
|
```
|
41
|
-
|
42
|
-
|
43
|
-
So the corresponding body template for the method above could look like this:
|
37
|
+
In your view, eg. `app/views/registration_carrier/welcome.erb.html`
|
44
38
|
```
|
45
39
|
Your token is <%= @token %>, please confirm your phone number
|
46
40
|
```
|
47
|
-
|
41
|
+
|
42
|
+
If the token was given as `1234`, the SMS generated would look like this:
|
48
43
|
```
|
49
44
|
Your token is 1234, please confirm your phone number
|
50
45
|
```
|
46
|
+
|
51
47
|
In order to send SMSes, you simply call the method and then call deliver_now on the return value.
|
52
48
|
|
53
49
|
Calling the method returns a Sms object:
|
54
50
|
```Ruby
|
55
|
-
|
56
|
-
|
51
|
+
sms = RegistrationCarrier.welcome("+886912345678", "1234")
|
52
|
+
sms.deliver_now
|
57
53
|
```
|
58
54
|
Or you can just chain the methods together like:
|
59
55
|
```Ruby
|
60
|
-
|
56
|
+
RegistrationCarrier.welcome("+886912345678", "1234").deliver_now
|
61
57
|
```
|
58
|
+
|
62
59
|
Or you can send SMS without carrier and template:
|
63
60
|
```Ruby
|
64
|
-
SmsCarrier::Base.sms(from: "+886987654321", to: "+886912345678", body: "Your token is #{
|
61
|
+
SmsCarrier::Base.sms(from: "+886987654321", to: "+886912345678", body: "Your token is #{token}, please confirm your phone number").deliver_now
|
65
62
|
```
|
66
63
|
|
67
64
|
### Setting defaults
|
68
|
-
|
69
|
-
|
70
|
-
Note that every value you set with this method will get overwritten if you use the same key in your carrier method.
|
71
|
-
|
72
|
-
Example:
|
65
|
+
You can set up default settings in carrier by `default` method.
|
73
66
|
```Ruby
|
74
67
|
class AuthenticationCarrier < SmsCarrier::Base
|
75
68
|
default from: "+886987654321", body: Proc.new { "SMS was generated at #{Time.now}" }
|
76
|
-
.....
|
77
69
|
end
|
78
70
|
```
|
71
|
+
You can also set up in rails config, eg. `config/environments/production.rb`
|
72
|
+
```Ruby
|
73
|
+
config.sms_carrier.default_options = { from: "+886987654321" }
|
74
|
+
```
|
75
|
+
|
76
|
+
### Difference with Action Mailer
|
77
|
+
* SMS Carrier removed preview.
|
78
|
+
* SMS Carrier removed attachments feature.
|
79
|
+
* SMS Carrier removed multiple part rendering.
|
80
|
+
* SMS Carrier use `Hash` as options to replace the `Mail::Header` as headers in Action Mailer.
|
79
81
|
|
80
82
|
## License
|
81
83
|
|
data/lib/sms_carrier/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_support/core_ext/string/inflections'
|
2
2
|
require 'active_support/core_ext/hash/except'
|
3
3
|
require 'active_support/core_ext/module/anonymous'
|
4
|
+
require 'active_support/core_ext/hash/reverse_merge'
|
4
5
|
|
5
6
|
require 'sms_carrier/sms'
|
6
7
|
require 'sms_carrier/log_subscriber'
|
data/lib/sms_carrier/sms.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module SmsCarrier
|
2
2
|
class Sms
|
3
|
-
attr_accessor :body, :from, :
|
3
|
+
attr_accessor :body, :from, :options, :perform_deliveries, :raise_delivery_errors, :delivery_handler
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@options = {}
|
data/lib/sms_carrier/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms_carrier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chen Yi-Cyuan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|