sms_safe 1.0.0 → 1.0.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: 995545e18c459164e07f01bd321450729f95dfe7
4
- data.tar.gz: 631d83f2446e3736b1aadb0c9a78eaaea73b3738
3
+ metadata.gz: 8f4a3822f12f7a4fd73e6a1863f8908beeb8d48e
4
+ data.tar.gz: 626f0e5724741f6a52d00b943430457ef115ae6d
5
5
  SHA512:
6
- metadata.gz: 2e3a1c3a4b4fbc0eb61da46600242b4eaf94b536c35fad468b9b750b937dbe77ab8117d474326fca45bbf01315d474f7de286953e58a0e86f61fd216f3bf98fc
7
- data.tar.gz: ee2bd5071bc7684b0b794ff4b00785470aaf5e81db29b003fef34b6672ef4c3abab50d67ec284a98d909eb1c0e07b49f06ee729873f063e5b467e2c3b84ee456
6
+ metadata.gz: dc8fe5e5674322da1829c34c625afe6ae1d45652a460661b9059b713c7622847e1f235c466db9c7e28207eb61eff18eae5dfc71843e6f69837f2a98a50e5f4c6
7
+ data.tar.gz: 55896810f5b6f6bd710bfb547940adee307a9342c70bcccb0b0c15be83cb4e024f506cbeb67ef64c7cfce3d4e9b9abef2b0e6e0ff902ae88388ba15260c3368b
data/Appraisals CHANGED
@@ -11,9 +11,13 @@ appraise "mail-2-5-4" do
11
11
  end
12
12
 
13
13
  appraise "mail-2-5-3" do
14
+ gem "activesupport", "3.2.13"
15
+ gem "actionmailer", "3.2.13"
14
16
  gem "mail", "2.5.3"
15
17
  end
16
18
 
17
19
  appraise "mail-2-4-4" do
20
+ gem "activesupport", "3.1.12"
21
+ gem "actionmailer", "3.1.12"
18
22
  gem "mail", "2.4.4"
19
23
  end
