yaml-write-stream 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae8a65b60178d130ae20ab1ed7b69b7da808877b
4
- data.tar.gz: 5bdaf04f74ef81c54d75f61e453a65b09059284f
3
+ metadata.gz: 056601295e460d268a19e94e908ee50e1a6fb839
4
+ data.tar.gz: fc0ab491262017a0e6a55a46ed0d895020fd9f6a
5
5
  SHA512:
6
- metadata.gz: 0a56250ac350ab119588f4a2b86560742ee9df190d0d42601d401f38621c9f9bf3bd5a3fbffdc05199e0d0d3e7e3b0a90ef8c43da6e37f8c001414daeb2e9a19
7
- data.tar.gz: 439293700442a20ca04e47227e352702eb23ae3ba91edd0788f75e260b1cdf7deb459b8e0daa9adf28ab7d13ba1a077f1fcbbb2d33f96f65e226ec69e544fb85
6
+ metadata.gz: c92e3d108d4e7f39ae3ed77e14c3e2c142f12a3f4400413d8aefeb04c4c21c04b229228f2365d2beabd03c9c4312bd85308b5f2f49f7ad29e54c0ec38cf352da
7
+ data.tar.gz: 940295e433a73dcaaaa959882e05bd983e51960b572fe51768532491a60fc17a9fad7a2b25ba8b964c7dc18b60ffee8bb65f7c326189130d8d0132e597267fde
data/History.txt CHANGED
@@ -28,3 +28,7 @@
28
28
  the string would have been dumped either with "non-specific" tag notation (i.e. "!") or
29
29
  without quotes. Both result in an integer when parsed. Now if you want to dump a number
30
30
  as a string, convert it to a string before serializing.
31
+
32
+ == 2.0.1
33
+
34
+ * Quote numeric string keys.
@@ -167,7 +167,8 @@ class YamlWriteStream
167
167
  end
168
168
 
169
169
  def write_key_value(key, value)
170
- write_scalar(key)
170
+ quote_key = !!(key =~ /\A\d+\z/)
171
+ write_scalar(key, quote_key)
171
172
  write_scalar(value, true)
172
173
  end
173
174
 
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  class YamlWriteStream
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
@@ -103,7 +103,8 @@ class YamlWriteStream
103
103
 
104
104
  def write_key_value(key, value)
105
105
  @first = false
106
- write_scalar(key)
106
+ quote_key = !!(key =~ /\A\d+\z/)
107
+ write_scalar(key, quote_key)
107
108
  write_scalar(value, true)
108
109
  end
109
110
  end
@@ -65,6 +65,14 @@ describe YamlWriteStream::YieldingWriter do
65
65
  expect(stream_writer).to be_closed
66
66
  expect(stream).to be_closed
67
67
  end
68
+
69
+ it 'quotes numeric string keys' do
70
+ stream_writer.write_map
71
+ stream_writer.write_key_value('110', 'foo')
72
+ stream_writer.close
73
+
74
+ expect(stream.string).to eq(utf8("\"110\": \"foo\"\n"))
75
+ end
68
76
  end
69
77
 
70
78
  describe '#closed?' do
@@ -71,5 +71,14 @@ describe YamlWriteStream::YieldingWriter do
71
71
  stream_writer.close
72
72
  expect(stream.string).to eq("foo: \n")
73
73
  end
74
+
75
+ it 'quotes numeric string keys' do
76
+ stream_writer.write_map do |map_writer|
77
+ map_writer.write_key_value('110', 'foo')
78
+ end
79
+
80
+ stream_writer.close
81
+ expect(stream.string).to eq(utf8("\"110\": \"foo\"\n"))
82
+ end
74
83
  end
75
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml-write-stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An easy, streaming way to generate YAML.
14
14
  email: