Updates conditional logic to use a case clause

This commit is contained in:
Tim Emiola 2015-04-23 11:19:16 -07:00
parent 98816f7b67
commit 194128d220
2 changed files with 9 additions and 8 deletions

View File

@ -1,15 +1,15 @@
# 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
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 4
# Offense count: 3
Metrics/AbcSize:
Max: 24
# Offense count: 6
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 12
Max: 13

View File

@ -89,15 +89,16 @@ END
c = options[:connection] || Faraday.default_connection
c.headers = { 'Metadata-Flavor' => 'Google' }
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)
end
if resp.status != 200
else
msg = "Unexpected error code #{resp.status}" + UNEXPECTED_ERROR_SUFFIX
fail(Signet::AuthorizationError, msg)
end
Signet::OAuth2.parse_credentials(resp.body,
resp.headers['content-type'])
end
end
end