data/README.md CHANGED
@@ -92,6 +92,9 @@ Instead of sending the SMS, an e-mail will be sent to the address specified by `
92
92
  This is useful in dev / staging as a less annoying alternative to SMS'ing yourself, and also
93
93
  for teams, since multiple people may end up having access to the e-mail, as opposed to an SMS.
94
94
 
95
+ You don't need to add any configuration for e-mailing to work. If you use Mail or ActionMailer, SmsSafe will
96
+ magically use the configuration you set up for either.
97
+
95
98
  ### Discarding
96
99
 
97
100
  In some cases, you just don't care, you simply don't want to be notified. This is particularly useful
@@ -151,6 +154,9 @@ This gem is being used by:
151
154
 
152
155
  ## Changelog
153
156
 
157
+ ### Version 1.0.1 (Jan 2nd, 2015)
158
+ - Made emails work automagically with either Mail or ActionMailer
159
+
154
160
  ### Version 1.0.0 (Jan 2nd, 2015)
155
161
  - Newly released gem, supports ActionTexter, Nexmo and Twilio.
156
162
  - Still waiting to make sure Mail configuration works transparently for both Mail and ActionMailer.
@@ -3,6 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "action_texter", "0.2.0", :git => "git://github.com/mstycom/action_texter.git"
6
+ gem "activesupport", "3.1.12"
7
+ gem "actionmailer", "3.1.12"
6
8
  gem "mail", "2.4.4"
7
9
 
8
10
  gemspec :path => "../"
@@ -1,31 +1,45 @@
1
1
  GIT
2
2
  remote: git://github.com/mstycom/action_texter.git
3
- revision: 75dea6a6dffe3e69082f1e2b50403f0e6c567119
3
+ revision: f9126d9755bcbb13fe09a5449417390bbda82c8f
4
4
  specs:
5
5
  action_texter (0.2.0)
6
6
 
7
7
  PATH
8
8
  remote: ../
9
9
  specs:
10
- sms_safe (0.1.0)
10
+ sms_safe (1.0.1)
11
11
  mail (>= 2.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
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)
16
+ actionmailer (3.1.12)
17
+ actionpack (= 3.1.12)
18
+ mail (~> 2.4.4)
19
+ actionpack (3.1.12)
20
+ activemodel (= 3.1.12)
21
+ activesupport (= 3.1.12)
22
+ builder (~> 3.0.0)
23
+ erubis (~> 2.7.0)
24
+ i18n (~> 0.6)
25
+ rack (~> 1.3.6)
26
+ rack-cache (~> 1.2)
27
+ rack-mount (~> 0.8.2)
28
+ rack-test (~> 0.6.1)
29
+ sprockets (~> 2.0.4)
30
+ activemodel (3.1.12)
31
+ activesupport (= 3.1.12)
32
+ builder (~> 3.0.0)
33
+ i18n (~> 0.6)
34
+ activesupport (3.1.12)
35
+ multi_json (~> 1.0)
22
36
  ansi (1.4.3)
23
37
  appraisal (1.0.2)
24
38
  bundler
25
39
  rake
26
40
  thor (>= 0.14.0)
27
- builder (3.2.2)
28
- codeclimate-test-reporter (0.4.3)
41
+ builder (3.0.4)
42
+ codeclimate-test-reporter (0.4.4)
29
43
  simplecov (>= 0.7.1, < 1.0.0)
30
44
  coveralls (0.7.1)
31
45
  multi_json (~> 1.3)
@@ -34,8 +48,9 @@ GEM
34
48
  term-ansicolor
35
49
  thor
36
50
  docile (1.1.5)
51
+ erubis (2.7.0)
52
+ hike (1.2.3)
37
53
  i18n (0.7.0)
38
- json (1.8.1)
39
54
  jwt (1.0.0)
40
55
  mail (2.4.4)
41
56
  i18n (>= 0.4.0)
@@ -55,6 +70,13 @@ GEM
55
70
  netrc (0.10.2)
56
71
  nexmo (2.0.0)
57
72
  polyglot (0.3.5)
73
+ rack (1.3.10)
74
+ rack-cache (1.2)
75
+ rack (>= 0.4)
76
+ rack-mount (0.8.3)
77
+ rack (>= 1.0.0)
78
+ rack-test (0.6.2)
79
+ rack (>= 1.0)
58
80
  rake (10.4.2)
59
81
  rest-client (1.7.2)
60
82
  mime-types (>= 1.16, < 3.0)
@@ -71,10 +93,14 @@ GEM
71
93
  multi_json (~> 1.0)
72
94
  simplecov-html (~> 0.8.0)
73
95
  simplecov-html (0.8.0)
96
+ sprockets (2.0.5)
97
+ hike (~> 1.2)
98
+ rack (~> 1.0)
99
+ tilt (~> 1.1, != 1.3.0)
74
100
  term-ansicolor (1.3.0)
75
101
  tins (~> 1.0)
76
102
  thor (0.19.1)
77
- thread_safe (0.3.4)
103
+ tilt (1.4.1)
78
104
  tins (1.3.3)
79
105
  treetop (1.4.15)
80
106
  polyglot
@@ -83,14 +109,14 @@ GEM
83
109
  builder (>= 2.1.2)
84
110
  jwt (~> 1.0.0)
85
111
  multi_json (>= 1.3.0)
86
- tzinfo (1.2.2)
87
- thread_safe (~> 0.1)
88
112
 
89
113
  PLATFORMS
90
114
  ruby
91
115
 
92
116
  DEPENDENCIES
93
117
  action_texter (= 0.2.0)!
118
+ actionmailer (= 3.1.12)
119
+ activesupport (= 3.1.12)
94
120
  appraisal
95
121
  bundler
96
122
  codeclimate-test-reporter
@@ -3,6 +3,8 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "action_texter", "0.2.0", :git => "git://github.com/mstycom/action_texter.git"
6
+ gem "activesupport", "3.2.13"
7
+ gem "actionmailer", "3.2.13"
6
8
  gem "mail", "2.5.3"
7
9
 
8
10
  gemspec :path => "../"
@@ -1,31 +1,44 @@
1
1
  GIT
2
2
  remote: git://github.com/mstycom/action_texter.git
3
- revision: 75dea6a6dffe3e69082f1e2b50403f0e6c567119
3
+ revision: f9126d9755bcbb13fe09a5449417390bbda82c8f
4
4
  specs:
5
5
  action_texter (0.2.0)
6
6
 
7
7
  PATH
8
8
  remote: ../
9
9
  specs:
10
- sms_safe (0.1.0)
10
+ sms_safe (1.0.1)
11
11
  mail (>= 2.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
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)
16
+ actionmailer (3.2.13)
17
+ actionpack (= 3.2.13)
18
+ mail (~> 2.5.3)
19
+ actionpack (3.2.13)
20
+ activemodel (= 3.2.13)
21
+ activesupport (= 3.2.13)
22
+ builder (~> 3.0.0)
23
+ erubis (~> 2.7.0)
24
+ journey (~> 1.0.4)
25
+ rack (~> 1.4.5)
26
+ rack-cache (~> 1.2)
27
+ rack-test (~> 0.6.1)
28
+ sprockets (~> 2.2.1)
29
+ activemodel (3.2.13)
30
+ activesupport (= 3.2.13)
31
+ builder (~> 3.0.0)
32
+ activesupport (3.2.13)
33
+ i18n (= 0.6.1)
34
+ multi_json (~> 1.0)
22
35
  ansi (1.4.3)
23
36
  appraisal (1.0.2)
24
37
  bundler
25
38
  rake
26
39
  thor (>= 0.14.0)
27
- builder (3.2.2)
28
- codeclimate-test-reporter (0.4.3)
40
+ builder (3.0.4)
41
+ codeclimate-test-reporter (0.4.4)
29
42
  simplecov (>= 0.7.1, < 1.0.0)
30
43
  coveralls (0.7.1)
31
44
  multi_json (~> 1.3)
@@ -34,8 +47,10 @@ GEM
34
47
  term-ansicolor
35
48
  thor
36
49
  docile (1.1.5)
37
- i18n (0.7.0)
38
- json (1.8.1)
50
+ erubis (2.7.0)
51
+ hike (1.2.3)
52
+ i18n (0.6.1)
53
+ journey (1.0.4)
39
54
  jwt (1.0.0)
40
55
  mail (2.5.3)
41
56
  i18n (>= 0.4.0)
@@ -55,6 +70,11 @@ GEM
55
70
  netrc (0.10.2)
56
71
  nexmo (2.0.0)
57
72
  polyglot (0.3.5)
73
+ rack (1.4.5)
74
+ rack-cache (1.2)
75
+ rack (>= 0.4)
76
+ rack-test (0.6.2)
77
+ rack (>= 1.0)
58
78
  rake (10.4.2)
59
79
  rest-client (1.7.2)
60
80
  mime-types (>= 1.16, < 3.0)
@@ -71,10 +91,15 @@ GEM
71
91
  multi_json (~> 1.0)
72
92
  simplecov-html (~> 0.8.0)
73
93
  simplecov-html (0.8.0)
94
+ sprockets (2.2.3)
95
+ hike (~> 1.2)
96
+ multi_json (~> 1.0)
97
+ rack (~> 1.0)
98
+ tilt (~> 1.1, != 1.3.0)
74
99
  term-ansicolor (1.3.0)
75
100
  tins (~> 1.0)
76
101
  thor (0.19.1)
77
- thread_safe (0.3.4)
102
+ tilt (1.4.1)
78
103
  tins (1.3.3)
79
104
  treetop (1.4.15)
80
105
  polyglot
@@ -83,14 +108,14 @@ GEM
83
108
  builder (>= 2.1.2)
84
109
  jwt (~> 1.0.0)
85
110
  multi_json (>= 1.3.0)
86
- tzinfo (1.2.2)
87
- thread_safe (~> 0.1)
88
111
 
89
112
  PLATFORMS
90
113
  ruby
91
114
 
92
115
  DEPENDENCIES
93
116
  action_texter (= 0.2.0)!
117
+ actionmailer (= 3.2.13)
118
+ activesupport (= 3.2.13)
94
119
  appraisal
95
120
  bundler
96
121
  codeclimate-test-reporter
@@ -7,12 +7,34 @@ GIT
7
7
  PATH
8
8
  remote: ../
9
9
  specs:
10
- sms_safe (0.1.0)
10
+ sms_safe (1.0.1)
11
11
  mail (>= 2.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
+ actionmailer (4.2.0)
17
+ actionpack (= 4.2.0)
18
+ actionview (= 4.2.0)
19
+ activejob (= 4.2.0)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ actionpack (4.2.0)
23
+ actionview (= 4.2.0)
24
+ activesupport (= 4.2.0)
25
+ rack (~> 1.6.0)
26
+ rack-test (~> 0.6.2)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
29
+ actionview (4.2.0)
30
+ activesupport (= 4.2.0)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
35
+ activejob (4.2.0)
36
+ activesupport (= 4.2.0)
37
+ globalid (>= 0.3.0)
16
38
  activesupport (4.2.0)
17
39
  i18n (~> 0.7)
18
40
  json (~> 1.7, >= 1.7.7)
@@ -34,14 +56,20 @@ GEM
34
56
  term-ansicolor
35
57
  thor
36
58
  docile (1.1.5)
59
+ erubis (2.7.0)
60
+ globalid (0.3.0)
61
+ activesupport (>= 4.1.0)
37
62
  i18n (0.7.0)
38
63
  json (1.8.1)
39
64
  jwt (1.0.0)
65
+ loofah (2.0.1)
66
+ nokogiri (>= 1.5.9)
40
67
  mail (2.5.4)
41
68
  mime-types (~> 1.16)
42
69
  treetop (~> 1.4.8)
43
70
  metaclass (0.0.4)
44
71
  mime-types (1.25.1)
72
+ mini_portile (0.6.2)
45
73
  minitest (5.5.0)
46
74
  minitest-reporters (1.0.8)
47
75
  ansi
@@ -53,7 +81,20 @@ GEM
53
81
  multi_json (1.10.1)
54
82
  netrc (0.10.2)
55
83
  nexmo (2.0.0)
84
+ nokogiri (1.6.5)
85
+ mini_portile (~> 0.6.0)
56
86
  polyglot (0.3.5)
87
+ rack (1.6.0)
88
+ rack-test (0.6.2)
89
+ rack (>= 1.0)
90
+ rails-deprecated_sanitizer (1.0.3)
91
+ activesupport (>= 4.2.0.alpha)
92
+ rails-dom-testing (1.0.5)
93
+ activesupport (>= 4.2.0.beta, < 5.0)
94
+ nokogiri (~> 1.6.0)
95
+ rails-deprecated_sanitizer (>= 1.0.1)
96
+ rails-html-sanitizer (1.0.1)
97
+ loofah (~> 2.0)
57
98
  rake (10.4.2)
58
99
  rest-client (1.7.2)
59
100
  mime-types (>= 1.16, < 3.0)
@@ -90,6 +131,7 @@ PLATFORMS
90
131
 
91
132
  DEPENDENCIES
92
133
  action_texter (= 0.2.0)!
134
+ actionmailer
93
135
  appraisal
94
136
  bundler
95
137
  codeclimate-test-reporter
@@ -7,12 +7,34 @@ GIT
7
7
  PATH
8
8
  remote: ../
9
9
  specs:
10
- sms_safe (0.1.0)
10
+ sms_safe (1.0.1)
11
11
  mail (>= 2.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
+ actionmailer (4.2.0)
17
+ actionpack (= 4.2.0)
18
+ actionview (= 4.2.0)
19
+ activejob (= 4.2.0)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ actionpack (4.2.0)
23
+ actionview (= 4.2.0)
24
+ activesupport (= 4.2.0)
25
+ rack (~> 1.6.0)
26
+ rack-test (~> 0.6.2)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
29
+ actionview (4.2.0)
30
+ activesupport (= 4.2.0)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
35
+ activejob (4.2.0)
36
+ activesupport (= 4.2.0)
37
+ globalid (>= 0.3.0)
16
38
  activesupport (4.2.0)
17
39
  i18n (~> 0.7)
18
40
  json (~> 1.7, >= 1.7.7)
@@ -34,13 +56,19 @@ GEM
34
56
  term-ansicolor
35
57
  thor
36
58
  docile (1.1.5)
59
+ erubis (2.7.0)
60
+ globalid (0.3.0)
61
+ activesupport (>= 4.1.0)
37
62
  i18n (0.7.0)
38
63
  json (1.8.1)
39
64
  jwt (1.0.0)
65
+ loofah (2.0.1)
66
+ nokogiri (>= 1.5.9)
40
67
  mail (2.6.1)
41
68
  mime-types (>= 1.16, < 3)
42
69
  metaclass (0.0.4)
43
70
  mime-types (2.4.3)
71
+ mini_portile (0.6.2)
44
72
  minitest (5.5.0)
45
73
  minitest-reporters (1.0.8)
46
74
  ansi
@@ -52,6 +80,19 @@ GEM
52
80
  multi_json (1.10.1)
53
81
  netrc (0.10.2)
54
82
  nexmo (2.0.0)
83
+ nokogiri (1.6.5)
84
+ mini_portile (~> 0.6.0)
85
+ rack (1.6.0)
86
+ rack-test (0.6.2)
87
+ rack (>= 1.0)
88
+ rails-deprecated_sanitizer (1.0.3)
89
+ activesupport (>= 4.2.0.alpha)
90
+ rails-dom-testing (1.0.5)
91
+ activesupport (>= 4.2.0.beta, < 5.0)
92
+ nokogiri (~> 1.6.0)
93
+ rails-deprecated_sanitizer (>= 1.0.1)
94
+ rails-html-sanitizer (1.0.1)
95
+ loofah (~> 2.0)
55
96
  rake (10.4.2)
56
97
  rest-client (1.7.2)
57
98
  mime-types (>= 1.16, < 3.0)
@@ -85,6 +126,7 @@ PLATFORMS
85
126
 
86
127
  DEPENDENCIES
87
128
  action_texter (= 0.2.0)!
129
+ actionmailer
88
130
  appraisal
89
131
  bundler
90
132
  codeclimate-test-reporter
@@ -7,12 +7,34 @@ GIT
7
7
  PATH
8
8
  remote: ../
9
9
  specs:
10
- sms_safe (0.1.0)
10
+ sms_safe (1.0.1)
11
11
  mail (>= 2.4)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
+ actionmailer (4.2.0)
17
+ actionpack (= 4.2.0)
18
+ actionview (= 4.2.0)
19
+ activejob (= 4.2.0)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ actionpack (4.2.0)
23
+ actionview (= 4.2.0)
24
+ activesupport (= 4.2.0)
25
+ rack (~> 1.6.0)
26
+ rack-test (~> 0.6.2)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
29
+ actionview (4.2.0)
30
+ activesupport (= 4.2.0)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
35
+ activejob (4.2.0)
36
+ activesupport (= 4.2.0)
37
+ globalid (>= 0.3.0)
16
38
  activesupport (4.2.0)
17
39
  i18n (~> 0.7)
18
40
  json (~> 1.7, >= 1.7.7)
@@ -34,13 +56,19 @@ GEM
34
56
  term-ansicolor
35
57
  thor
36
58
  docile (1.1.5)
59
+ erubis (2.7.0)
60
+ globalid (0.3.0)
61
+ activesupport (>= 4.1.0)
37
62
  i18n (0.7.0)
38
63
  json (1.8.1)
39
64
  jwt (1.0.0)
65
+ loofah (2.0.1)
66
+ nokogiri (>= 1.5.9)
40
67
  mail (2.6.3)
41
68
  mime-types (>= 1.16, < 3)
42
69
  metaclass (0.0.4)
43
70
  mime-types (2.4.3)
71
+ mini_portile (0.6.2)
44
72
  minitest (5.5.0)
45
73
  minitest-reporters (1.0.8)
46
74
  ansi
@@ -52,6 +80,19 @@ GEM
52
80
  multi_json (1.10.1)
53
81
  netrc (0.10.2)
54
82
  nexmo (2.0.0)
83
+ nokogiri (1.6.5)
84
+ mini_portile (~> 0.6.0)
85
+ rack (1.6.0)
86
+ rack-test (0.6.2)
87
+ rack (>= 1.0)
88
+ rails-deprecated_sanitizer (1.0.3)
89
+ activesupport (>= 4.2.0.alpha)
90
+ rails-dom-testing (1.0.5)
91
+ activesupport (>= 4.2.0.beta, < 5.0)
92
+ nokogiri (~> 1.6.0)
93
+ rails-deprecated_sanitizer (>= 1.0.1)
94
+ rails-html-sanitizer (1.0.1)
95
+ loofah (~> 2.0)
55
96
  rake (10.4.2)
56
97
  rest-client (1.7.2)
57
98
  mime-types (>= 1.16, < 3.0)
@@ -85,6 +126,7 @@ PLATFORMS
85
126
 
86
127
  DEPENDENCIES
87
128
  action_texter (= 0.2.0)!
129
+ actionmailer
88
130
  appraisal
89
131
  bundler
90
132
  codeclimate-test-reporter
@@ -1,15 +1,19 @@
1
1
  module SmsSafe
2
2
 
3
+ # Thrown when a config setting is invalid
3
4
  class InvalidConfigSettingError < StandardError; end
4
5
 
6
+ # Returns the current configuration
5
7
  def self.configuration
6
8
  @configuration ||= Configuration.new
7
9
  end
8
10
 
11
+ # Yields the current configuration, allowing the caller to modify it in a block
9
12
  def self.configure
10
13
  yield(configuration) if block_given?
11
14
  end
12
15
 
16
+ # Holds the configuration
13
17
  class Configuration
14
18
 
15
19
  # List of phone numbers that can accept SMS. Any phone number not on this list will get the SMS intercepted
@@ -2,6 +2,7 @@ require 'mail'
2
2
 
3
3
  module SmsSafe
4
4
 
5
+ # Main class with almost all the functionality.
5
6
  # When a message is intercepted, Interceptor decides whether we need to do anything with it,
6
7
  # and does it.
7
8
  # The different adaptor classes in the Interceptors module provide mapping to each of the SMS libraries peculiarities.
@@ -76,29 +77,34 @@ module SmsSafe
76
77
  end
77
78
 
78
79
  # Sends an e-mail to the specified address, instead of
80
+ # @return nil, to stop the sending
79
81
  def email(message)
80
- message_body = <<-EOS
81
- This email was originally an SMS that SmsSafe intercepted:
82
-
83
- From: #{message.from}
84
- To: #{message.to}
85
- Text: #{message.text}
86
-
87
- Full object: #{message.original_message.inspect}
88
- EOS
89
-
90
82
  recipient = email_recipient(message)
91
-
83
+ body = email_body(message)
92
84
  mail = Mail.new do
93
85
  from recipient
94
86
  to recipient
95
- subject 'SmsSafe: #{message.to} - #{message.text}'
96
- body message_body
87
+ subject "SmsSafe: #{message.to} - #{message.text}"
88
+ body body
97
89
  end
98
- mail.deliver!
90
+ deliver_email(mail)
99
91
 
100
- # Must return nil to stop the sending
101
- nil
92
+ nil # Must return nil to stop the sending
93
+ end
94
+
95
+ # Delivers the email through Mail, or ActionMailer, whatever is there
96
+ # @param [Mail] mail to send
97
+ # @return [Mail] the same mail received as parameter
98
+ def deliver_email(mail)
99
+ # Ugly hack, or beautiful elegance? No idea, really...
100
+ # We don't want a dependency on ActionMailer, but we want our users that have ActionMailer configured
101
+ # to not need to configure Mail too, so we want to take the ActionMailer configuration magically
102
+ # if it's there
103
+ if defined?(ActionMailer)
104
+ ActionMailer::Base.wrap_delivery_behavior(mail)
105
+ end
106
+
107
+ mail.deliver!
102
108
  end
103
109
 
104
110
  # Decides which email address to send the SMS to
@@ -114,8 +120,24 @@ Full object: #{message.original_message.inspect}
114
120
  end
115
121
  end
116
122
 
123
+ # Returns the Body for the e-mail that we'll send
124
+ # @param [Message] message the message we are emailing
125
+ # @return [String] the email body
126
+ def email_body(message)
127
+ <<-EOS
128
+ This email was originally an SMS that SmsSafe intercepted:
129
+
130
+ From: #{message.from}
131
+ To: #{message.to}
132
+ Text: #{message.text}
133
+
134
+ Full object: #{message.original_message.inspect}
135
+ EOS
136
+ end
137
+
117
138
  # Discards the message. Essentially doesn't do anything. Will sleep for a bit, however, if
118
139
  # configuration.discard_delay is set.
140
+ # @return nil, to stop the sending
119
141
  def discard
120
142
  # Delay to simulate the time it takes to talk to the external service
121
143
  if !SmsSafe.configuration.discard_delay.nil? && SmsSafe.configuration.discard_delay > 0
@@ -1,9 +1,12 @@
1
1
  module SmsSafe
2
2
  module Interceptors
3
+ # Interceptor class for ActionTexter Gem. Maps ActionTexter::Message into SmsSafe::Message and back.
3
4
  class ActionTexter < SmsSafe::Interceptor
4
5
  # This method will be called differently for each Texter Gem, it's the one that the hook likes to call
5
6
  # In all cases, it's a one-liner that calls process_message in the superclass
6
7
  # It could even be an alias, for all practical purposes
8
+ # @param [ActionTexter::Message] message that is being sent by ActionTexter gem
9
+ # @return [ActionTexter::Message] modified message to send, or nil to cancel send
7
10
  def delivering_sms(message)
8
11
  self.process_message(message)
9
12
  end
@@ -1,5 +1,6 @@
1
1
  module SmsSafe
2
2
  module Interceptors
3
+ # Interceptor class for Nexmo Gem. Maps Hash params into SmsSafe::Message and back.
3
4
  class Nexmo < SmsSafe::Interceptor
4
5
  # This method will be called differently for each Texter Gem, it's the one that the hook likes to call
5
6
  # In all cases, it's a one-liner that calls process_message in the superclass
@@ -1,5 +1,6 @@
1
1
  module SmsSafe
2
2
  module Interceptors
3
+ # Interceptor class for Twilio Ruby Gem. Maps Hash params into SmsSafe::Message and back.
3
4
  class Twilio < SmsSafe::Interceptor
4
5
  # This method will be called differently for each Texter Gem, it's the one that the hook likes to call
5
6
  # In all cases, it's a one-liner that calls process_message in the superclass
@@ -14,6 +14,8 @@ module SmsSafe
14
14
  class Message
15
15
  attr_accessor :from, :to, :text, :original_message
16
16
 
17
+ # Set all params as internal values.
18
+ # @param [Hash] attrs accepts :from, :to, :text and :original_message
17
19
  def initialize(attrs)
18
20
  attrs.each { |k, v| self.send "#{k.to_s}=".to_sym, v }
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module SmsSafe
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/sms_safe.gemspec CHANGED
@@ -4,7 +4,7 @@ require "sms_safe/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'sms_safe'
7
- s.version = '1.0.0'
7
+ s.version = '1.0.1'
8
8
  s.summary = "Keep your SMS messages from escaping into the wild during development."
9
9
  s.description = %q{SmsSafe provides a safety net while you're developing an application that uses ActionTexter
10
10
  or other gems to send SMS. It keeps SMS messages from escaping into the wild.
@@ -29,6 +29,8 @@ Gem::Specification.new do |s|
29
29
 
30
30
  s.add_runtime_dependency "mail", '>= 2.4'
31
31
 
32
+ s.add_development_dependency "actionmailer"
33
+
32
34
  s.add_development_dependency "bundler"
33
35
  s.add_development_dependency "rake"
34
36
 
data/test/test_helper.rb CHANGED
@@ -28,9 +28,8 @@ include ActiveSupport::Testing::Assertions
28
28
  require "benchmark"
29
29
 
30
30
  require 'mail'
31
- Mail.defaults do
32
- delivery_method :test
33
- end
31
+ require "action_mailer"
32
+ ActionMailer::Base.delivery_method = :test
34
33
  include Mail::Matchers
35
34
 
36
35
  require "sms_safe"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_safe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Magliola
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionmailer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement