summaryrefslogtreecommitdiff
path: root/lib/rubygems/config_file.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/config_file.rb37
1 files changed, 31 insertions, 6 deletions
@@ -1,3 +1,9 @@
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -47,10 +53,29 @@ class Gem::ConfigFile
system_config_path =
begin
- require 'etc.so'
Etc.sysconfdir
- rescue LoadError
- '/etc'
end
SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
@@ -192,7 +217,7 @@ class Gem::ConfigFile
dirname = File.dirname(credentials_path)
Dir.mkdir(dirname) unless File.exists?(dirname)
- require 'yaml'
File.open(credentials_path, 'w') do |f|
f.write config.to_yaml
@@ -202,9 +227,10 @@ class Gem::ConfigFile
end
def load_file(filename)
return {} unless filename and File.exists?(filename)
begin
- require 'yaml'
YAML.load(File.read(filename))
rescue ArgumentError
warn "Failed to load #{config_file_name}"
@@ -299,7 +325,6 @@ class Gem::ConfigFile
# Writes out this config file, replacing its source.
def write
- require 'yaml'
open config_file_name, 'w' do |io|
io.write to_yaml
end