Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 36abf88

Browse files
committed
Fix several ruby styling issues
1 parent c433953 commit 36abf88

File tree

6 files changed

+31
-28
lines changed

6 files changed

+31
-28
lines changed

lookups/lookup-get-basic-example-1/lookup-get-basic-example-1.5.x.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
puts number.carrier['type']
1414
puts number.carrier['name']
1515
rescue Twilio::REST::RestError => e
16-
if e.status_code === 404
16+
if e.status_code === 404 # rubocop:disable Style/CaseEquality
1717
puts 'No carrier information'
1818
else
1919
puts e.message

rest/voice/generate-twiml-gather-input/twiml-gather-record.5.x.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
get '/voice/handle-gather' do
66
redirect '/voice' unless %w[1 2].include?(params['Digits'])
7-
if params['Digits'] == '1'
7+
case params['Digits']
8+
when '1'
89
response = Twilio::TwiML::Response.new do |r|
910
r.Dial '+13105551212'
1011
r.Say 'The call failed or the remote party hung up. Goodbye.'
1112
end
12-
elsif params['Digits'] == '2'
13+
when '2'
1314
response = Twilio::TwiML::Response.new do |r|
1415
r.Say 'Record your message after the tone.'
1516
r.Record maxLength: '30', action: '/voice/handle-record', method: 'get'

security/signature_validation_tests/signature_validation_tests.5.x.rb

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,32 @@
1111
url = 'https://mycompany.com/myapp'
1212
params = {
1313
'CallSid' => 'CA1234567890ABCDE',
14-
'Caller' => '+12349013030',
15-
'Digits' => '1234',
16-
'From' => '+12349013030',
17-
'To' => '+18005551212'
14+
'Caller' => '+12349013030',
15+
'Digits' => '1234',
16+
'From' => '+12349013030',
17+
'To' => '+18005551212'
1818
}
1919

20+
# rubocop:disable Metrics/MethodLength
2021
def test_url(method, url, params, valid)
21-
if method == 'GET'
22-
url += '?' + URI.encode_www_form(params)
23-
params = {}
24-
end
22+
if method == 'GET'
23+
url += '?' + URI.encode_www_form(params)
24+
params = {}
25+
end
2526

26-
signature = @validator.build_signature_for(valid ? url : "http://invalid.com", params)
27-
headers = {'X-Twilio-Signature': signature}
28-
if method == 'GET'
29-
response = HTTParty.get(url, headers: headers)
30-
else
31-
response = HTTParty.post(url, body: params, headers: headers)
32-
end
33-
valid_str = valid ? 'valid' : 'invalid'
34-
puts "HTTP #{method} with #{valid_str} signature returned #{response.code}"
27+
signature = @validator.build_signature_for(valid ? url : 'http://invalid.com', params)
28+
headers = { 'X-Twilio-Signature': signature }
29+
response = if method == 'GET'
30+
HTTParty.get(url, headers: headers)
31+
else
32+
HTTParty.post(url, body: params, headers: headers)
33+
end
34+
valid_str = valid ? 'valid' : 'invalid'
35+
puts "HTTP #{method} with #{valid_str} signature returned #{response.code}"
3536
end
37+
# rubocop:enable Metrics/MethodLength
3638

3739
test_url('GET', url, params, true)
3840
test_url('GET', url, params, false)
3941
test_url('POST', url, params, true)
40-
test_url('POST', url, params, false)
42+
test_url('POST', url, params, false)

twiml/voice/pay/pay-9/pay-9.5.x.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
end
99
pay.prompt(for: 'expiration-date', attempt: '2 3') do |prompt2|
1010
prompt2
11-
.say(message: 'Please enter your expiration date, two digits for the month and two digits for the year. For example, if your expiration date is March 2022, then please enter 0 3 2 2')
11+
.say(message: 'Please enter your expiration date, two digits for the month and two digits for the year. '\
12+
'For example, if your expiration date is March 2022, then please enter 0 3 2 2')
1213
end
1314
end
1415

video/rest/rooms/participants/retrieve-participant-list-connected/retrieve-participants-connected.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
client = Twilio::REST::Client.new api_key_sid, api_key_secret
1010

11-
participants = client.video.rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
12-
.participants.list(status: 'connected').each do |participant|
13-
puts participant.sid
14-
end
11+
client.video.rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
12+
.participants.list(status: 'connected').each do |participant|
13+
puts participant.sid
14+
end

video/rest/rooms/recording-rules-start-all/recording-rules-start-all.5.x.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
recording_rules = @client.video
1212
.rooms('RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
1313
.recording_rules
14-
.update(rules: [{"type": :"include", "all": true}])
14+
.update(rules: [{ "type": :include, "all": true }])
1515

1616
puts recording_rules.room_sid
17-

0 commit comments

Comments
 (0)