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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3b944beb4d212490ae2f8900f090869bbbf1783
4
- data.tar.gz: 3d69474c75ca853562dd964956b778220335fbf4
3
+ metadata.gz: f1676094e4f0cad1f9cd41e5051316048b740090
4
+ data.tar.gz: c88fe5e6427bcbef25df5ae2daefc3261d2421fa
5
5
  SHA512:
6
- metadata.gz: f95dcf646a2930f5459fd021eb0751bca932315269977934ef5e444cc59396091a6d68fa57c527fe86e921dad687661ef2690b99514f691c071e678cdae44c6e
7
- data.tar.gz: 075277ab39f967c205400d8a12ca808e81a67df3b375bdd5d63ce45cdc8762e1f8ddb0fa52df57290aa823b4bab35ad809c5869892738a6ad39a17561e882bc2
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 close
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
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  class YamlWriteStream
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -10,13 +10,19 @@ class YamlWriteStream
10
10
  @first = true
11
11
  end
12
12
 
13
- def close
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.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-09-26 00:00:00.000000000 Z
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: