Skip to content

Commit be17f2a

Browse files
committed
Merge pull request #61 from fpringvaldsen/bug/TK-249/bad-comments
(TK-249) Remove unnecessary comments in output
2 parents 6b402bc + e893d6f commit be17f2a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/hocon/impl/simple_config_document.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'hocon/impl'
44
require 'hocon/parser/config_document'
55
require 'hocon/impl/config_document_parser'
6+
require 'hocon/config_render_options'
67

78
class Hocon::Impl::SimpleConfigDocument
89
include Hocon::Parser::ConfigDocument
@@ -23,7 +24,9 @@ def set_value(path, new_value)
2324
end
2425

2526
def set_config_value(path, new_value)
26-
set_value(path, new_value.render.strip)
27+
options = Hocon::ConfigRenderOptions.defaults
28+
options.origin_comments = false
29+
set_value(path, new_value.render(options).strip)
2730
end
2831

2932
def remove_value(path)

spec/unit/typesafe/config/config_document_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,15 @@
552552
config_document = ConfigDocumentFactory.parse_string(orig_text)
553553
map_val = ConfigValueFactory.from_any_ref({"a" => 1, "b" => 2})
554554

555-
expect(config_document.set_config_value("a", map_val).render).to eq("a : {\n # hardcoded value\n \"a\" : 1,\n # hardcoded value\n \"b\" : 2\n}")
555+
expect(config_document.set_config_value("a", map_val).render).to eq("a : {\n \"a\" : 1,\n \"b\" : 2\n}")
556556
end
557557

558558
it "should successfully insert an array into an empty document" do
559559
orig_text = ""
560560
config_document = ConfigDocumentFactory.parse_string(orig_text)
561561
array_val = ConfigValueFactory.from_any_ref([1,2])
562562

563-
expect(config_document.set_config_value("a", array_val).render).to eq("a : [\n # hardcoded value\n 1,\n # hardcoded value\n 2\n]")
563+
expect(config_document.set_config_value("a", array_val).render).to eq("a : [\n 1,\n 2\n]")
564564
end
565565
end
566566

@@ -570,7 +570,7 @@
570570
config_document = ConfigDocumentFactory.parse_string(orig_text)
571571

572572
map = ConfigValueFactory.from_any_ref({"a" => 1, "b" => 2})
573-
expect(config_document.set_config_value("a", map).render).to eq("{ a : {\n # hardcoded value\n \"a\" : 1,\n # hardcoded value\n \"b\" : 2\n } }")
573+
expect(config_document.set_config_value("a", map).render).to eq("{ a : {\n \"a\" : 1,\n \"b\" : 2\n } }")
574574
end
575575
end
576576
end

0 commit comments

Comments
 (0)