twilio_contactable 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/contactable.rb +14 -0
- data/lib/controller.rb +4 -3
- data/test/twilio_contactable_controller_test.rb +20 -14
- data/twilio_contactable.gemspec +3 -3
- metadata +14 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.5
|
data/lib/contactable.rb
CHANGED
@@ -127,6 +127,7 @@ module TwilioContactable
|
|
127
127
|
# code. If they match then the current phone number is set
|
128
128
|
# as confirmed by the user.
|
129
129
|
def sms_confirm_with(code)
|
130
|
+
check_for_twilio_contactable_columns(:sms)
|
130
131
|
if _TC_sms_confirmation_code.to_s.downcase == code.downcase
|
131
132
|
# save the phone number into the 'confirmed phone number' attribute
|
132
133
|
self._TC_sms_confirmed_phone_number = _TC_formatted_phone_number
|
@@ -139,6 +140,7 @@ module TwilioContactable
|
|
139
140
|
# Returns true if the current phone number has been confirmed by
|
140
141
|
# the user for recieving TXT messages.
|
141
142
|
def sms_confirmed?
|
143
|
+
check_for_twilio_contactable_columns(:sms)
|
142
144
|
return false if _TC_sms_confirmed_phone_number.blank?
|
143
145
|
self._TC_sms_confirmed_phone_number == _TC_formatted_phone_number
|
144
146
|
end
|
@@ -147,6 +149,7 @@ module TwilioContactable
|
|
147
149
|
# code. If they match then the current phone number is set
|
148
150
|
# as confirmed by the user.
|
149
151
|
def voice_confirm_with(code)
|
152
|
+
check_for_twilio_contactable_columns(:voice)
|
150
153
|
if _TC_voice_confirmation_code.to_s.downcase == code.downcase
|
151
154
|
# save the phone number into the 'confirmed phone number' attribute
|
152
155
|
self._TC_voice_confirmed_phone_number = _TC_formatted_phone_number
|
@@ -159,6 +162,7 @@ module TwilioContactable
|
|
159
162
|
# Returns true if the current phone number has been confirmed by
|
160
163
|
# the user by receiving a phone call
|
161
164
|
def voice_confirmed?
|
165
|
+
check_for_twilio_contactable_columns(:voice)
|
162
166
|
return false if _TC_voice_confirmed_phone_number.blank?
|
163
167
|
self._TC_voice_confirmed_phone_number == _TC_formatted_phone_number
|
164
168
|
end
|
@@ -187,6 +191,16 @@ module TwilioContactable
|
|
187
191
|
|
188
192
|
protected
|
189
193
|
|
194
|
+
def check_for_twilio_contactable_columns(type)
|
195
|
+
columns_to_check_for = ["#{type}_confirmed_phone_number",
|
196
|
+
"#{type}_confirmation_attempted",
|
197
|
+
"#{type}_confirmation_code"]
|
198
|
+
return if self.class.columns.select do |column|
|
199
|
+
columns_to_check_for.include? column.name.to_s
|
200
|
+
end.size == columns_to_check_for.size
|
201
|
+
warn "TwilioContactable #{type.to_s.inspect} confirmation columns have not been added to #{self.class.name.inspect}"
|
202
|
+
end
|
203
|
+
|
190
204
|
def update_twilio_contactable_sms_confirmation(new_code)
|
191
205
|
self._TC_sms_confirmation_code = new_code
|
192
206
|
self._TC_sms_confirmation_attempted = Time.now.utc
|
data/lib/controller.rb
CHANGED
@@ -50,15 +50,16 @@ module TwilioContactable
|
|
50
50
|
).tap do |gather|
|
51
51
|
gather.addSay "Please type the numbers that appear on your screen, followed by the pound sign"
|
52
52
|
end
|
53
|
-
response.addSay "Thank you, please return to the website and continue"
|
54
|
-
response.addPause
|
55
53
|
end.respond)
|
56
54
|
end
|
57
55
|
|
58
56
|
def receive_voice_confirmation
|
59
57
|
@contactable = params[:contactable_type].constantize.find(params[:contactable_id])
|
60
58
|
@contactable.voice_confirm_with(params['Digits'])
|
61
|
-
render :xml =>
|
59
|
+
render :xml => (Twilio::Response.new.tap do |response|
|
60
|
+
response.addSay "Thank you, please return to the website and continue"
|
61
|
+
response.addHangup
|
62
|
+
end.respond)
|
62
63
|
end
|
63
64
|
|
64
65
|
protected
|
@@ -81,20 +81,16 @@ class TwilioContactableControllerTest < ActionController::TestCase
|
|
81
81
|
should_respond_with_content_type :xml
|
82
82
|
should "render Gather TwiML node with a Say inside" do
|
83
83
|
assert_dom_equal %q{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
</say>
|
95
|
-
<pause></pause>
|
96
|
-
</response>
|
97
|
-
}, @response.body
|
84
|
+
<response>
|
85
|
+
<gather
|
86
|
+
action="http://test.host/twilio_contactable/receive_voice_confirmation?contactable_id=1&contactable_type=User"
|
87
|
+
>
|
88
|
+
<say>
|
89
|
+
Please type the numbers that appear on your screen, followed by the pound sign
|
90
|
+
</say>
|
91
|
+
</gather>
|
92
|
+
</response>},
|
93
|
+
@response.body
|
98
94
|
end
|
99
95
|
end
|
100
96
|
context "receiving digits from Twilio" do
|
@@ -113,6 +109,16 @@ class TwilioContactableControllerTest < ActionController::TestCase
|
|
113
109
|
should "not change the user's sms confirmation setting" do
|
114
110
|
assert !@user.sms_confirmed?
|
115
111
|
end
|
112
|
+
should "render message in TwiML and hang up" do
|
113
|
+
assert_dom_equal %q{
|
114
|
+
<response>
|
115
|
+
<say>
|
116
|
+
Thank you, please return to the website and continue
|
117
|
+
</say>
|
118
|
+
<hangup></hangup>
|
119
|
+
</response>},
|
120
|
+
@response.body
|
121
|
+
end
|
116
122
|
end
|
117
123
|
end
|
118
124
|
end
|
data/twilio_contactable.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{twilio_contactable}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jack Danger Canty"]
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.homepage = %q{http://github.com/JackDanger/twilio_contactable}
|
38
38
|
s.rdoc_options = ["--charset=UTF-8"]
|
39
39
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = %q{1.3.
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
41
|
s.summary = %q{Help authorize the users of your Rails apps to confirm and use their phone numbers}
|
42
42
|
s.test_files = [
|
43
43
|
"test/test_helper.rb",
|
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
|
|
50
50
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
51
|
s.specification_version = 3
|
52
52
|
|
53
|
-
if Gem::Version.new(Gem::
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
54
|
s.add_runtime_dependency(%q<twiliolib>, [">= 2.0.5"])
|
55
55
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
56
56
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twilio_contactable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
9
|
+
- 5
|
10
|
+
version: 0.7.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Jack Danger Canty
|
@@ -21,9 +22,11 @@ dependencies:
|
|
21
22
|
name: twiliolib
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
27
30
|
segments:
|
28
31
|
- 2
|
29
32
|
- 0
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: shoulda
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
version: "0"
|
@@ -47,9 +52,11 @@ dependencies:
|
|
47
52
|
name: mocha
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
53
60
|
segments:
|
54
61
|
- 0
|
55
62
|
version: "0"
|
@@ -91,23 +98,27 @@ rdoc_options:
|
|
91
98
|
require_paths:
|
92
99
|
- lib
|
93
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
94
102
|
requirements:
|
95
103
|
- - ">="
|
96
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
97
106
|
segments:
|
98
107
|
- 0
|
99
108
|
version: "0"
|
100
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
101
111
|
requirements:
|
102
112
|
- - ">="
|
103
113
|
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
104
115
|
segments:
|
105
116
|
- 0
|
106
117
|
version: "0"
|
107
118
|
requirements: []
|
108
119
|
|
109
120
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.3.
|
121
|
+
rubygems_version: 1.3.7
|
111
122
|
signing_key:
|
112
123
|
specification_version: 3
|
113
124
|
summary: Help authorize the users of your Rails apps to confirm and use their phone numbers
|