censive 0.24 → 0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/censive.gemspec +1 -1
  3. data/lib/censive.rb +6 -41
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76c05b90f6a522a328f86d7d142ed150b33c487e74619707e10f40453c7e9079
4
- data.tar.gz: 1e5a93d293ad708b323e20e1323926f2bf70e219ffc502e8fc87025be7be23b6
3
+ metadata.gz: 576378807981d5da8807494a94c45c7a9c42939f216b579daa97b39bfd179b28
4
+ data.tar.gz: 325e720a55384d7ecee7059b3889e2c401f0bed74bf3a212b44533113017a3a1
5
5
  SHA512:
6
- metadata.gz: e56b1a6a0f943d962ff8c240625a8354283fcbccd1a640cd66054873e1803779ddb36e128841590e8a8aa0022694e1e22a4fa25b6f88eba7056dc68b838262fb
7
- data.tar.gz: 41ddfb9d77a686bef546836d0a110b9603ac7e4f205b7d9760ed37203d23f32f6ba9d2cc5fcb9f8996713fbcdec8fcb924298b1052c1ecc5e9f6442deed3078f
6
+ metadata.gz: 5975a7104ed337ce034e76d322cc6096714cbfd3807261ec127d5c8ed78f438e618d1d72ea1d8e7fa058e561690c63cf4662967f6d5311c100169144e974225f
7
+ data.tar.gz: 359d426bd92041250647aa85c17262b1a6356c49147236c3b6ab86df16c56e87708b09839c74970ccafa17121d80ee764b80824b5723ea3817447ba43d514ae9
data/censive.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "censive"
3
- s.version = "0.24"
3
+ s.version = `grep '^VERSION' lib/censive.rb | cut -f 2 -d '"'`
4
4
  s.author = "Steve Shreeve"
5
5
  s.email = "steve.shreeve@gmail.com"
6
6
  s.summary =
data/lib/censive.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ VERSION="0.25"
4
+
3
5
  # ============================================================================
4
6
  # censive - A quick and lightweight CSV handling library for Ruby
5
7
  #
@@ -36,7 +38,7 @@ class Censive < StringScanner
36
38
 
37
39
  def self.writer(obj=nil, **opts, &code)
38
40
  case obj
39
- when String then File.open(obj, "w") {|io| yield new(out: io, **opts, &code) }
41
+ when String then File.open(obj, "w") {|io| new(out: io, **opts, &code) }
40
42
  when IO,nil then new(out: obj, **opts, &code)
41
43
  else abort "#{File.basename($0)}: invalid #{obj.class} object in writer"
42
44
  end
@@ -71,7 +73,7 @@ class Censive < StringScanner
71
73
  @encoding = str.encoding
72
74
  @excel = excel
73
75
  @mode = mode
74
- @out = out || ""
76
+ @out = out || $stdout
75
77
  @relax = relax
76
78
  @strip = strip
77
79
 
@@ -100,6 +102,8 @@ class Censive < StringScanner
100
102
  @quoted = @excel ? /(?:=)?#{@quote}/o : @quote
101
103
  @unquoted = /[^#{@sep}#{@cr}#{@lf}][^#{@quote}#{@cr}#{@lf}]*/o
102
104
  @leadzero = /\A0\d*\z/
105
+
106
+ yield self if block_given?
103
107
  end
104
108
 
105
109
  def reset(str=nil)
@@ -248,42 +252,3 @@ class Censive < StringScanner
248
252
  abort "\n#{File.basename($0)}: #{msg} at character #{pos} near '#{string[pos-4,7]}'"
249
253
  end
250
254
  end
251
-
252
- if __FILE__ == $0
253
- str = DATA.gets("\n\n").chomp
254
- # str = File.read(ARGV.first || "lc-2023.csv")
255
- # str = File.open("KEN_ALL.CSV", "r:cp932").read
256
-
257
- # require "stringio"
258
- # csv = Censive.new(str, excel: true, relax: true)
259
- # out = "" # StringIO.new
260
- # csv.export(out: out) # (excel: true) # sep: "|")
261
- # puts out # .string
262
-
263
- # csv = Censive.new(str, excel: true, relax: true, out: "")
264
- # out = csv.export
265
- # puts out.out
266
-
267
- puts Censive.parse(str, excel: true, relax: true).to_csv
268
- end
269
-
270
- __END__
271
- "AAA "BBB",CCC,"DDD"
272
-
273
- "CHUI, LOK HANG "BENNY",224325325610,="001453","Hemoglobin A1c",=""
274
- "Don",="007",10,"Ed"
275
- Name,Age,,,Shoe,,,
276
- "Alice",27,5
277
- Bob,33,10 1/2
278
- Charlie or "Chuck",=B2 + B3,9
279
- Subtotal,=sum(B2:B5),="01234"
280
- A,B,C,D
281
- A,B,"C",D
282
- A,B,C",D
283
- A,B,"C",D
284
- 08/27/2022,="73859443",="04043260",,"Crossover @ Mathilda","CHO, JOELLE "JOJO"",08/19/2022
285
- 123,
286
- 123,"CHO, JOELLE "JOJO"",456
287
- 123,"CHO, JOELLE ""JOJO""",456
288
- =,=x,x=,="x",="","","=",123,0123,="123",="0123"
289
- ,=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.24'
4
+ version: '0.25'
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-17 00:00:00.000000000 Z
11
+ date: 2023-03-15 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.6
50
+ rubygems_version: 3.4.8
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: A quick and lightweight CSV handling library for Ruby