method
to_yaml
v2_1_10 -
Show latest stable
- Class:
Gem::ConfigFile
to_yaml()public
to_yaml only overwrites things you can’t override on the command line.
# File lib/rubygems/config_file.rb, line 403
def to_yaml # :nodoc:
yaml_hash = {}
yaml_hash[:backtrace] = if @hash.key?(:backtrace)
@hash[:backtrace]
else
DEFAULT_BACKTRACE
end
yaml_hash[:bulk_threshold] = if @hash.key?(:bulk_threshold)
@hash[:bulk_threshold]
else
DEFAULT_BULK_THRESHOLD
end
yaml_hash[:sources] = Gem.sources.to_a
yaml_hash[:update_sources] = if @hash.key?(:update_sources)
@hash[:update_sources]
else
DEFAULT_UPDATE_SOURCES
end
yaml_hash[:verbose] = if @hash.key?(:verbose)
@hash[:verbose]
else
DEFAULT_VERBOSITY
end
keys = yaml_hash.keys.map { |key| key.to_s }
keys << 'debug'
re = Regexp.union(*keys)
@hash.each do |key, value|
key = key.to_s
next if key =~ re
yaml_hash[key.to_s] = value
end
yaml_hash.to_yaml
end