Skip to content

Commit ee8f8a7

Browse files
gmcgibbonthinkingseriouseshanholtz
authored
feat: Autoload Twilio::REST and Twilio::HTTP (#558)
Co-authored-by: Elmer Thomas <[email protected]> Co-authored-by: Elise Shanholtz <[email protected]>
1 parent 9d49273 commit ee8f8a7

File tree

11 files changed

+30
-22
lines changed

11 files changed

+30
-22
lines changed

.rubocop_todo.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Lint/UnusedBlockArgument:
6666
Lint/UnusedMethodArgument:
6767
Exclude:
6868
- 'lib/twilio-ruby.rb'
69-
- 'lib/twilio-ruby/framework/page.rb'
69+
- 'lib/twilio-ruby/framework/rest/page.rb'
7070
- 'spec/holodeck/holodeck.rb'
7171

7272
# Offense count: 1
@@ -130,7 +130,7 @@ Style/FrozenStringLiteralComment:
130130
# Configuration parameters: MinBodyLength.
131131
Style/GuardClause:
132132
Exclude:
133-
- 'lib/twilio-ruby/framework/page.rb'
133+
- 'lib/twilio-ruby/framework/rest/page.rb'
134134

135135
# Offense count: 1
136136
# Cop supports --auto-correct.
@@ -144,8 +144,8 @@ Style/HashSyntax:
144144
# Cop supports --auto-correct.
145145
Style/IfUnlessModifier:
146146
Exclude:
147-
- 'lib/twilio-ruby/framework/page.rb'
148-
- 'lib/twilio-ruby/framework/version.rb'
147+
- 'lib/twilio-ruby/framework/rest/page.rb'
148+
- 'lib/twilio-ruby/framework/rest/version.rb'
149149
- 'lib/twilio-ruby/jwt/access_token.rb'
150150
- 'lib/twilio-ruby/jwt/client_capability.rb'
151151
- 'lib/twilio-ruby/jwt/jwt.rb'
@@ -168,9 +168,9 @@ Style/RedundantSelf:
168168
# SupportedStyles: slashes, percent_r, mixed
169169
Style/RegexpLiteral:
170170
Exclude:
171-
- 'lib/twilio-ruby/framework/domain.rb'
172-
- 'lib/twilio-ruby/framework/helper.rb'
173-
- 'lib/twilio-ruby/framework/version.rb'
171+
- 'lib/twilio-ruby/framework/rest/domain.rb'
172+
- 'lib/twilio-ruby/framework/rest/helper.rb'
173+
- 'lib/twilio-ruby/framework/rest/version.rb'
174174
- 'spec/rack/twilio_webhook_authentication_spec.rb'
175175

176176
# Offense count: 5

lib/twilio-ruby.rb

+5-15
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,17 @@
1616
require 'twilio-ruby/security/request_validator'
1717
require 'twilio-ruby/util/configuration'
1818

19-
Dir[File.dirname(__FILE__) + '/twilio-ruby/http/**/*.rb'].sort.each do |file|
20-
require file
21-
end
22-
Dir[File.dirname(__FILE__) + '/twilio-ruby/framework/**/*.rb'].sort.each do |file|
23-
require file
24-
end
25-
Dir[File.dirname(__FILE__) + '/twilio-ruby/rest/*.rb'].sort.each do |file|
26-
require file
27-
end
28-
Dir[File.dirname(__FILE__) + '/twilio-ruby/rest/**/*.rb'].sort.each do |file|
29-
require file
30-
end
31-
Dir[File.dirname(__FILE__) + '/twilio-ruby/compatibility/**/*.rb'].sort.each do |file|
19+
Dir[File.join(__dir__, 'twilio-ruby/framework/*.rb')].sort.each do |file|
3220
require file
3321
end
3422

3523
module Twilio
3624
extend SingleForwardable
3725

38-
autoload :JWT, File.join(File.dirname(__FILE__), 'twilio-ruby', 'jwt', 'jwt.rb')
39-
autoload :TwiML, File.join(File.dirname(__FILE__), 'twilio-ruby', 'twiml', 'twiml.rb')
26+
autoload :JWT, File.join(__dir__, 'twilio-ruby', 'jwt', 'jwt.rb')
27+
autoload :TwiML, File.join(__dir__, 'twilio-ruby', 'twiml', 'twiml.rb')
28+
autoload :HTTP, File.join(__dir__, 'twilio-ruby', 'http.rb')
29+
autoload :REST, File.join(__dir__, 'twilio-ruby', 'rest.rb')
4030

4131
def_delegators :configuration, :account_sid, :auth_token, :http_client, :region, :edge, :logger
4232

lib/twilio-ruby/http.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
Dir[File.join(__dir__, 'http/**/*.rb')].sort.each do |file|
4+
require file
5+
end

lib/twilio-ruby/rest.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
Dir[File.join(__dir__, 'framework/rest/*.rb')].sort.each do |file|
4+
require file
5+
end
6+
7+
Dir[File.join(__dir__, 'rest/*.rb')].sort.each do |file|
8+
require file
9+
end
10+
11+
Dir[File.join(__dir__, 'rest/**/*.rb')].sort.each do |file|
12+
require file
13+
end

0 commit comments

Comments
 (0)