yaml-write-stream 1.0.3 → 1.0.4

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: 5763f8ecccf5b43ed37bb2ba5732a46565f25b37
4
- data.tar.gz: db9ca82e64965b2139d835cc817dfe41d6ce0db3
3
+ metadata.gz: 5150ab0601006ad44967a247d05199fd95a260fa
4
+ data.tar.gz: f512124a33caaf8ca2ea52920ce63879d43d1c8e
5
5
  SHA512:
6
- metadata.gz: e834bb3a518dbae4fa396a70851f8412dcbaaf8dbb033a8c5915e02fadc4759017809305bcc0f36f1ded5df24cb06975fbab864cbd428021be5ba2ca57a1a010
7
- data.tar.gz: 4b6cc1fa51d600039ba57437bd257915d5b17e34c3c6bc98a83c6a43770258abe88d9123492862fd8dce3a5f528a57f49c7588a1e4653b6c1fd1ab78b918e61a
6
+ metadata.gz: 6b0ab08d6209fa31bb09a24168ee03abfc81a4eb852100a57c8e63a7e5f4ec5099f30390e30e5a4414c4a8f3677c5b8fadd3247a29c52d61f684804509d3a357
7
+ data.tar.gz: 198b820deec8fa0383daefa6d13f8055676860a032c7027961732f90645d707a70c45189929ebd8bb10b9fa26e8af8f7fca0c95028e6f2ec9ba1d860523d98cd
data/History.txt CHANGED
@@ -16,3 +16,7 @@
16
16
  blank strings should be wrapped in quotes so YAML parsers know to return a blank string
17
17
  instead of a nil. Eg. foo: should parse as {"foo":nil} while foo: "" should parse as
18
18
  {"foo":""}.
19
+
20
+ == 1.0.4
21
+
22
+ * Mapping values are now wrapped in double quotes by default
@@ -114,11 +114,15 @@ class YamlWriteStream
114
114
  stack.last
115
115
  end
116
116
 
117
- def write_scalar(value)
117
+ def write_scalar(value, quote = false)
118
118
  style = if value == ''
119
119
  Psych::Nodes::Scalar::DOUBLE_QUOTED
120
120
  else
121
- Psych::Nodes::Scalar::ANY
121
+ if !quote || !value
122
+ Psych::Nodes::Scalar::ANY
123
+ else
124
+ Psych::Nodes::Scalar::DOUBLE_QUOTED
125
+ end
122
126
  end
123
127
 
124
128
  quoted = value == ''
@@ -149,7 +153,7 @@ class YamlWriteStream
149
153
 
150
154
  def write_key_value(key, value)
151
155
  write_scalar(key)
152
- write_scalar(value)
156
+ write_scalar(value, true)
153
157
  end
154
158
 
155
159
  def close
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  class YamlWriteStream
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  end
@@ -51,13 +51,17 @@ class YamlWriteStream
51
51
 
52
52
  protected
53
53
 
54
- def write_scalar(value)
54
+ def write_scalar(value, quote = false)
55
55
  @first = false
56
56
 
57
57
  style = if value == ''
58
58
  Psych::Nodes::Scalar::DOUBLE_QUOTED
59
59
  else
60
- Psych::Nodes::Scalar::ANY
60
+ if !quote || !value
61
+ Psych::Nodes::Scalar::ANY
62
+ else
63
+ Psych::Nodes::Scalar::DOUBLE_QUOTED
64
+ end
61
65
  end
62
66
 
63
67
  quoted = value == ''
@@ -84,7 +88,7 @@ class YamlWriteStream
84
88
  def write_key_value(key, value)
85
89
  @first = false
86
90
  write_scalar(key)
87
- write_scalar(value)
91
+ write_scalar(value, true)
88
92
  end
89
93
  end
90
94
 
@@ -31,7 +31,7 @@ describe YamlWriteStream::YieldingWriter do
31
31
  stream_writer.write_key_value('def', 'ghi')
32
32
  stream_writer.close
33
33
 
34
- expect(stream.string).to eq(utf8("- abc\n- def: ghi\n"))
34
+ expect(stream.string).to eq(utf8("- abc\n- def: ! \"ghi\"\n"))
35
35
  expect(stream_writer).to be_closed
36
36
  expect(stream).to be_closed
37
37
  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: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An easy, streaming way to generate YAML.
14
14
  email:
@@ -17,6 +17,10 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - Gemfile
21
+ - History.txt
22
+ - README.md
23
+ - Rakefile
20
24
  - lib/yaml-write-stream.rb
21
25
  - lib/yaml-write-stream/stateful.rb
22
26
  - lib/yaml-write-stream/version.rb
@@ -26,33 +30,28 @@ files:
26
30
  - spec/stateful_spec.rb
27
31
  - spec/yaml-write-stream_spec.rb
28
32
  - spec/yielding_spec.rb
29
- - Gemfile
30
- - History.txt
31
- - README.md
32
- - Rakefile
33
33
  - yaml-write-stream.gemspec
34
34
  homepage: http://github.com/camertron
35
35
  licenses: []
36
36
  metadata: {}
37
- post_install_message:
37
+ post_install_message:
38
38
  rdoc_options: []
39
39
  require_paths:
40
40
  - lib
41
41
  required_ruby_version: !ruby/object:Gem::Requirement
42
42
  requirements:
43
- - - '>='
43
+ - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '>='
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubyforge_project:
53
- rubygems_version: 2.1.9
54
- signing_key:
52
+ rubyforge_project:
53
+ rubygems_version: 2.2.3
54
+ signing_key:
55
55
  specification_version: 4
56
56
  summary: An easy, streaming way to generate YAML.
57
57
  test_files: []
58
- has_rdoc: true