[rubygems/rubygems] Move config_file_name logic to its own method

https://github.com/rubygems/rubygems/commit/ac4596aace
This commit is contained in:
bronzdoc 2019-05-28 22:41:54 -06:00 коммит произвёл Hiroshi SHIBATA
Родитель d64cc80b66
Коммит 6f60ead756
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
1 изменённых файлов: 21 добавлений и 19 удалений

Просмотреть файл

@ -168,23 +168,7 @@ class Gem::ConfigFile
# TODO: parse options upstream, pass in options directly
def initialize(args)
@config_file_name = nil
need_config_file_name = false
arg_list = []
args.each do |arg|
if need_config_file_name
@config_file_name = arg
need_config_file_name = false
elsif arg =~ /^--config-file=(.*)/
@config_file_name = $1
elsif arg =~ /^--config-file$/
need_config_file_name = true
else
arg_list << arg
end
end
set_config_file_name(args)
@backtrace = DEFAULT_BACKTRACE
@bulk_threshold = DEFAULT_BULK_THRESHOLD
@ -197,13 +181,14 @@ class Gem::ConfigFile
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
user_config = load_file config_file_name.dup.untaint
environment_config = (ENV['GEMRC'] || '')
.split(File::PATH_SEPARATOR).inject({}) do |result, file|
result.merge load_file file
end
@hash = operating_system_config.merge platform_config
unless arg_list.index '--norc'
unless args.index '--norc'
@hash = @hash.merge system_config
@hash = @hash.merge user_config
@hash = @hash.merge environment_config
@ -227,7 +212,7 @@ class Gem::ConfigFile
@api_keys = nil
@rubygems_api_key = nil
handle_arguments arg_list
handle_arguments args
end
##
@ -486,4 +471,21 @@ if you believe they were disclosed to a third party.
attr_reader :hash
protected :hash
private
def set_config_file_name(args)
@config_file_name = nil
need_config_file_name = false
args.each do |arg|
if need_config_file_name
@config_file_name = arg
need_config_file_name = false
elsif arg =~ /^--config-file=(.*)/
@config_file_name = $1
elsif arg =~ /^--config-file$/
need_config_file_name = true
end
end
end
end