[前][次][番号順一覧][スレッド一覧]

ruby-changes:71649

From: Ashley <ko1@a...>
Date: Wed, 6 Apr 2022 08:55:21 +0900 (JST)
Subject: [ruby-changes:71649] 37a19f7f67 (master): [rubygems/rubygems] Extract default_host method

https://git.ruby-lang.org/ruby.git/commit/?id=37a19f7f67

From 37a19f7f67f2e1836e981084f20ea5692b6a09d5 Mon Sep 17 00:00:00 2001
From: Ashley Ellis Pierce <anellis12@g...>
Date: Tue, 8 Mar 2022 13:15:37 +0000
Subject: [rubygems/rubygems] Extract default_host method

https://github.com/rubygems/rubygems/commit/6e10e75574
---
 lib/rubygems/gemcutter_utilities.rb | 11 ++++++++---
 1 file 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L221
   # +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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L245
   end
 
   def pretty_host(host)
-    if Gem::DEFAULT_HOST == host
+    if default_host?
       'RubyGems.org'
     else
       host
@@ -269,8 +269,12 @@ module Gem::GemcutterUtilities https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L269
     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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L289
     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"]
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]