yaml-write-stream 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/yaml-write-stream/stateful.rb +7 -2
- data/lib/yaml-write-stream/version.rb +1 -1
- data/lib/yaml-write-stream/yielding.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1676094e4f0cad1f9cd41e5051316048b740090
|
4
|
+
data.tar.gz: c88fe5e6427bcbef25df5ae2daefc3261d2421fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9529ece89cebfbf5e9c9665917fc6d8883448208ac2f3c16049c6bc74c341fc7ff97b5c08404fe8922e8b3f865bbcbd39295ab8961277add44b8ede64c93f48
|
7
|
+
data.tar.gz: 127a870309e9e8ebb42a50e5bc09c3f0654dc1e442f9c0d61dc7186b56b864ce5b7616630a85b2320605548213e8b4bea71fba14bb1204690a36db795b1a6b47
|
data/README.md
CHANGED
@@ -99,9 +99,11 @@ Stateful:
|
|
99
99
|
writer = YamlWriteStream.open('path/to/file.yml')
|
100
100
|
writer.write_map
|
101
101
|
...
|
102
|
-
writer.close
|
102
|
+
writer.close # also closes the underlying stream
|
103
103
|
```
|
104
104
|
|
105
|
+
If you'd rather not close the underlying stream, you can call `#flush` instead, which will add necessary closing punctuation but leave the stream open. Once a yaml write stream has been flushed, it should NOT be written to again. Treat flushed streams as if they were closed.
|
106
|
+
|
105
107
|
## Requirements
|
106
108
|
|
107
109
|
Only Ruby 1.9 or greater is supported (requires the Psych emitter).
|
@@ -22,7 +22,7 @@ class YamlWriteStream
|
|
22
22
|
@first = true
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def flush
|
26
26
|
# psych gets confused if you open a file and don't at least
|
27
27
|
# pretend to write something
|
28
28
|
write_scalar('') if first
|
@@ -37,11 +37,16 @@ class YamlWriteStream
|
|
37
37
|
|
38
38
|
emitter.end_document(true)
|
39
39
|
emitter.end_stream
|
40
|
-
stream.close
|
41
40
|
@closed = true
|
42
41
|
nil
|
43
42
|
end
|
44
43
|
|
44
|
+
def close
|
45
|
+
flush
|
46
|
+
stream.close
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
45
50
|
def write_map(*args)
|
46
51
|
check_eos
|
47
52
|
@first = false
|
@@ -10,13 +10,19 @@ class YamlWriteStream
|
|
10
10
|
@first = true
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def flush
|
14
14
|
# psych gets confused if you open a file and don't at least
|
15
15
|
# pretend to write something
|
16
16
|
write_scalar('') if first
|
17
17
|
emitter.end_document(true)
|
18
18
|
emitter.end_stream
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def close
|
23
|
+
flush
|
19
24
|
stream.close
|
25
|
+
nil
|
20
26
|
end
|
21
27
|
|
22
28
|
def write_sequence
|
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.
|
4
|
+
version: 1.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: 2014-
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An easy, streaming way to generate YAML.
|
14
14
|
email:
|