diff options
author | Ashley Ellis Pierce <anellis12@gmail.com> | 2022-03-08 13:15:37 +0000 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-04-06 08:54:59 +0900 |
commit | 37a19f7f67f2e1836e981084f20ea5692b6a09d5 (patch) | |
tree | 1a0ca180702d74eeb3cff230213af0062bea9183 | |
parent | b75b67f1136363ea54e9f79a4d63a9a355312f26 (diff) |
[rubygems/rubygems] Extract default_host method
https://github.com/rubygems/rubygems/commit/6e10e75574
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index 3a60b654d6..53351fc13a 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -221,7 +221,7 @@ module Gem::GemcutterUtilities # +response+ text and no otp provided by options. def set_api_key(host, key) - if host == Gem::DEFAULT_HOST + if default_host? Gem.configuration.rubygems_api_key = key else Gem.configuration.set_api_key host, key @@ -245,7 +245,7 @@ module Gem::GemcutterUtilities end def pretty_host(host) - if Gem::DEFAULT_HOST == host + if default_host? 'RubyGems.org' else host @@ -269,8 +269,12 @@ module Gem::GemcutterUtilities scope_params end + def default_host? + self.host == Gem::DEFAULT_HOST + end + def get_mfa_params(email, password) - return {} unless self.host == Gem::DEFAULT_HOST + return {} unless default_host? mfa_level = get_user_mfa_level(email, password) params = {} @@ -285,6 +289,7 @@ module Gem::GemcutterUtilities response = rubygems_api_request(:get, "api/v1/profile/me.yaml") do |request| request.basic_auth email, password end + with_response response do |resp| body = Gem::SafeYAML.load clean_text(resp.body) body["mfa"] |