osv 0.4.4-x86_64-linux-musl
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 +7 -0
 - data/Gemfile +14 -0
 - data/LICENSE +21 -0
 - data/README.md +176 -0
 - data/Rakefile +42 -0
 - data/lib/osv/3.2/osv.so +0 -0
 - data/lib/osv/3.3/osv.so +0 -0
 - data/lib/osv/3.4/osv.so +0 -0
 - data/lib/osv/version.rb +3 -0
 - data/lib/osv.rb +10 -0
 - data/lib/osv.rbi +56 -0
 - metadata +81 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d6747117ae8fbacec9229ff9c3d6f96e4c08ae32635f65b929e109c9fe66c197
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 843891956c678a14900935ab4de46e72d2b87e99a979162757613b3c8bd5650b
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9409486c47ccc16741964f0c2e9f2b41bbd6c7cd62b653d4146608723c603d96f082a00836204dea4b32cb490096021fb401c63de6e81151fdde29b500a04df4
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d83e41f6c247a8dbe80eaf5a25ff7aec69bcadc1b309556082fe14b1c9a75c4ffa86c64bf33ea159a2475a839dc2e12863552131b37202c90de73560438abcbb
         
     | 
    
        data/Gemfile
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem "rb_sys", "~> 0.9.56"
         
     | 
| 
      
 4 
     | 
    
         
            +
            gem "rake"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Use local version of osv
         
     | 
| 
      
 7 
     | 
    
         
            +
            gemspec
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            group :development, :test do
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem "csv"
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem "minitest", "~> 5.0"
         
     | 
| 
      
 12 
     | 
    
         
            +
              gem "benchmark-ips", "~> 2.12"
         
     | 
| 
      
 13 
     | 
    
         
            +
              gem "fastcsv", "~> 0.0.7"
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2024 Nathan Jaremko
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
      
 13 
     | 
    
         
            +
            copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         
     | 
| 
      
 21 
     | 
    
         
            +
            SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,176 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # OSV
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://badge.fury.io/rb/osv)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            OSV is a high-performance CSV parser for Ruby, implemented in Rust. It wraps BurntSushi's excellent [csv-rs](https://github.com/BurntSushi/rust-csv) crate.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            It provides a simple interface for reading CSV files with support for both hash-based and array-based row formats.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            The array-based mode is faster than the hash-based mode, so if you don't need the hash keys, use the array-based mode.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 16 
     | 
    
         
            +
            gem 'osv'
         
     | 
| 
      
 17 
     | 
    
         
            +
            ```
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 22 
     | 
    
         
            +
            bundle install
         
     | 
| 
      
 23 
     | 
    
         
            +
            ```
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            Or install it directly:
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 28 
     | 
    
         
            +
            gem install osv
         
     | 
| 
      
 29 
     | 
    
         
            +
            ```
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ### Reading CSV Files
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 36 
     | 
    
         
            +
            require 'osv'
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            # Basic usage - each row as a hash
         
     | 
| 
      
 39 
     | 
    
         
            +
            OSV.for_each("data.csv") do |row|
         
     | 
| 
      
 40 
     | 
    
         
            +
              puts row["name"]  # => "John"
         
     | 
| 
      
 41 
     | 
    
         
            +
              puts row["age"]   # => "25"
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            # Return an enumerator instead of using a block
         
     | 
| 
      
 45 
     | 
    
         
            +
            rows = OSV.for_each("data.csv")
         
     | 
| 
      
 46 
     | 
    
         
            +
            rows.each { |row| puts row["name"] }
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            # High-performance array mode
         
     | 
| 
      
 49 
     | 
    
         
            +
            OSV.for_each("data.csv", result_type: :array) do |row|
         
     | 
| 
      
 50 
     | 
    
         
            +
              puts row[0]  # First column
         
     | 
| 
      
 51 
     | 
    
         
            +
              puts row[1]  # Second column
         
     | 
| 
      
 52 
     | 
    
         
            +
            end
         
     | 
| 
      
 53 
     | 
    
         
            +
            ```
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            ### Input Sources
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 58 
     | 
    
         
            +
            # From a file path
         
     | 
