censive 0.29 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/censive.rb +41 -2
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ab03fca630d441eb0d600137017738fe47949b1b333ddb92d82bd690b9015ef
4
- data.tar.gz: e864e8e08e27abd92852a6cf28f1a54e09454c421023e004a6222f428a874b81
3
+ metadata.gz: 246be731b3c88020be3432707b0fb66b8624bc6ebd18b54dae56d813defc7ae9
4
+ data.tar.gz: 13ee5d519f07b82c410a1afcdeaf01678be8e43de894b00e7d6a1bab09e9cf92
5
5
  SHA512:
6
- metadata.gz: c412bd6870fb5e577436d055cea945905ebc3ab2f74df43ca678eb5bc0c26c9e1d7a4ecb43f10f8896d5735799f64fce2d3f33ee347e454b6840b4ce054d09dc
7
- data.tar.gz: 968a53df8658a96b6f2c74d9e3dd868320028630d7b92c3e7068e3ef52894181cf76283e5516c10cb0df3f711e99896513cb5455db490bff5ee4dca5ac7f33f4
6
+ metadata.gz: a36473da2784c22dd99a4a414388699942d2bcfcbe87d3883f4efa4234922d99db4aa359102f9f56ae2d94d162d7391ca8caffdbaf3cf550f8a50a00b7b19fc5
7
+ data.tar.gz: 27a07ae5bbcc85c5b48116b935cdd62d39d1b34bf66abf31ab255ab7562ee0fdd1ad44a42990387ee0057a5423175e00117de98c9484564b65e4baea2fda415a
data/lib/censive.rb CHANGED
@@ -28,7 +28,7 @@
28
28
  require "strscan"
29
29
 
30
30
  class Censive < StringScanner
31
- VERSION="0.29"
31
+ VERSION="1.0.0"
32
32
 
33
33
  attr :encoding, :out, :rows
34
34
 
@@ -220,7 +220,7 @@ class Censive < StringScanner
220
220
  row
221
221
  when 1
222
222
  row.map do |col|
223
- col.match?(@quotable) ? "#{q}#{col}#{q}" : col
223
+ col&.match?(@quotable) ? "#{q}#{col}#{q}" : col
224
224
  end
225
225
  else
226
226
  row.map do |col|
@@ -257,3 +257,42 @@ class Censive < StringScanner
257
257
  abort "\n#{File.basename($0)}: #{msg} at character #{pos} near '#{string[pos-4,7]}'"
258
258
  end
259
259
  end
260
+
261
+ if __FILE__ == $0
262
+ str = DATA.gets("\n\n").chomp
263
+ # str = File.read(ARGV.first || "lc-2023.csv")
264
+ # str = File.open("KEN_ALL.CSV", "r:cp932").read
265
+
266
+ # require "stringio"
267
+ # csv = Censive.new(str, excel: true, relax: true)
268
+ # out = "" # StringIO.new
269
+ # csv.export(out: out) # (excel: true) # sep: "|")
270
+ # puts out # .string
271
+
272
+ # csv = Censive.new(str, excel: true, relax: true, out: "")
273
+ # out = csv.export
274
+ # puts out.out
275
+
276
+ puts Censive.parse(str, excel: true, relax: true).to_csv
277
+ end
278
+
279
+ __END__
280
+ "AAA "BBB",CCC,"DDD"
281
+
282
+ "CHUI, LOK HANG "BENNY",224325325610,="001453","Hemoglobin A1c",=""
283
+ "Don",="007",10,"Ed"
284
+ Name,Age,,,Shoe,,,
285
+ "Alice",27,5
286
+ Bob,33,10 1/2
287
+ Charlie or "Chuck",=B2 + B3,9
288
+ Subtotal,=sum(B2:B5),="01234"
289
+ A,B,C,D
290
+ A,B,"C",D
291
+ A,B,C",D
292
+ A,B,"C",D
293
+ 08/27/2022,="73859443",="04043260",,"Crossover @ Mathilda","CHO, JOELLE "JOJO"",08/19/2022
294
+ 123,
295
+ 123,"CHO, JOELLE "JOJO"",456
296
+ 123,"CHO, JOELLE ""JOJO""",456
297
+ =,=x,x=,="x",="","","=",123,0123,="123",="0123"
298
+ ,=x,x=,x,,,,,,=,,123,="0123",123,,="0123"
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: '0.29'
4
+ version: 1.0.0
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-03-22 00:00:00.000000000 Z
11
+ date: 2023-03-30 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.9
50
+ rubygems_version: 3.4.10
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: A quick and lightweight CSV handling library for Ruby