censive 0.28 → 1.0.0
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 +11 -7
 - 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: 246be731b3c88020be3432707b0fb66b8624bc6ebd18b54dae56d813defc7ae9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 13ee5d519f07b82c410a1afcdeaf01678be8e43de894b00e7d6a1bab09e9cf92
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a36473da2784c22dd99a4a414388699942d2bcfcbe87d3883f4efa4234922d99db4aa359102f9f56ae2d94d162d7391ca8caffdbaf3cf550f8a50a00b7b19fc5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 27a07ae5bbcc85c5b48116b935cdd62d39d1b34bf66abf31ab255ab7562ee0fdd1ad44a42990387ee0057a5423175e00117de98c9484564b65e4baea2fda415a
         
     | 
    
        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: Mar  
     | 
| 
      
 7 
     | 
    
         
            +
            #   Date: Mar 22, 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
         
     | 
| 
         @@ -28,7 +28,7 @@ 
     | 
|
| 
       28 
28 
     | 
    
         
             
            require "strscan"
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
            class Censive < StringScanner
         
     | 
| 
       31 
     | 
    
         
            -
              VERSION="0. 
     | 
| 
      
 31 
     | 
    
         
            +
              VERSION="1.0.0"
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
              attr :encoding, :out, :rows
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
         @@ -185,10 +185,14 @@ class Censive < StringScanner 
     | 
|
| 
       185 
185 
     | 
    
         
             
                @rows.each {|row| yield row }
         
     | 
| 
       186 
186 
     | 
    
         
             
              end
         
     | 
| 
       187 
187 
     | 
    
         | 
| 
       188 
     | 
    
         
            -
              def to_csv(**opts)
         
     | 
| 
       189 
     | 
    
         
            -
                 
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
       191 
     | 
    
         
            -
                 
     | 
| 
      
 188 
     | 
    
         
            +
              def to_csv(*args, **opts, &code)
         
     | 
| 
      
 189 
     | 
    
         
            +
                if args.empty? && opts.empty?
         
     | 
| 
      
 190 
     | 
    
         
            +
                  block_given? ? each(&code) : each {|row| @out << row }
         
     | 
| 
      
 191 
     | 
    
         
            +
                elsif block_given?
         
     | 
| 
      
 192 
     | 
    
         
            +
                  Censive.writer(*args, **opts, &code)
         
     | 
| 
      
 193 
     | 
    
         
            +
                else
         
     | 
| 
      
 194 
     | 
    
         
            +
                  Censive.writer(*args, **opts) {|csv| each {|row| csv << row }}
         
     | 
| 
      
 195 
     | 
    
         
            +
                end
         
     | 
| 
       192 
196 
     | 
    
         
             
              end
         
     | 
| 
       193 
197 
     | 
    
         | 
| 
       194 
198 
     | 
    
         
             
              # ==[ Helpers ]==
         
     | 
| 
         @@ -216,7 +220,7 @@ class Censive < StringScanner 
     | 
|
| 
       216 
220 
     | 
    
         
             
                    row
         
     | 
| 
       217 
221 
     | 
    
         
             
                  when 1
         
     | 
| 
       218 
222 
     | 
    
         
             
                    row.map do |col|
         
     | 
| 
       219 
     | 
    
         
            -
                      col 
     | 
| 
      
 223 
     | 
    
         
            +
                      col&.match?(@quotable) ? "#{q}#{col}#{q}" : col
         
     | 
| 
       220 
224 
     | 
    
         
             
                    end
         
     | 
| 
       221 
225 
     | 
    
         
             
                  else
         
     | 
| 
       222 
226 
     | 
    
         
             
                    row.map do |col|
         
     | 
    
        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:  
     | 
| 
      
 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- 
     | 
| 
      
 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. 
     | 
| 
      
 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
         
     |