| 
      
 59 
     | 
    
         
            +
            OSV.for_each("data.csv") { |row| puts row["name"] }
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            # From a file path
         
     | 
| 
      
 62 
     | 
    
         
            +
            OSV.for_each("data.csv.gz") { |row| puts row["name"] }
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            # From an IO object
         
     | 
| 
      
 65 
     | 
    
         
            +
            File.open("data.csv") { |file| OSV.for_each(file) { |row| puts row["name"] } }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            # From a string
         
     | 
| 
      
 68 
     | 
    
         
            +
            data = StringIO.new("name,age\nJohn,25")
         
     | 
| 
      
 69 
     | 
    
         
            +
            OSV.for_each(data) { |row| puts row["name"] }
         
     | 
| 
      
 70 
     | 
    
         
            +
            ```
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            ### Configuration Options
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 75 
     | 
    
         
            +
            OSV.for_each("data.csv",
         
     | 
| 
      
 76 
     | 
    
         
            +
              # Input formatting
         
     | 
| 
      
 77 
     | 
    
         
            +
              has_headers: true,     # First row contains headers (default: true)
         
     | 
| 
      
 78 
     | 
    
         
            +
              col_sep: ",",          # Column separator (default: ",")
         
     | 
| 
      
 79 
     | 
    
         
            +
              quote_char: '"',       # Quote character (default: '"')
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              # Output formatting
         
     | 
| 
      
 82 
     | 
    
         
            +
              result_type: :hash,    # :hash or :array (hash is default)
         
     | 
| 
      
 83 
     | 
    
         
            +
              nil_string: nil,       # String to interpret as nil when parsing (default: nil)
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              # Parsing behavior
         
     | 
| 
      
 86 
     | 
    
         
            +
              flexible: false,       # Allow varying number of fields (default: false)
         
     | 
| 
      
 87 
     | 
    
         
            +
              trim: :all,            # Whether to trim whitespace. Options are :all, :headers, or :fields (default: nil)
         
     | 
| 
      
 88 
     | 
    
         
            +
              buffer_size: 1024,     # Number of rows to buffer in memory (default: 1024)
         
     | 
| 
      
 89 
     | 
    
         
            +
              ignore_null_bytes: false, # Boolean specifying if null bytes should be ignored (default: false)
         
     | 
| 
      
 90 
     | 
    
         
            +
              lossy: false,             # Boolean specifying if invalid UTF-8 characters should be replaced with a replacement character (default: false)
         
     | 
| 
      
 91 
     | 
    
         
            +
            )
         
     | 
| 
      
 92 
     | 
    
         
            +
            ```
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            #### Available Options
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            - `has_headers`: Boolean indicating if the first row contains headers (default: true)
         
     | 
| 
      
 97 
     | 
    
         
            +
            - `col_sep`: String specifying the field separator (default: ",")
         
     | 
| 
      
 98 
     | 
    
         
            +
            - `quote_char`: String specifying the quote character (default: "\"")
         
     | 
| 
      
 99 
     | 
    
         
            +
            - `nil_string`: String that should be interpreted as nil
         
     | 
| 
      
 100 
     | 
    
         
            +
              - by default, empty strings are interpreted as empty strings
         
     | 
| 
      
 101 
     | 
    
         
            +
              - if you want to interpret empty strings as nil, set this to an empty string
         
     | 
| 
      
 102 
     | 
    
         
            +
            - `buffer_size`: Integer specifying the number of rows to buffer in memory (default: 1024)
         
     | 
| 
      
 103 
     | 
    
         
            +
            - `result_type`: String specifying the output format ("hash" or "array" or :hash or :array)
         
     | 
