summaryrefslogtreecommitdiff
path: root/lib/rubygems/config_file.rb
diff options
context:
space:
mode:
authorbronzdoc <lsagastume1990@gmail.com>2019-05-28 22:41:54 -0600
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-07-31 07:47:00 +0800
commit6f60ead7565e02901db63f005008860b65b4a15e (patch)
treea58ebb6cdb6d306d1177860ce30cfdf28ef77012 /lib/rubygems/config_file.rb
parentd64cc80b660c30577945f3cac452ca16db44ce9f (diff)
[rubygems/rubygems] Move config_file_name logic to its own method
https://github.com/rubygems/rubygems/commit/ac4596aace
Diffstat (limited to 'lib/rubygems/config_file.rb')
-rw-r--r--lib/rubygems/config_file.rb40
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 52591f49bb..003d98f53d 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -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