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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8856860fad36aa1fa2eef28c277106e3c3e8a361
4
- data.tar.gz: 261bcc32724a7d9c75eae9217208800a1117881f
3
+ metadata.gz: bea90caa9579c390186c64fd2dbd159b8c4bfd70
4
+ data.tar.gz: 2ee0fe5ef2db5c818c86d257c42ad9807d10609c
5
5
  SHA512:
6
- metadata.gz: 0f5dccb9d50b80a849099fb1df1dc732ae78a6ca50c4d7e750e725472ef1debe2b149845b8cd46e78d881b017473df20445e8d9979d35fe4910e017d81ec39d5
7
- data.tar.gz: 0a144ff33491e6ae9bd781010eacb4cbf76e347b670a886b5c9102e5dd755b8c31a3365ccef590b1f925378bae702129e3970ae112fb669350afdfcb8da85363
6
+ metadata.gz: 4946aa528cd57098b66e4752f816f4ed9301a3a5036869fbd03e00b63e6207abeabfa53cfdd78997812226f701899bd3af7febfea97fe792fdcff170db190ecb
7
+ data.tar.gz: 31813632c3f42980ca391daaee909ba77c1a3ce5427d4e79cf2b8924a15e42a4528cced415935661d98cb5a4758fe17cc68d6fe1cacd87419c5669b357ff323f
@@ -1,3 +1,7 @@
1
+ # v0.1.1 / 2015-10-26
2
+
3
+ * Fixed warning and add require file.
4
+
1
5
  # v0.1.0 / 2015-10-23
2
6
 
3
7
  Create project
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. These layers are used to consolidate code for sending out confirmation token, and any other use case that requires a written notification to either a person or another system.
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
- The framework works by initializing any instance variables you want to be available in the SMS template, followed by a call to sms to deliver the SMS.
29
-
30
- This can be as simple as:
26
+ You can use carrier and template to send SMSes.
31
27
  ```Ruby
32
- class Notifier < SmsCarrier::Base
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
- The body of the SMS is created by using an Action View template (regular ERB) that has the instance variables that are declared in the carrier action.
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
- If the token was given as “1234”, the SMS generated would look like this:
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
- message = Notifier.welcome("1234") # => Returns a SmsCarrier::Sms object
56
- message.deliver_now # => delivers the SMS
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
- Notifier.welcome("1234").deliver_now # Creates the SMS and sends it immediately
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 #{@token}").deliver_now
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
- It is possible to set default values that will be used in every method in your SMS Carrier class. To implement this functionality, you just call the public class method default which you get for free from SmsCarrier::Base. This method accepts a Hash as the parameter. You can use any of the options, SMS messages have, like :from as the key. You can also pass in a string as the key, like “Content-Type”, but SMS Carrier does this out of the box for you, so you won't need to worry about that. Finally, it is also possible to pass in a Proc that will get evaluated when it is needed.
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
 
@@ -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'
@@ -1,6 +1,6 @@
1
1
  module SmsCarrier
2
2
  class Sms
3
- attr_accessor :body, :from, :to, :options, :perform_deliveries, :raise_delivery_errors, :delivery_handler
3
+ attr_accessor :body, :from, :options, :perform_deliveries, :raise_delivery_errors, :delivery_handler
4
4
 
5
5
  def initialize
6
6
  @options = {}
@@ -1,3 +1,3 @@
1
1
  module SmsCarrier
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-23 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack