censive 1.0.0 → 1.0.2
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/censive.rb +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25f6217fb31687025a210892368bc405a34cc6628a5736f28f02ed02d76d93f1
|
4
|
+
data.tar.gz: daebdb56f27c498e1c0268a2bdc0df927242f193404d1f2bb8dd9995ec1a79ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a1770695f7a9974ab0add960b9f8f6c1430746006899f04245a2dcd6c584a9227b596bd1d6d6a6a3c9d9229a420e7ae69e29944ce08d9fbd3b448fbb2b37c8
|
7
|
+
data.tar.gz: 991e9eca701c3c51ca72c6615bd322b9032b1e7642c96693fa02125629787e15a6193b4ac67b573406d03b0bdc5591e18152ca822d4ea105c8397c243bd42586
|
data/lib/censive.rb
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
require "strscan"
|
29
29
|
|
30
30
|
class Censive < StringScanner
|
31
|
-
VERSION="1.0.
|
31
|
+
VERSION="1.0.2"
|
32
32
|
|
33
33
|
attr :encoding, :out, :rows
|
34
34
|
|
@@ -38,8 +38,8 @@ class Censive < StringScanner
|
|
38
38
|
|
39
39
|
def self.writer(obj=nil, **opts, &code)
|
40
40
|
case obj
|
41
|
-
when String
|
42
|
-
when IO,nil then new(out: obj, **opts, &code)
|
41
|
+
when String then File.open(obj, "w") {|io| new(out: io, **opts, &code) }
|
42
|
+
when StringIO,IO,nil then new(out: obj, **opts, &code)
|
43
43
|
else abort "#{File.basename($0)}: invalid #{obj.class} object in writer"
|
44
44
|
end
|
45
45
|
end
|
@@ -181,7 +181,7 @@ class Censive < StringScanner
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def each
|
184
|
-
@rows
|
184
|
+
@rows or parse
|
185
185
|
@rows.each {|row| yield row }
|
186
186
|
end
|
187
187
|
|
@@ -199,7 +199,7 @@ class Censive < StringScanner
|
|
199
199
|
|
200
200
|
# returns 2 (must be quoted and escaped), 1 (must be quoted), 0 (neither)
|
201
201
|
def grok(str)
|
202
|
-
if idx = str
|
202
|
+
if idx = str&.index(@escapes)
|
203
203
|
$1 ? 2 : str.index(@quote, idx) ? 2 : 1
|
204
204
|
else
|
205
205
|
0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: censive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Shreeve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A quick and lightweight CSV handling library for Ruby
|
14
14
|
email: steve.shreeve@gmail.com
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
rubygems_version: 3.4.
|
50
|
+
rubygems_version: 3.4.1
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: A quick and lightweight CSV handling library for Ruby
|