censive 0.22 → 0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f9bbebb5cd4aba5b0d22ec2f87e129a47292fc999ada61284ea53e5458c1d42
4
- data.tar.gz: 9db7f322767ab0fe4275e2c40c0e466dd3654b1180aed55a4aa8826bddee3f78
3
+ metadata.gz: 5a787932ff608f1df361b6faca419ce69eac2cafe853aa7c16155c5f2ace4621
4
+ data.tar.gz: 1818249a3e778223297adaff85216c6497d2f802c25e77664ec1525e51dc9d2d
5
5
  SHA512:
6
- metadata.gz: a6b3eda844db32d8f50a9972eff3a2c1d690dc8bdcc0eb0276df6dea722d6a45790236e2b0dfaceb17555e153ce44f54c7b18df961babea70ac764ca03aeffa5
7
- data.tar.gz: f3c153d47ddc3e2e27be33407d0ca9159776590d42b79e4cfa41c932b9cde3daa3dfdc68de238b3e34a243bc6aff4cfc34df7cc0a1b1aafc27cd0a77c185a8fa
6
+ metadata.gz: 9ecf977a34e9cd5f86fdc8843aa64b2212bcf608a30eef579593e5af5d3c9ab00164d0dac1030738898ccfe4b541366d711ac8a029b2f907071c113543d10003
7
+ data.tar.gz: 90780a1b7ca9be28eb7e83392ba00f0d4a7374c05b91845605cf9f8c64d58d5e187d468de96dfabe2126f331944ca94b4d4f5af286750c054db13731bfe8830d
data/censive.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "censive"
3
- s.version = "0.22"
3
+ s.version = "0.23"
4
4
  s.author = "Steve Shreeve"
5
5
  s.email = "steve.shreeve@gmail.com"
6
6
  s.summary =
data/lib/censive.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  # censive - A quick and lightweight CSV handling library for Ruby
5
5
  #
6
6
  # Author: Steve Shreeve (steve.shreeve@gmail.com)
7
- # Date: Feb 14, 2023
7
+ # Date: Feb 17, 2023
8
8
  #
9
9
  # https://crystal-lang.org/api/1.7.2/CSV.html (Crystal's CSV library)
10
10
  # https://github.com/ruby/strscan/blob/master/ext/strscan/strscan.c
@@ -46,11 +46,11 @@ class Censive < StringScanner
46
46
  drop: false , # drop trailing empty columns?
47
47
  encoding: nil , # character encoding
48
48
  excel: false , # literals ="01" formulas =A1 + B2 http://bit.ly/3Y7jIvc
49
- mode: :compact, # export mode: compact or full
49
+ mode: :compact, # output mode: compact or full
50
50
  out: nil , # output stream, needs to respond to <<
51
51
  quote: '"' , # quote character
52
52
  relax: false , # relax quote parsing so ,"Fo"o, => ,"Fo""o",
53
- rowsep: "\n" , # row separator for export
53
+ rowsep: "\n" , # row separator for output
54
54
  sep: "," , # column separator character
55
55
  strip: false , # strip columns when reading
56
56
  **opts # grab bag
@@ -71,7 +71,7 @@ class Censive < StringScanner
71
71
  @encoding = str.encoding
72
72
  @excel = excel
73
73
  @mode = mode
74
- @out = out || $stdout
74
+ @out = out || ""
75
75
  @relax = relax
76
76
  @strip = strip
77
77
 
@@ -121,7 +121,7 @@ class Censive < StringScanner
121
121
  @cols = count if count > @cols
122
122
  @cells += count
123
123
  end
124
- @rows
124
+ self
125
125
  end
126
126
 
127
127
  def next_row
@@ -179,10 +179,10 @@ class Censive < StringScanner
179
179
  @rows.each {|row| yield row }
180
180
  end
181
181
 
182
- def export(**opts)
182
+ def to_csv(**opts)
183
183
  dest = opts.empty? ? self : self.class.writer(**opts)
184
184
  each {|row| dest << row }
185
- dest
185
+ dest.out
186
186
  end
187
187
 
188
188
  # ==[ Helpers ]==
@@ -259,9 +259,11 @@ if __FILE__ == $0
259
259
  # csv.export(out: out) # (excel: true) # sep: "|")
260
260
  # puts out # .string
261
261
 
262
- csv = Censive.new(str, excel: true, relax: true, out: "")
263
- out = csv.export
264
- puts out.out
262
+ # csv = Censive.new(str, excel: true, relax: true, out: "")
263
+ # out = csv.export
264
+ # puts out.out
265
+
266
+ Censive.parse(str, excel: true, relax: true).to_csv
265
267
  end
266
268
 
267
269
  __END__
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.22'
4
+ version: '0.23'
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-02-14 00:00:00.000000000 Z
11
+ date: 2023-02-17 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
@@ -19,7 +19,6 @@ files:
19
19
  - LICENSE
20
20
  - README.md
21
21
  - censive.gemspec
22
- - diagram/NFA to Regex.pdf
23
22
  - diagram/censive@ce9d51d.png
24
23
  - diagram/csv-ragel.dot
25
24
  - diagram/csv.dot
@@ -29,9 +28,6 @@ files:
29
28
  - diagram/diagram.dot
30
29
  - diagram/diagram.rl
31
30
  - lib/censive.rb
32
- - lib/test-censive.rb
33
- - lib/test-csv.rb
34
- - test/a-uses-tabs-and-single-quotes-and-no-trailing-newline.tsv
35
31
  homepage: https://github.com/shreeve/censive
36
32
  licenses:
37
33
  - MIT
Binary file
data/lib/test-censive.rb DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "./censive"
4
- require "digest/md5"
5
-
6
- path = ARGV[0] || "KEN_ALL.CSV"
7
- mode = path =~ /^ken/i ? "r:cp932" : "r"
8
-
9
- data = File.open(path, mode).read
10
- rows = Censive.parse(data)
11
-
12
- puts "%s %s (%d size)" % [Digest::MD5.hexdigest(rows.join), path, File.stat(path).size], ""
data/lib/test-csv.rb DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "csv"
4
- require "digest/md5"
5
-
6
- path = ARGV[0] || "KEN_ALL.CSV"
7
- mode = path =~ /^ken/i ? "r:cp932" : "r"
8
-
9
- data = File.open(path, mode).read
10
- rows = CSV.parse(data)
11
-
12
- puts "%s %s (%d size)" % [Digest::MD5.hexdigest(rows.join), path, File.stat(path).size], ""
@@ -1,3 +0,0 @@
1
- age name
2
- 5 'Mike the ''man!'''
3
- 10 Tommy