csvreader 1.2.3 → 1.2.4

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: e54c57c44e895f8daacd12261b87195ab0ab6cd2
4
- data.tar.gz: b63d0d183d98c3ab1f291e3bdf6168e0d5bd39fc
3
+ metadata.gz: f9fafbb8383e3ba0e72b6813fe7ee301e66e9075
4
+ data.tar.gz: f71ef3a5ca8f1d38437750411411deea844d243a
5
5
  SHA512:
6
- metadata.gz: 06756ee95e4810ded31be95abb5136bf0d0c8d7b79e2e19df483590bac051b449daee4f6178571bf177635ec35847220d859a6b5ba72068325710f022dbb6115
7
- data.tar.gz: 884f5eff36a5d4cf03e1d7d5bab3a53632361ad6a7ab09ce16a502c0d25f25dcfea025efa8d79e8127fd735627683c3d8a91f22e3c03cf3d033ff7e64d7004b0
6
+ metadata.gz: 0b7a54d100e575a452551ce0fdc0458986ca19d694e3e2109fa08885437a354b703fdf67661a1ba968930adba4cf2a4083e08641cdafb65cd93599ddf820cabf
7
+ data.tar.gz: 348f14c961322d9fa5a44d0ae63478b097e5a46786bf7bfa189badf8bf7caafad2a2594ccfbe4f60c7830406f3b724773561b5c1f7883a8f667b4997b4f03179
@@ -223,6 +223,8 @@ def parse_field( input, sep: )
223
223
  value = ""
224
224
 
225
225
  numeric = config[:numeric]
226
+ hashtag = config[:hashtag]
227
+
226
228
 
227
229
  logger.debug "parse field" if logger.debug?
228
230
 
@@ -301,6 +303,17 @@ def parse_field( input, sep: )
301
303
  while (c=input.peek; !(c==sep || c==LF || c==CR || input.eof?))
302
304
  if input.peek == BACKSLASH
303
305
  value << parse_escape( input, sep: sep )
306
+ ### check for end-of-line comments (e.g. # ...)
307
+ ## note: quick hack for now
308
+ ## will NOT work in hashtag (hxl) mode and for % comments
309
+ ## for now ALWAYS assumes # for comments
310
+ ## and end-of-line comments ONLY work here (that is, in unquoted values and NOT in quotes values) for now
311
+ ## todo/fix: note: require leading space for comment hash (#) for now- why? why not?
312
+ ## require trailing space after comment hash (#) - why? why not?
313
+ elsif (hashtag == false || hashtag.nil?) && input.peek == COMMENT_HASH &&
314
+ (value.size == 0 || (value.size > 0 && value[-1] == ' '))
315
+ ## eat-up everything until end-of-line (eol)
316
+ skip_until_eol( input )
304
317
  else
305
318
  logger.debug " add char >#{input.peek}< (#{input.peek.ord})" if logger.debug?
306
319
  value << input.getc ## note: eat-up all spaces (" ") and tabs (\t) too (strip trailing spaces at the end)
@@ -6,7 +6,7 @@ class CsvReader ## note: uses a class for now - change to module - why? why no
6
6
  module Version
7
7
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
8
8
  MINOR = 2
9
- PATCH = 3
9
+ PATCH = 4
10
10
 
11
11
  ## self.to_s - why? why not?
12
12
  end
@@ -60,11 +60,11 @@ end
60
60
  def test_comments
61
61
  assert_equal [["first", "line", "" ],
62
62
  ["second", "line", "tokenWith#no-comment" ],
63
- ["third", "line", "#no-comment" ]],
63
+ ["third", "line" ]],
64
64
  parser.default.parse( "first,line,\n" +
65
65
  "second,line,tokenWith#no-comment\n" +
66
66
  "# comment line \n" +
67
- "third,line,#no-comment\n" +
67
+ "third,line #inline-end-of-line-comment\n" +
68
68
  "# penultimate comment\n" +
69
69
  "# Final comment\n" )
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvreader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-24 00:00:00.000000000 Z
11
+ date: 2019-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tabreader