Skip to content

Commit 061ebce

Browse files
authored
Merge pull request #8 from fnordfish/dump-symbol-values-as-string
Dump Symbol values as String
2 parents f0f697b + 102e5ed commit 061ebce

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

lib/tomlib/dumper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ def to_toml_value(value)
155155
case value
156156
when String
157157
escape_string(value)
158+
when Symbol
159+
escape_string(value.to_s)
158160
when Float, BigDecimal
159161
to_toml_float(value)
160162
when Time, DateTime
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo = "bar"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo: :bar

spec/tomlib_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_case_to_hash(data)
108108
json = toml.gsub('.toml', '.json')
109109

110110
if File.exist?(yaml)
111-
hash = YAML.safe_load(File.read(yaml), permitted_classes: [Date, Time])
111+
hash = YAML.safe_load(File.read(yaml), permitted_classes: [Date, Time, Symbol])
112112
else
113113
hash = test_case_to_hash(JSON.parse(File.read(json)))
114114
end

0 commit comments

Comments
 (0)