Updates conditional logic to use a case clause
This commit is contained in:
parent
98816f7b67
commit
194128d220
|
@ -1,15 +1,15 @@
|
||||||
# This configuration was generated by `rubocop --auto-gen-config`
|
# This configuration was generated by `rubocop --auto-gen-config`
|
||||||
# on 2015-04-23 09:39:10 -0700 using RuboCop version 0.30.0.
|
# on 2015-04-23 11:18:24 -0700 using RuboCop version 0.30.0.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
# versions of RuboCop, may require this file to be generated again.
|
# versions of RuboCop, may require this file to be generated again.
|
||||||
|
|
||||||
# Offense count: 4
|
# Offense count: 3
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 24
|
Max: 24
|
||||||
|
|
||||||
# Offense count: 6
|
# Offense count: 6
|
||||||
# Configuration parameters: CountComments.
|
# Configuration parameters: CountComments.
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 12
|
Max: 13
|
||||||
|
|
|
@ -89,15 +89,16 @@ END
|
||||||
c = options[:connection] || Faraday.default_connection
|
c = options[:connection] || Faraday.default_connection
|
||||||
c.headers = { 'Metadata-Flavor' => 'Google' }
|
c.headers = { 'Metadata-Flavor' => 'Google' }
|
||||||
resp = c.get(COMPUTE_AUTH_TOKEN_URI)
|
resp = c.get(COMPUTE_AUTH_TOKEN_URI)
|
||||||
if resp.status == 404
|
case resp.status
|
||||||
|
when 200
|
||||||
|
Signet::OAuth2.parse_credentials(resp.body,
|
||||||
|
resp.headers['content-type'])
|
||||||
|
when 404
|
||||||
fail(Signet::AuthorizationError, NO_METADATA_SERVER_ERROR)
|
fail(Signet::AuthorizationError, NO_METADATA_SERVER_ERROR)
|
||||||
end
|
else
|
||||||
if resp.status != 200
|
|
||||||
msg = "Unexpected error code #{resp.status}" + UNEXPECTED_ERROR_SUFFIX
|
msg = "Unexpected error code #{resp.status}" + UNEXPECTED_ERROR_SUFFIX
|
||||||
fail(Signet::AuthorizationError, msg)
|
fail(Signet::AuthorizationError, msg)
|
||||||
end
|
end
|
||||||
Signet::OAuth2.parse_credentials(resp.body,
|
|
||||||
resp.headers['content-type'])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue