diff options
author | Homu <homu@barosl.com> | 2016-04-18 08:28:57 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-04-18 08:28:57 +0900 |
commit | ba23e13a8c4420c91d2d866e3bcaed18cbb03d1b (patch) | |
tree | 1bd3ad8877e0b3e4250c674045f2a2320eef37ea | |
parent | 0446fa9860f36a3ee75fa12599e03fabc613a894 (diff) | |
parent | 72c1825ad246e610b49cabdf69e56726f4f79ca2 (diff) | |
download | bundler-ba23e13a8c4420c91d2d866e3bcaed18cbb03d1b.tar.gz |
Auto merge of #4416 - bundler:seg-settings-custom-serializer, r=segiddins
[Settings] Use a custom serializer instead of relying upon the YAML module
¯\\\_(ツ)\_/¯ seems like a good idea
\c @RochesterinNYC @indirect
-rw-r--r-- | lib/bundler/settings.rb | 11 | ||||
-rw-r--r-- | spec/commands/config_spec.rb | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 8e43918097..de0644adce 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -201,14 +201,21 @@ module Bundler hash.delete(key) if value.nil? SharedHelpers.filesystem_access(file) do |p| FileUtils.mkdir_p(p.dirname) - require "bundler/psyched_yaml" - File.open(p, "w") {|f| f.puts YAML.dump(hash) } + p.open("w") {|f| f.write(serialize_hash(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"]) diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index 2c31e48940..ad88af62d9 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -226,7 +226,7 @@ E it "doesn't return quotes around values", :ruby => "1.9" do bundle "config foo '1'" run "puts Bundler.settings.send(:global_config_file).read" - expect(out).to include("'1'") + expect(out).to include('"1"') run "puts Bundler.settings[:foo]" expect(out).to eq("1") end |