sms_safe 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 995545e18c459164e07f01bd321450729f95dfe7
4
+ data.tar.gz: 631d83f2446e3736b1aadb0c9a78eaaea73b3738
5
+ SHA512:
6
+ metadata.gz: 2e3a1c3a4b4fbc0eb61da46600242b4eaf94b536c35fad468b9b750b937dbe77ab8117d474326fca45bbf01315d474f7de286953e58a0e86f61fd216f3bf98fc
7
+ data.tar.gz: ee2bd5071bc7684b0b794ff4b00785470aaf5e81db29b003fef34b6672ef4c3abab50d67ec284a98d909eb1c0e07b49f06ee729873f063e5b467e2c3b84ee456
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ .idea
3
+ *.gem
4
+ coverage
5
+ Gemfile.lock
6
+ .yardoc
7
+ doc
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - "2.1.1"
6
+ - "2.1.2"
7
+ - "2.1.3"
8
+ - "2.1.5"
9
+ # Test in all the platforms that "mail" (our main dependency) tests on
10
+
11
+ gemfile:
12
+ - gemfiles/mail_2_6_3.gemfile
13
+ - gemfiles/mail_2_6_1.gemfile
14
+ - gemfiles/mail_2_5_4.gemfile
15
+ - gemfiles/mail_2_5_3.gemfile
16
+ - gemfiles/mail_2_4_4.gemfile
17
+
18
+ script: bundle exec rake test_with_coveralls
@@ -0,0 +1,19 @@
1
+ appraise "mail-2-6-3" do
2
+ gem "mail", "2.6.3"
3
+ end
4
+
5
+ appraise "mail-2-6-1" do
6
+ gem "mail", "2.6.1"
7
+ end
8
+
9
+ appraise "mail-2-5-4" do
10
+ gem "mail", "2.5.4"
11
+ end
12
+
13
+ appraise "mail-2-5-3" do
14
+ gem "mail", "2.5.3"
15
+ end
16
+
17
+ appraise "mail-2-4-4" do
18
+ gem "mail", "2.4.4"
19
+ end
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sms_safe.gemspec
4
+ gemspec
5
+
6
+ gem 'action_texter', '0.2.0', :git => 'git://github.com/mstycom/action_texter.git'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014, Daniel Magliola
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,173 @@
1
+ # SmsSafe
2
+
3
+ [![Build Status](https://travis-ci.org/dmagliola/sms_safe.svg?branch=master)](https://travis-ci.org/dmagliola/sms_safe)
4
+ [![Coverage Status](https://coveralls.io/repos/dmagliola/sms_safe/badge.png?branch=master)](https://coveralls.io/r/dmagliola/sms_safe?branch=master)
5
+ [![Code Climate](https://codeclimate.com/github/dmagliola/sms_safe/badges/gpa.svg)](https://codeclimate.com/github/dmagliola/sms_safe)
6
+ [![Inline docs](http://inch-ci.org/github/dmagliola/sms_safe.svg?branch=master&style=flat)](http://inch-ci.org/github/dmagliola/sms_safe)
7
+ [![Gem Version](https://badge.fury.io/rb/sms_safe.png)](http://badge.fury.io/rb/sms_safe)
8
+ [![Dependency Status](https://gemnasium.com/dmagliola/sms_safe.svg)](https://gemnasium.com/dmagliola/sms_safe)
9
+
10
+
11
+ SMS safe provides a safety net while you're developing an application that sends SMS.
12
+ It keeps SMS messages from escaping into the wild.
13
+
14
+ Inspired by [MailSafe](https://rubygems.org/gems/mail_safe), it is essentially "MailSafe for SMS".
15
+
16
+ Once you've installed and configured this gem, you can rest assured that your app won't send
17
+ SMS messages to external phone numbers.
18
+
19
+ Messages going to your own, internal phone numbers will still go through normally, however, anything else will
20
+ either get sent to you instead (via SMS or Email), or discarded.
21
+
22
+ ## Download
23
+
24
+ Gem: `gem install sms_safe`
25
+
26
+ ## Installation
27
+
28
+ Load the gem in the appropriate environments in your GemFile. For example, I'm loading this in Gemfile as:
29
+
30
+ `gem "sms_safe", group: [:development, :staging]`
31
+
32
+ IMPORTANT: Be sure not to load this in your production environment, otherwise, your SMS won't be sent to the proper
33
+ recipients. In your test environment, you may or may not want this depending on how you are dealing with SMS right now.
34
+
35
+ We recommend using [ActionTexter](https://rubygems.org/gems/action_texter) to send your SMS, which already provides
36
+ for a very good way of switching SMS off in your test environment, while giving you testable objects that you can use
37
+ to check your logic.
38
+
39
+
40
+ ## Configuration
41
+
42
+ You should configure SmsSafe in the same initializer that you use for your SMS, so you can make sure that it runs
43
+ after your Texter gem has been configured.
44
+
45
+ ```
46
+ SmsSafe.configure do |config|
47
+ config.internal_phone_numbers = ['+12223334444', '+447111222222']
48
+ config.intercept_mechanism = :redirect
49
+ config.redirect_target = '+12223334444'
50
+ end
51
+
52
+ SmsSafe.hook!(:action_texter) # or :twilio or :nexmo
53
+
54
+ ```
55
+
56
+ Call hook! **after** setting the configuration for your texter gem.
57
+
58
+ The configuration specifies:
59
+
60
+ - **internal_phone_numbers:** SMS sent to these numbers will be sent normally. These can be specified
61
+ as a String, Regex, Proc, or an array of the same. Any phone number that doesn't match these is
62
+ considered external, and its SMS will get intercepted. If left empty, **all** SMS will be intercepted.
63
+ - **intercept_mechanism:** Whether to `:redirect` (default), `:email` or `:discard` the SMS sent to an external number.
64
+ - **redirect_target:** If `:redirect`ing, SMS will be sent to this number instead of the original recipient.
65
+ Can be a String or a Proc
66
+ - **email_target:** If `:email`ing, SMS will be sent as an e-mail to this e-mail address. Can be a String or a Proc
67
+ - **discard_delay:** [ms] If `:discard`ing, a delay this long will be introduced, for slightly more realistic
68
+ performance characteristics.
69
+
70
+
71
+ ## Interception mechanisms
72
+
73
+ When an SMS is being sent to a phone number that is not recognized as internal, it gets intercepted
74
+ and it will be processed according to the `intercept_mechanism` configured.
75
+
76
+ **IMPORTANT!**
77
+
78
+ If you choose to `:email` or `:discard` instead of `:redirect`ing, then when you send a message
79
+ the return value from your texter gem can be nil if the SMS does get intercepted.
80
+ You need to account for that, and consider it a successful send for your app logic.
81
+
82
+
83
+ ### Redirection
84
+
85
+ SMS will be sent anyway, but to the number specified by `redirect_target`.
86
+
87
+ A string "(SmsSafe: #{original_phone_number})" will be added, so you know it was meant for a different number.
88
+
89
+ ### Emailing
90
+
91
+ Instead of sending the SMS, an e-mail will be sent to the address specified by `email_target`, describing all the information about the SMS.
92
+ This is useful in dev / staging as a less annoying alternative to SMS'ing yourself, and also
93
+ for teams, since multiple people may end up having access to the e-mail, as opposed to an SMS.
94
+
95
+ ### Discarding
96
+
97
+ In some cases, you just don't care, you simply don't want to be notified. This is particularly useful
98
+ if you are doing load testing / stress testing, where millions of SMS / emails might end up being sent to you.
99
+
100
+ For this scenario, we include the `discard_delay` setting, which will make the "sending" take longer
101
+ than a simple discard. You should set this to an average value that your SMS provider exhibits. This way,
102
+ even if you are queueing SMS sending using Resque / DelayedJob, you can still check that, when dealing with
103
+ a real load, your queue workers can keep up with the demand.
104
+
105
+
106
+ ## Supported Libraries
107
+
108
+ SmsSafe can currently hook into the following texter gems:
109
+
110
+ - **[ActionTexter](https://rubygems.org/gems/action_texter)**
111
+ - [Nexmo](https://rubygems.org/gems/nexmo)
112
+ - [Twilio Ruby](https://rubygems.org/gems/twilio-ruby)
113
+
114
+ Of these 3, ActionTexter is the only one that provides useful functionality for automated testing,
115
+ and functionality for interceptors / observers. It also works natively with both Twilio and Nexmo,
116
+ so we recommend it extensively.
117
+
118
+ For Nexmo and Twilio Ruby, unfortunately, the way we hook is by monkey-patching them. This works,
119
+ but it's not ideal, so we recommend using ActionTexter if you can.
120
+
121
+ If you would like the SmsSafe functionality but you use another SMS provider / gem, you can add the new provider
122
+ and submit a Pull Request (see bottom of README), add the new provider to [ActionTexter](https://github.com/watu/action_texter),
123
+ or just ask, I'd like to extend this gem as much as possible.
124
+
125
+
126
+ ## Version Compatibility and Continuous Integration
127
+
128
+ Tested with [Travis](https://travis-ci.org/dmagliola/sms_safe) using Ruby 1.9.3, 2.0, 2.1.1, 2.1.2, 2.1.3 and 2.1.5,
129
+ and against mail 2.6.3, 2.6.1, 2.5.4, 2.5.3 and 2.4.4.
130
+
131
+ To locally run tests do:
132
+
133
+ ````
134
+ appraisal rake test
135
+ ```
136
+
137
+ ## Copyright
138
+
139
+ Copyright (c) 2014, 2015, Daniel Magliola
140
+
141
+ See LICENSE for details.
142
+
143
+
144
+ ## Users
145
+
146
+ This gem is being used by:
147
+
148
+ - [MSTY](https://www.msty.com)
149
+ - You? please, let us know if you are using this gem.
150
+
151
+
152
+ ## Changelog
153
+
154
+ ### Version 1.0.0 (Jan 2nd, 2015)
155
+ - Newly released gem, supports ActionTexter, Nexmo and Twilio.
156
+ - Still waiting to make sure Mail configuration works transparently for both Mail and ActionMailer.
157
+ - Also waiting to figure out how to get Coveralls to recognize the true coverage (aka 100%)
158
+
159
+
160
+ ## Contributing
161
+
162
+ 1. Fork it
163
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
164
+ 1. Code your thing
165
+ 1. Write and run tests:
166
+ bundle install
167
+ appraisal
168
+ appraisal rake test
169
+ 1. Write documentation and make sure it looks good: yard server --reload
170
+ 1. Add items to the changelog, in README.
171
+ 1. Commit your changes (`git commit -am "Add some feature"`)
172
+ 1. Push to the branch (`git push origin my-new-feature`)
173
+ 1. Create new Pull Request
@@ -0,0 +1,15 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rake/testtask"
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "lib"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ end
10
+
11
+ task :default => :test
12
+
13
+ require 'coveralls/rake/task'
14
+ Coveralls::RakeTask.new
15
+ task :test_with_coveralls => ["test", "coveralls:push"]
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "action_texter", "0.2.0", :git => "git://github.com/mstycom/action_texter.git"
6
+ gem "mail", "2.4.4"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,107 @@
1
+ GIT
2
+ remote: git://github.com/mstycom/action_texter.git
3
+ revision: 75dea6a6dffe3e69082f1e2b50403f0e6c567119
4
+ specs:
5
+ action_texter (0.2.0)
6
+
7
+ PATH
8
+ remote: ../
9
+ specs:
10
+ sms_safe (0.1.0)
11
+ mail (>= 2.4)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ activesupport (4.2.0)
17
+ i18n (~> 0.7)
18
+ json (~> 1.7, >= 1.7.7)
19
+ minitest (~> 5.1)
20
+ thread_safe (~> 0.3, >= 0.3.4)
21
+ tzinfo (~> 1.1)
22
+ ansi (1.4.3)
23
+ appraisal (1.0.2)
24
+ bundler
25
+ rake
26
+ thor (>= 0.14.0)
27
+ builder (3.2.2)
28
+ codeclimate-test-reporter (0.4.3)
29
+ simplecov (>= 0.7.1, < 1.0.0)
30
+ coveralls (0.7.1)
31
+ multi_json (~> 1.3)
32
+ rest-client
33
+ simplecov (>= 0.7)
34
+ term-ansicolor
35
+ thor
36
+ docile (1.1.5)
37
+ i18n (0.7.0)
38
+ json (1.8.1)
39
+ jwt (1.0.0)
40
+ mail (2.4.4)
41
+ i18n (>= 0.4.0)
42
+ mime-types (~> 1.16)
43
+ treetop (~> 1.4.8)
44
+ metaclass (0.0.4)
45
+ mime-types (1.25.1)
46
+ minitest (5.5.0)
47
+ minitest-reporters (1.0.8)
48
+ ansi
49
+ builder
50
+ minitest (>= 5.0)
51
+ ruby-progressbar
52
+ mocha (1.1.0)
53
+ metaclass (~> 0.0.1)
54
+ multi_json (1.10.1)
55
+ netrc (0.10.2)
56
+ nexmo (2.0.0)
57
+ polyglot (0.3.5)
58
+ rake (10.4.2)
59
+ rest-client (1.7.2)
60
+ mime-types (>= 1.16, < 3.0)
61
+ netrc (~> 0.7)
62
+ ruby-progressbar (1.7.1)
63
+ shoulda (3.5.0)
64
+ shoulda-context (~> 1.0, >= 1.0.1)
65
+ shoulda-matchers (>= 1.4.1, < 3.0)
66
+ shoulda-context (1.2.1)
67
+ shoulda-matchers (2.7.0)
68
+ activesupport (>= 3.0.0)
69
+ simplecov (0.9.1)
70
+ docile (~> 1.1.0)
71
+ multi_json (~> 1.0)
72
+ simplecov-html (~> 0.8.0)
73
+ simplecov-html (0.8.0)
74
+ term-ansicolor (1.3.0)
75
+ tins (~> 1.0)
76
+ thor (0.19.1)
77
+ thread_safe (0.3.4)
78
+ tins (1.3.3)
79
+ treetop (1.4.15)
80
+ polyglot
81
+ polyglot (>= 0.3.1)
82
+ twilio-ruby (3.14.2)
83
+ builder (>= 2.1.2)
84
+ jwt (~> 1.0.0)
85
+ multi_json (>= 1.3.0)
86
+ tzinfo (1.2.2)
87
+ thread_safe (~> 0.1)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ action_texter (= 0.2.0)!
94
+ appraisal
95
+ bundler
96
+ codeclimate-test-reporter
97
+ coveralls
98
+ mail (= 2.4.4)
99
+ minitest
100
+ minitest-reporters
101
+ mocha
102
+ nexmo
103
+ rake
104
+ shoulda
105
+ simplecov
106
+ sms_safe!
107
+ twilio-ruby
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "action_texter", "0.2.0", :git => "git://github.com/mstycom/action_texter.git"
6
+ gem "mail", "2.5.3"
7
+
8
+ gemspec :path => "../"
@@ -0,0 +1,107 @@
1
+ GIT
2
+ remote: git://github.com/mstycom/action_texter.git
3
+ revision: 75dea6a6dffe3e69082f1e2b50403f0e6c567119
4
+ specs:
5
+ action_texter (0.2.0)
6
+
7
+ PATH
8
+ remote: ../
9
+ specs:
10
+ sms_safe (0.1.0)
11
+ mail (>= 2.4)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ activesupport (4.2.0)
17
+ i18n (~> 0.7)
18
+ json (~> 1.7, >= 1.7.7)
19
+ minitest (~> 5.1)
20
+ thread_safe (~> 0.3, >= 0.3.4)
21
+ tzinfo (~> 1.1)
22
+ ansi (1.4.3)
23
+ appraisal (1.0.2)
24
+ bundler
25
+ rake
26
+ thor (>= 0.14.0)
27
+ builder (3.2.2)
28
+ codeclimate-test-reporter (0.4.3)
29
+ simplecov (>= 0.7.1, < 1.0.0)
30
+ coveralls (0.7.1)
31
+ multi_json (~> 1.3)
32
+ rest-client
33
+ simplecov (>= 0.7)
34
+ term-ansicolor
35
+ thor
36
+ docile (1.1.5)
37
+ i18n (0.7.0)
38
+ json (1.8.1)
39
+ jwt (1.0.0)
40
+ mail (2.5.3)
41
+ i18n (>= 0.4.0)
42
+ mime-types (~> 1.16)
43
+ treetop (~> 1.4.8)
44
+ metaclass (0.0.4)
45
+ mime-types (1.25.1)
46
+ minitest (5.5.0)
47
+ minitest-reporters (1.0.8)
48
+ ansi
49
+ builder
50
+ minitest (>= 5.0)
51
+ ruby-progressbar
52
+ mocha (1.1.0)
53
+ metaclass (~> 0.0.1)
54
+ multi_json (1.10.1)
55
+ netrc (0.10.2)
56
+ nexmo (2.0.0)
57
+ polyglot (0.3.5)
58
+ rake (10.4.2)
59
+ rest-client (1.7.2)
60
+ mime-types (>= 1.16, < 3.0)
61
+ netrc (~> 0.7)
62
+ ruby-progressbar (1.7.1)
63
+ shoulda (3.5.0)
64
+ shoulda-context (~> 1.0, >= 1.0.1)
65
+ shoulda-matchers (>= 1.4.1, < 3.0)
66
+ shoulda-context (1.2.1)
67
+ shoulda-matchers (2.7.0)
68
+ activesupport (>= 3.0.0)
69
+ simplecov (0.9.1)
70
+ docile (~> 1.1.0)
71
+ multi_json (~> 1.0)
72
+ simplecov-html (~> 0.8.0)
73
+ simplecov-html (0.8.0)
74
+ term-ansicolor (1.3.0)
75
+ tins (~> 1.0)
76
+ thor (0.19.1)
77
+ thread_safe (0.3.4)
78
+ tins (1.3.3)
79
+ treetop (1.4.15)
80
+ polyglot
81
+ polyglot (>= 0.3.1)
82
+ twilio-ruby (3.14.2)
83
+ builder (>= 2.1.2)
84
+ jwt (~> 1.0.0)
85
+ multi_json (>= 1.3.0)
86
+ tzinfo (1.2.2)
87
+ thread_safe (~> 0.1)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ action_texter (= 0.2.0)!
94
+ appraisal
95
+ bundler
96
+ codeclimate-test-reporter
97
+ coveralls
98
+ mail (= 2.5.3)
99
+ minitest
100
+ minitest-reporters
101
+ mocha
102
+ nexmo
103
+ rake
104
+ shoulda
105
+ simplecov
106
+ sms_safe!
107
+ twilio-ruby