| 
      
 104 
     | 
    
         
            +
            - `flexible`: Boolean specifying if the parser should be flexible (default: false)
         
     | 
| 
      
 105 
     | 
    
         
            +
            - `trim`: String specifying the trim mode ("all" or "headers" or "fields" or :all or :headers or :fields)
         
     | 
| 
      
 106 
     | 
    
         
            +
            - `ignore_null_bytes`: Boolean specifying if null bytes should be ignored (default: false)
         
     | 
| 
      
 107 
     | 
    
         
            +
            - `lossy`: Boolean specifying if invalid UTF-8 characters should be replaced with a replacement character (default: false)
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            When `has_headers` is false, hash keys will be generated as `"c0"`, `"c1"`, etc.
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            ## Requirements
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            - Ruby >= 3.1.0
         
     | 
| 
      
 114 
     | 
    
         
            +
            - Rust toolchain (for installation from source)
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
            ## Performance
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            This library is faster than the standard Ruby CSV library. It's also faster than any other CSV gem I've been able to find.
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            Here's some unscientific benchmarks. You can find the code in the [benchmark/comparison_benchmark.rb](benchmark/comparison_benchmark.rb) file.
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            ### 1,000,000 records
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            ```
         
     | 
| 
      
 125 
     | 
    
         
            +
            🏃 Running benchmarks...
         
     | 
| 
      
 126 
     | 
    
         
            +
            Benchmarking with 3000001 lines of data
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            ruby 3.3.6 (2024-11-05 revision 75015d4c1f) +YJIT [arm64-darwin24]
         
     | 
| 
      
 129 
     | 
    
         
            +
            Warming up --------------------------------------
         
     | 
| 
      
 130 
     | 
    
         
            +
                  CSV - StringIO     1.000 i/100ms
         
     | 
| 
      
 131 
     | 
    
         
            +
              FastCSV - StringIO     1.000 i/100ms
         
     | 
| 
      
 132 
     | 
    
         
            +
                  OSV - StringIO     1.000 i/100ms
         
     | 
| 
      
 133 
     | 
    
         
            +
               CSV - Hash output     1.000 i/100ms
         
     | 
| 
      
 134 
     | 
    
         
            +
               OSV - Hash output     1.000 i/100ms
         
     | 
| 
      
 135 
     | 
    
         
            +
              CSV - Array output     1.000 i/100ms
         
     | 
| 
      
 136 
     | 
    
         
            +
              OSV - Array output     1.000 i/100ms
         
     | 
| 
      
 137 
     | 
    
         
            +
            FastCSV - Array output
         
     | 
| 
      
 138 
     | 
    
         
            +
                                     1.000 i/100ms
         
     | 
| 
      
 139 
     | 
    
         
            +
            OSV - Direct Open Array output
         
     | 
| 
      
 140 
     | 
    
         
            +
                                     1.000 i/100ms
         
     | 
| 
      
 141 
     | 
    
         
            +
                   OSV - Gzipped     1.000 i/100ms
         
     | 
| 
      
 142 
     | 
    
         
            +
            OSV - Gzipped Direct     1.000 i/100ms
         
     | 
| 
      
 143 
     | 
    
         
            +
               FastCSV - Gzipped     1.000 i/100ms
         
     | 
| 
      
 144 
     | 
    
         
            +
                   CSV - Gzipped     1.000 i/100ms
         
     | 
| 
      
 145 
     | 
    
         
            +
            Calculating -------------------------------------
         
     | 
| 
      
 146 
     | 
    
         
            +
                  CSV - StringIO      0.083 (± 0.0%) i/s    (12.06 s/i) -      3.000 in  36.304469s
         
     | 
| 
      
 147 
     | 
    
         
            +
              FastCSV - StringIO      0.335 (± 0.0%) i/s     (2.98 s/i) -     10.000 in  31.019521s
         
     | 
| 
      
 148 
     | 
    
         
            +
                  OSV - StringIO      0.705 (± 0.0%) i/s     (1.42 s/i) -     21.000 in  30.629511s
         
     | 
| 
      
 149 
     | 
    
         
            +
               CSV - Hash output      0.060 (± 0.0%) i/s    (16.74 s/i) -      2.000 in  33.475977s
         
     | 
| 
      
 150 
     | 
    
         
            +
               OSV - Hash output      0.434 (± 0.0%) i/s     (2.30 s/i) -     13.000 in  30.071679s
         
     | 
| 
      
 151 
     | 
    
         
            +
              CSV - Array output      0.063 (± 0.0%) i/s    (15.88 s/i) -      2.000 in  32.229906s
         
     | 
| 
      
 152 
     | 
    
         
            +
              OSV - Array output      0.406 (± 0.0%) i/s     (2.47 s/i) -     12.000 in  31.072600s
         
     | 
| 
      
 153 
     | 
    
         
            +
            FastCSV - Array output
         
     | 
| 
      
 154 
     | 
    
         
            +
                                      0.321 (± 0.0%) i/s     (3.11 s/i) -     10.000 in  31.458966s
         
     | 
| 
      
 155 
     | 
    
         
            +
            OSV - Direct Open Array output
         
     | 
| 
      
 156 
     | 
    
         
            +
                                      0.686 (± 0.0%) i/s     (1.46 s/i) -     21.000 in  30.639715s
         
     | 
| 
      
 157 
     | 
    
         
            +
                   OSV - Gzipped      0.524 (± 0.0%) i/s     (1.91 s/i) -     16.000 in  30.695259s
         
     | 
| 
      
 158 
     | 
    
         
            +
            OSV - Gzipped Direct      0.519 (± 0.0%) i/s     (1.93 s/i) -     16.000 in  30.830005s
         
     | 
| 
      
 159 
     | 
    
         
            +
               FastCSV - Gzipped      0.313 (± 0.0%) i/s     (3.20 s/i) -     10.000 in  32.031002s
         
     | 
| 
      
 160 
     | 
    
         
            +
                   CSV - Gzipped      0.057 (± 0.0%) i/s    (17.55 s/i) -      2.000 in  35.107808s
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
            Comparison:
         
     | 
| 
      
 163 
     | 
    
         
            +
                  OSV - StringIO          : 0.7 i/s
         
     | 
| 
      
 164 
     | 
    
         
            +
            OSV - Direct Open Array output: 0.7 i/s - 1.03x  slower
         
     | 
| 
      
 165 
     | 
    
         
            +
                   OSV - Gzipped          : 0.5 i/s - 1.34x  slower
         
     | 
| 
      
 166 
     | 
    
         
            +
            OSV - Gzipped Direct          : 0.5 i/s - 1.36x  slower
         
     | 
| 
      
 167 
     | 
    
         
            +
               OSV - Hash output          : 0.4 i/s - 1.62x  slower
         
     | 
| 
      
 168 
     | 
    
         
            +
              OSV - Array output          : 0.4 i/s - 1.74x  slower
         
     | 
| 
      
 169 
     | 
    
         
            +
              FastCSV - StringIO          : 0.3 i/s - 2.10x  slower
         
     | 
| 
      
 170 
     | 
    
         
            +
            FastCSV - Array output        : 0.3 i/s - 2.20x  slower
         
     | 
| 
      
 171 
     | 
    
         
            +
               FastCSV - Gzipped          : 0.3 i/s - 2.26x  slower
         
     | 
| 
      
 172 
     | 
    
         
            +
                  CSV - StringIO          : 0.1 i/s - 8.50x  slower
         
     | 
| 
      
 173 
     | 
    
         
            +
              CSV - Array output          : 0.1 i/s - 11.20x  slower
         
     | 
| 
      
 174 
     | 
    
         
            +
               CSV - Hash output          : 0.1 i/s - 11.80x  slower
         
     | 
| 
      
 175 
     | 
    
         
            +
                   CSV - Gzipped          : 0.1 i/s - 12.37x  slower
         
     | 
| 
      
 176 
     | 
    
         
            +
            ```
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rake/testtask"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "rb_sys/extensiontask"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            task default: :test
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            GEMSPEC = Gem::Specification.load("osv.gemspec")
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            platforms = [
         
     | 
| 
      
 11 
     | 
    
         
            +
              "x86_64-linux",
         
     | 
| 
      
 12 
     | 
    
         
            +
              "x86_64-linux-musl",
         
     | 
| 
      
 13 
     | 
    
         
            +
              "aarch64-linux",
         
     | 
| 
      
 14 
     | 
    
         
            +
              "aarch64-linux-musl",
         
     | 
| 
      
 15 
     | 
    
         
            +
              "x86_64-darwin",
         
     | 
| 
      
 16 
     | 
    
         
            +
              "arm64-darwin"
         
     | 
| 
      
 17 
     | 
    
         
            +
            ]
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            RbSys::ExtensionTask.new("osv", GEMSPEC) do |ext|
         
     | 
