Skip to content

Commit 6e10e75

Browse files
committed
Extract default_host method
1 parent 6122e8c commit 6e10e75

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/rubygems/gemcutter_utilities.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def with_response(response, error_prefix = nil)
221221
# +response+ text and no otp provided by options.
222222

223223
def set_api_key(host, key)
224-
if host == Gem::DEFAULT_HOST
224+
if default_host?
225225
Gem.configuration.rubygems_api_key = key
226226
else
227227
Gem.configuration.set_api_key host, key
@@ -245,7 +245,7 @@ def ask_otp
245245
end
246246

247247
def pretty_host(host)
248-
if Gem::DEFAULT_HOST == host
248+
if default_host?
249249
'RubyGems.org'
250250
else
251251
host
@@ -269,8 +269,12 @@ def get_scope_params(scope)
269269
scope_params
270270
end
271271

272+
def default_host?
273+
self.host == Gem::DEFAULT_HOST
274+
end
275+
272276
def get_mfa_params(email, password)
273-
return {} unless self.host == Gem::DEFAULT_HOST
277+
return {} unless default_host?
274278

275279
mfa_level = get_user_mfa_level(email, password)
276280
params = {}
@@ -285,6 +289,7 @@ def get_user_mfa_level(email, password)
285289
response = rubygems_api_request(:get, "api/v1/profile/me.yaml") do |request|
286290
request.basic_auth email, password
287291
end
292+
288293
with_response response do |resp|
289294
body = Gem::SafeYAML.load clean_text(resp.body)
290295
body["mfa"]

0 commit comments

Comments
 (0)