csvreader icon indicating copy to clipboard operation
csvreader copied to clipboard

Record, and therefore CsvRecord, not Ruby3 compatible.

Open dhnaranjo opened this issue 3 years ago • 1 comments

Hello!

So, CsvRecord fails on any record instance creation in Ruby 3+, hitting me with an ArgumentError: wrong number of arguments (given 1, expected 0). I traced the issue to your gem Record, specifically:

--- record-1.2.0/lib/record/base.rb
+++ record-that-new-style/lib/record/base.rb
  def initialize( **kwargs )
    @values = []
-    update( **kwargs )
+    update( kwargs )
  end

  def update( kwargs )
    pp kwargs
    kwargs.each do |name,value|
      ## note: only convert/typecast string values
      if value.is_a?( String )
        send( "parse_#{name}", value )  ## note: use parse_<name> setter (for typecasting)
      else  ## use "regular" plain/classic attribute setter
        send( "#{name}=", value )
      end
    end

I'd put a PR against Record, but trouble is the repo is gone! I see that you've got something called Records but it looks substantively different. I tried to just sub one for the other naively but Records lacks a .define method.

I wouldn't mind taking a crack at resolving it, but I'd appreciate a lil guidance on what you're intending with Record and Records.

Appreciate,

dhnaranjo avatar Jan 28 '22 19:01 dhnaranjo

Hello, wow thanks for looking into 3.x compatibility / updates. First the record gem repo / source moved to https://github.com/rubycoco/more/tree/master/record - that is - I have way too many repos 500+ and, thus, I try slowly move to a more mono-repo - all-in-one kind of style / layout e.g. all csv gems are now in this repo.

As far as I can remember the idea was to make the "machinery", that is, the code independent from CSV.

Not sure if this helps to answer some questions. Let me know - greetings from Austria (Central European Time). Cheers. Prost.

Update Thinking some more about it might be a good case for moving record over here (even though the idea was to make it useable without CSV - but no one is using it anyway as far as I can tell).

geraldb avatar Jan 28 '22 20:01 geraldb