| 
      
 20 
     | 
    
         
            +
              ext.lib_dir = "lib/osv"
         
     | 
| 
      
 21 
     | 
    
         
            +
              ext.ext_dir = "ext/osv"
         
     | 
| 
      
 22 
     | 
    
         
            +
              ext.cross_compile = true
         
     | 
| 
      
 23 
     | 
    
         
            +
              ext.cross_platform = platforms
         
     | 
| 
      
 24 
     | 
    
         
            +
              ext.cross_compiling do |spec|
         
     | 
| 
      
 25 
     | 
    
         
            +
                spec.dependencies.reject! { |dep| dep.name == "rb_sys" }
         
     | 
| 
      
 26 
     | 
    
         
            +
                spec.files.reject! { |file| File.fnmatch?("ext/*", file, File::FNM_EXTGLOB) }
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            Rake::TestTask.new do |t|
         
     | 
| 
      
 31 
     | 
    
         
            +
              t.deps << :compile
         
     | 
| 
      
 32 
     | 
    
         
            +
              t.test_files = FileList[File.expand_path("test/*_test.rb", __dir__)]
         
     | 
| 
      
 33 
     | 
    
         
            +
              t.libs << "lib"
         
     | 
| 
      
 34 
     | 
    
         
            +
              t.libs << "test"
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            task :release do
         
     | 
