mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Move config_file_name logic to its own method
ac4596aace
This commit is contained in:
parent
d64cc80b66
commit
6f60ead756
1 changed files with 21 additions and 19 deletions
|
@ -168,23 +168,7 @@ class Gem::ConfigFile
|
||||||
# TODO: parse options upstream, pass in options directly
|
# TODO: parse options upstream, pass in options directly
|
||||||
|
|
||||||
def initialize(args)
|
def initialize(args)
|
||||||
@config_file_name = nil
|
set_config_file_name(args)
|
||||||
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
|
|
||||||
|
|
||||||
@backtrace = DEFAULT_BACKTRACE
|
@backtrace = DEFAULT_BACKTRACE
|
||||||
@bulk_threshold = DEFAULT_BULK_THRESHOLD
|
@bulk_threshold = DEFAULT_BULK_THRESHOLD
|
||||||
|
@ -197,13 +181,14 @@ class Gem::ConfigFile
|
||||||
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
|
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
|
||||||
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
|
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
|
||||||
user_config = load_file config_file_name.dup.untaint
|
user_config = load_file config_file_name.dup.untaint
|
||||||
|
|
||||||
environment_config = (ENV['GEMRC'] || '')
|
environment_config = (ENV['GEMRC'] || '')
|
||||||
.split(File::PATH_SEPARATOR).inject({}) do |result, file|
|
.split(File::PATH_SEPARATOR).inject({}) do |result, file|
|
||||||
result.merge load_file file
|
result.merge load_file file
|
||||||
end
|
end
|
||||||
|
|
||||||
@hash = operating_system_config.merge platform_config
|
@hash = operating_system_config.merge platform_config
|
||||||
unless arg_list.index '--norc'
|
unless args.index '--norc'
|
||||||
@hash = @hash.merge system_config
|
@hash = @hash.merge system_config
|
||||||
@hash = @hash.merge user_config
|
@hash = @hash.merge user_config
|
||||||
@hash = @hash.merge environment_config
|
@hash = @hash.merge environment_config
|
||||||
|
@ -227,7 +212,7 @@ class Gem::ConfigFile
|
||||||
@api_keys = nil
|
@api_keys = nil
|
||||||
@rubygems_api_key = nil
|
@rubygems_api_key = nil
|
||||||
|
|
||||||
handle_arguments arg_list
|
handle_arguments args
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -486,4 +471,21 @@ if you believe they were disclosed to a third party.
|
||||||
attr_reader :hash
|
attr_reader :hash
|
||||||
protected :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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue