csvh 0.5.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de3ee5b1fa4dbe3dd0a91b897e8476e2fa40f3c
4
- data.tar.gz: d3946dba3e4bdfd5dbbf1b68012c7b7666fed29f
3
+ metadata.gz: a6323cad1ddf79e484199f5830eb10076b61d04f
4
+ data.tar.gz: 779978ad240f9f0a2b1a46f3e316aad5d460f167
5
5
  SHA512:
6
- metadata.gz: f452f83e37f35367181c27cf092864a4e91f431295bc39d96b850d513268f36d59a0e78c81725cea6f4df2cc82fb205a5e7ab380713b970416a809d692d275d5
7
- data.tar.gz: 08a81b08f521c2bb14adc7fe858b21e4ef05172b9e48277a43efbe4b3607ef43678c22dd8260ef1fe0c0920e75b103c40c8a34641c18fa66576db08442d5e548
6
+ metadata.gz: 9bc569b2cb0d5008214c42c43fb2f897d67ad44278da745636797cd369bb88ff0e15bc7d60bf5551dead5bd57d5ed414c39cba7d7a1dab35dadd9fed366b05ff
7
+ data.tar.gz: ea02ecde2fe229c2551654ff898c02128aff2bbed72796f28712de20664eda7247e42ea329255de28a70f2d6074aafaa263519e7837fed8109593ff9d26f9af3
@@ -30,6 +30,38 @@ module CSVH
30
30
  # return the header row. Any oadditional options you supply
31
31
  # will be added to those defaults or override them.
32
32
  #
33
+ # A [Reader] created using this method will delegate all
34
+ # of the same IO methods that a `CSV` created using
35
+ # `CSV#open` does except `close_write`, `flush`, `fsync`,
36
+ # `sync`, `sync=`, and `truncate`. You may call:
37
+ #
38
+ # * binmode()
39
+ # * binmode?()
40
+ # * close()
41
+ # * close_read()
42
+ # * closed?()
43
+ # * eof()
44
+ # * eof?()
45
+ # * external_encoding()
46
+ # * fcntl()
47
+ # * fileno()
48
+ # * flock()
49
+ # * flush()
50
+ # * internal_encoding()
51
+ # * ioctl()
52
+ # * isatty()
53
+ # * path()
54
+ # * pid()
55
+ # * pos()
56
+ # * pos=()
57
+ # * reopen()
58
+ # * seek()
59
+ # * fstat()
60
+ # * tell()
61
+ # * to_i()
62
+ # * to_io()
63
+ # * tty?()
64
+ #
33
65
  # @param file_path [String] the path of the file to read.
34
66
  # @param opts options for `CSV.new`.
35
67
  # @yieldparam [Reader] the new reader.
@@ -119,17 +151,60 @@ module CSVH
119
151
  end
120
152
  end
121
153
 
154
+ # These methods always delegate to CSV, which may or may not
155
+ # futher delegate them to its underlying file IO object,
156
+ # depending on how it was created.
157
+
122
158
  def_delegators \
123
159
  :@csv,
160
+ :binmode,
161
+ :binmode?,
162
+ :close_read,
124
163
  :close,
125
- :closed?
164
+ :closed?,
165
+ :eof,
166
+ :eof?,
167
+ :external_encoding,
168
+ :fcntl,
169
+ :fileno,
170
+ :flock,
171
+ :flush,
172
+ :internal_encoding,
173
+ :ioctl,
174
+ :isatty,
175
+ :path,
176
+ :pid,
177
+ :pos,
178
+ :pos=,
179
+ :reopen,
180
+ :seek,
181
+ :fstat,
182
+ :tell,
183
+ :to_i,
184
+ :to_io,
185
+ :tty?
186
+
187
+ # You can use this method to install a `CSV::Converters`
188
+ # built-in, or provide a block that handles a custom
189
+ # conversion.
190
+ #
191
+ # See the documentation for `CSV` in the Ruby standard
192
+ # library for more details.
193
+ def_delegator :@csv, :convert
194
+
195
+ # Returns the current list of converters in effect.
196
+ #
197
+ # See the documentation for `CSV` in the Ruby standard
198
+ # library for more details.
199
+ def_delegator :@csv, :converters
126
200
 
127
- # When given a block, yields each data row of the data source
128
- # in turn as `CSV::Row` instances. When called without a
129
- # block, returns an Enumerator over those rows.
201
+ # When given a block, yields each remaining data row of the
202
+ # data source in turn as a `CSV::Row` instance. When called
203
+ # without a block, returns an Enumerator over those rows.
130
204
  #
131
- # Does not yield the header row, however, the headers are
132
- # available via the #headers method of the reader or the row.
205
+ # Will never yield the header row, however, the headers are
206
+ # available via the #headers method of either the reader or
207
+ # the row object.
133
208
  #
134
209
  # @yieldparam [CSV::Row]
135
210
  def each
@@ -141,6 +216,76 @@ module CSVH
141
216
  end
142
217
  end
143
218
 
219
+ # Returns `true` if all output fields are quoted.
220
+ #
221
+ # See the documentation for `CSV` in the Ruby standard
222
+ # library for more details.
223
+ def_delegator :@csv, :force_quotes?
224
+
225
+ # Identical to #convert, but for header rows.
226
+ #
227
+ # Note that this must be called before reading any rows or
228
+ # calling #headers to have any effect.
229
+ #
230
+ # See the documentation for `CSV` in the Ruby standard
231
+ # library for more details.
232
+ def_delegator :@csv, :header_convert
233
+
234
+ # Returns the current list of converters in effect for
235
+ # headers.
236
+ #
237
+ # See the documentation for `CSV` in the Ruby standard
238
+ # library for more details.
239
+ def_delegator :@csv, :header_converters
240
+
241
+ # Slurps the remaining data rows and returns a `CSV::Table`.
242
+ #
243
+ # This is essentially the same behavior as `CSV#read`, but
244
+ # ensures that the header info has been fetched first, and the
245
+ # resulting table will never include the header row.
246
+ #
247
+ # Note that the Ruby documentation (at least as of 2.2.2) is
248
+ # for `CSV#read` is incomplete and simply says that it
249
+ # returns "an Array of Arrays", but it actually returns a
250
+ # table if a truthy `:headers` option was used when creating
251
+ # the `CSV` object.
252
+ #
253
+ # @return [CSV::Table] a table of remaining unread rows
254
+ def read
255
+ headers
256
+ @csv.read
257
+ end
258
+
259
+ alias readlines read
260
+
261
+ # A single data row is pulled from the data source, parsed
262
+ # and returned as a CSV::Row.
263
+ #
264
+ # This is essentially the same behavior as `CSV#shift`, but
265
+ # ensures that the header info has been fetched first, and
266
+ # #shift will never return the header row.
267
+ #
268
+ # @return [CSV::Row] the next previously unread row
269
+ def shift
270
+ headers
271
+ @csv.shift
272
+ end
273
+
274
+ alias gets shift
275
+ alias readline shift
276
+
277
+ # Returns `true` if blank lines are skipped by the parser.
278
+ #
279
+ # See the documentation for `CSV` in the Ruby standard
280
+ # library for more details.
281
+ def_delegator :@csv, :skip_blanks?
282
+
283
+ # Returns `true` if `unconverted_fields()` to parsed results.
284
+ #
285
+ # See the documentation for `CSV` in the Ruby standard
286
+ # library for more details.
287
+ def_delegator :@csv, :unconverted_fields?
288
+
144
289
  end
145
290
 
146
291
  end
@@ -1,3 +1,3 @@
1
1
  module CSVH
2
- VERSION = "0.5.1"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Jorgensen