| 
      
 38 
     | 
    
         
            +
              sh "bundle exec rake test"
         
     | 
| 
      
 39 
     | 
    
         
            +
              sh "mkdir -p pkg"
         
     | 
| 
      
 40 
     | 
    
         
            +
              sh "gem build osv.gemspec -o pkg/osv-#{OSV::VERSION}.gem"
         
     | 
| 
      
 41 
     | 
    
         
            +
              sh "gem push pkg/osv-#{OSV::VERSION}.gem"
         
     | 
| 
      
 42 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/osv/3.2/osv.so
    ADDED
    
    | 
         Binary file 
     | 
    
        data/lib/osv/3.3/osv.so
    ADDED
    
    | 
         Binary file 
     | 
    
        data/lib/osv/3.4/osv.so
    ADDED
    
    | 
         Binary file 
     | 
    
        data/lib/osv/version.rb
    ADDED
    
    
    
        data/lib/osv.rb
    ADDED
    
    
    
        data/lib/osv.rbi
    ADDED
    
    | 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # typed: strict
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module OSV
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Options:
         
     | 
| 
      
 5 
     | 
    
         
            +
              #   - `has_headers`: Boolean indicating if the first row contains headers
         
     | 
| 
      
 6 
     | 
    
         
            +
              #                    (default: true)
         
     | 
| 
      
 7 
     | 
    
         
            +
              #   - `col_sep`: String specifying the field separator
         
     | 
