socketry / cloudflare

An asynchronous Ruby wrapper for the CloudFlare V4 API.
MIT License
139 stars 88 forks source link

Not compatible with ruby 3.X #72

Closed julienchabanon closed 1 month ago

julienchabanon commented 2 years ago

Method arguments using **options is not valid in ruby 3.0 and as a result, we now get an error saying it expect 3 arguments instead of 4.

https://github.com/socketry/cloudflare/blob/master/lib/cloudflare/dns.rb#L78

More on this here: https://bugs.ruby-lang.org/issues/14183

zone.dns_records.create *** ArgumentError Exception: wrong number of arguments (given 0, expected 3)

ruby: 3.0.2 gem version 4.3.0

f-asa commented 2 years ago

please help.

ioquatix commented 2 years ago
zone.dns_records.create
*** ArgumentError Exception: wrong number of arguments (given 0, expected 3)

Well, you are supplying zero arguments, and there are 3 non-optional arguments.

julienchabanon commented 2 years ago

@ioquatix yes I did that in purpose in rails console to show the number of expected params when using ruby 3.0. It is supposed to be 4.

I already have a fix, I will do a PR soon.

sailing commented 1 year ago

We just ran into this, so far all our attempts return the same error – do you mind sharing your fix @julienchabanon

julienchabanon commented 1 year ago

@sailing

Assuming options is a hash, instead of doing something like: zone.dns_records.create('A', 'batman', '1.2.3.4', options)

You should now be doing something like: zone.dns_records.create('A', 'batman', '1.2.3.4', **options)

sailing commented 1 year ago

Thanks @julienchabanon!

ioquatix commented 1 year ago

Sorry, I'll take a look at this code and fix it.

ioquatix commented 1 month ago

The minimum supported version is now Ruby 3.1.