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 +4 -4
- data/lib/csvreader/parser_std.rb +13 -0
- data/lib/csvreader/version.rb +1 -1
- data/test/test_parser_java.rb +2 -2
- 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: f9fafbb8383e3ba0e72b6813fe7ee301e66e9075
|
4
|
+
data.tar.gz: f71ef3a5ca8f1d38437750411411deea844d243a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b7a54d100e575a452551ce0fdc0458986ca19d694e3e2109fa08885437a354b703fdf67661a1ba968930adba4cf2a4083e08641cdafb65cd93599ddf820cabf
|
7
|
+
data.tar.gz: 348f14c961322d9fa5a44d0ae63478b097e5a46786bf7bfa189badf8bf7caafad2a2594ccfbe4f60c7830406f3b724773561b5c1f7883a8f667b4997b4f03179
|
data/lib/csvreader/parser_std.rb
CHANGED
@@ -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)
|
data/lib/csvreader/version.rb
CHANGED
data/test/test_parser_java.rb
CHANGED
@@ -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"
|
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
|
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.
|
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:
|
11
|
+
date: 2019-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tabreader
|