| 
      
 8 
     | 
    
         
            +
              #                (default: ",")
         
     | 
| 
      
 9 
     | 
    
         
            +
              #   - `quote_char`: String specifying the quote character
         
     | 
| 
      
 10 
     | 
    
         
            +
              #                   (default: "\"")
         
     | 
| 
      
 11 
     | 
    
         
            +
              #   - `nil_string`: String that should be interpreted as nil
         
     | 
| 
      
 12 
     | 
    
         
            +
              #                   By default, empty strings are interpreted as empty strings.
         
     | 
| 
      
 13 
     | 
    
         
            +
              #                   If you want to interpret empty strings as nil, set this to
         
     | 
| 
      
 14 
     | 
    
         
            +
              #                   an empty string.
         
     | 
| 
      
 15 
     | 
    
         
            +
              #   - `buffer_size`: Integer specifying the read buffer size
         
     | 
| 
      
 16 
     | 
    
         
            +
              #   - `result_type`: String specifying the output format
         
     | 
| 
      
 17 
     | 
    
         
            +
              #                    ("hash" or "array" or :hash or :array)
         
     | 
| 
      
 18 
     | 
    
         
            +
              #   - `flexible`: Boolean specifying if the parser should be flexible
         
     | 
| 
      
 19 
     | 
    
         
            +
              #                 (default: false)
         
     | 
| 
      
 20 
     | 
    
         
            +
              #   - `trim`: String specifying the trim mode
         
     | 
| 
      
 21 
     | 
    
         
            +
              #             ("all" or "headers" or "fields" or :all or :headers or :fields)
         
     | 
| 
      
 22 
     | 
    
         
            +
              #             (default: `nil`)
         
     | 
| 
      
 23 
     | 
    
         
            +
              #   - `ignore_null_bytes`: Boolean specifying if null bytes should be ignored
         
     | 
| 
      
 24 
     | 
    
         
            +
              #                         (default: false)
         
     | 
| 
      
 25 
     | 
    
         
            +
              #   - `lossy`: Boolean specifying if invalid UTF-8 characters should be replaced with a replacement character
         
     | 
| 
      
 26 
     | 
    
         
            +
              sig do
         
     | 
| 
      
 27 
     | 
    
         
            +
                params(
         
     | 
| 
      
 28 
     | 
    
         
            +
                  input: T.any(String, StringIO, IO),
         
     | 
| 
      
 29 
     | 
    
         
            +
                  has_headers: T.nilable(T::Boolean),
         
     | 
| 
      
 30 
     | 
    
         
            +
                  col_sep: T.nilable(String),
         
     | 
| 
      
 31 
     | 
    
         
            +
                  quote_char: T.nilable(String),
         
     | 
| 
      
 32 
     | 
    
         
            +
                  nil_string: T.nilable(String),
         
     | 
| 
      
 33 
     | 
    
         
            +
                  buffer_size: T.nilable(Integer),
         
     | 
| 
      
 34 
     | 
    
         
            +
                  result_type: T.nilable(T.any(String, Symbol)),
         
     | 
| 
      
 35 
     | 
    
         
            +
                  flexible: T.nilable(T::Boolean),
         
     | 
| 
      
 36 
     | 
    
         
            +
                  ignore_null_bytes: T.nilable(T::Boolean),
         
     | 
| 
      
 37 
     | 
    
         
            +
                  trim: T.nilable(T.any(String, Symbol)),
         
     | 
| 
      
 38 
     | 
    
         
            +
                  blk: T.nilable(T.proc.params(row: T.any(T::Hash[String, T.nilable(String)], T::Array[T.nilable(String)])).void)
         
     | 
| 
      
 39 
     | 
    
         
            +
                ).returns(T.any(Enumerator, T.untyped))
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
              def self.for_each(
         
     | 
| 
      
 42 
     | 
    
         
            +
                input,
         
     | 
| 
      
 43 
     | 
    
         
            +
                has_headers: true,
         
     | 
| 
      
 44 
     | 
    
         
            +
                col_sep: nil,
         
     | 
| 
      
 45 
     | 
    
         
            +
                quote_char: nil,
         
     | 
| 
      
 46 
     | 
    
         
            +
                nil_string: nil,
         
     | 
| 
      
 47 
     | 
    
         
            +
                buffer_size: nil,
         
     | 
| 
      
 48 
     | 
    
         
            +
                result_type: nil,
         
     | 
| 
      
 49 
     | 
    
         
            +
                flexible: nil,
         
     | 
| 
      
 50 
     | 
    
         
            +
                ignore_null_bytes: nil,
         
     | 
| 
      
 51 
     | 
    
         
            +
                trim: nil,
         
     | 
| 
      
 52 
     | 
    
         
            +
                lossy: nil,
         
     | 
| 
      
 53 
     | 
    
         
            +
                &blk
         
     | 
| 
      
 54 
     | 
    
         
            +
              )
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: osv
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.4
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: x86_64-linux-musl
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Nathan Jaremko
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-02-04 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: rake-compiler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 1.2.0
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 1.2.0
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: |2
         
     | 
