diff options
Diffstat (limited to 'lib/bundler/settings.rb')
-rw-r--r-- | lib/bundler/settings.rb | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index de0644adce..0dd1d762e6 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -3,7 +3,7 @@ require "uri" module Bundler class Settings - BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check disable_shared_gems ignore_messages gem.mit gem.coc silence_root_warning no_install).freeze + BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check disable_shared_gems ignore_messages gem.mit gem.coc silence_root_warning no_install plugins).freeze NUMBER_KEYS = %w(retry timeout redirect ssl_verify_mode).freeze DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }.freeze @@ -201,21 +201,14 @@ module Bundler hash.delete(key) if value.nil? SharedHelpers.filesystem_access(file) do |p| FileUtils.mkdir_p(p.dirname) - p.open("w") {|f| f.write(serialize_hash(hash)) } + require "bundler/yaml_serializer" + p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) } end end value end - def serialize_hash(hash) - yaml = String.new("---\n") - hash.each do |key, value| - yaml << key << ": " << value.to_s.gsub(/\s+/, " ").inspect << "\n" - end - yaml - end - def global_config_file if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty? Pathname.new(ENV["BUNDLE_CONFIG"]) @@ -246,20 +239,11 @@ module Bundler SharedHelpers.filesystem_access(config_file, :read) do valid_file = config_file && config_file.exist? && !config_file.size.zero? return {} if ignore_config? || !valid_file - config_pairs = config_file.read.scan(CONFIG_REGEX).map do |m| - key, _, value = m - [convert_to_backward_compatible_key(key), value.gsub(/\s+/, " ").tr('"', "'")] - end - Hash[config_pairs] + require "bundler/yaml_serializer" + YAMLSerializer.load config_file.read end end - def convert_to_backward_compatible_key(key) - key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z} - key = key.gsub(".", "__") if key.include?(".") - key - end - # TODO: duplicates Rubygems#normalize_uri # TODO: is this the correct place to validate mirror URIs? def self.normalize_uri(uri) |