| 
      
 28 
     | 
    
         
            +
                  OSV is a high-performance CSV parser for Ruby, implemented in Rust.
         
     | 
| 
      
 29 
     | 
    
         
            +
                  It wraps BurntSushi's csv-rs crate to provide fast CSV parsing with support for both hash-based and array-based row formats.
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Features include: Flexible input sources (file paths, gzipped files, IO objects, strings),
         
     | 
| 
      
 31 
     | 
    
         
            +
                  configurable parsing options (headers, separators, quote chars), support for both hash and array output formats,
         
     | 
| 
      
 32 
     | 
    
         
            +
                  whitespace trimming options, strict or flexible parsing modes, and is significantly faster than Ruby's standard CSV library.
         
     | 
| 
      
 33 
     | 
    
         
            +
            email:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - nathan@jaremko.ca
         
     | 
| 
      
 35 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 36 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 37 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 38 
     | 
    
         
            +
            files:
         
     | 
| 
      
 39 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 40 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 41 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 42 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/osv.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/osv.rbi
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/osv/3.2/osv.so
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/osv/3.3/osv.so
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/osv/3.4/osv.so
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/osv/version.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            homepage: https://github.com/njaremko/osv
         
     | 
| 
      
 50 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 51 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 52 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 53 
     | 
    
         
            +
              homepage_uri: https://github.com/njaremko/osv
         
     | 
| 
      
 54 
     | 
    
         
            +
              source_code_uri: https://github.com/njaremko/osv
         
     | 
| 
      
 55 
     | 
    
         
            +
              readme_uri: https://github.com/njaremko/osv/blob/main/README.md
         
     | 
| 
      
 56 
     | 
    
         
            +
              changelog_uri: https://github.com/njaremko/osv/blob/main/CHANGELOG.md
         
     | 
| 
      
 57 
     | 
    
         
            +
              documentation_uri: https://www.rubydoc.info/gems/osv
         
     | 
| 
      
 58 
     | 
    
         
            +
              funding_uri: https://github.com/sponsors/njaremko
         
     | 
| 
      
 59 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 60 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 61 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 62 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 63 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 64 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 65 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 66 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 67 
     | 
    
         
            +
                  version: '3.2'
         
     | 
| 
      
 68 
     | 
    
         
            +
              - - "<"
         
     | 
| 
      
 69 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 70 
     | 
    
         
            +
                  version: 3.5.dev
         
     | 
| 
      
 71 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 77 
     | 
    
         
            +
            rubygems_version: 3.5.23
         
     | 
| 
      
 78 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 79 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 80 
     | 
    
         
            +
            summary: CSV parser for Ruby
         
     | 
| 
      
 81 
     | 
    
         
            +
            test_files: []
         
     |