benburkert / randexp

generate random data from a Regular Expression
MIT License
286 stars 43 forks source link

Incompatible with Ruby 3.2 #22

Open pboling opened 1 year ago

pboling commented 1 year ago

File.exists? was deprecated in Ruby 2.1, and removed in Ruby 3.2.

It should be replaced with File.exist?.

     NoMethodError:
       undefined method `exists?' for File:Class
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/dictionary.rb:3:in `load_dictionary'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/dictionary.rb:16:in `words'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/randgen.rb:35:in `word'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/reducer.rb:60:in `char'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/reducer.rb:17:in `random'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/reducer.rb:4:in `reduce'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/reducer.rb:12:in `quantify'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/reducer.rb:4:in `reduce'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp.rb:9:in `reduce'
     # ./vendor/bundle/ruby/3.2.0/gems/randexp-0.1.7/lib/randexp/core_ext/regexp.rb:3:in `generate'
pboling commented 1 year ago

The solution, until this gem has a maintainer, (I volunteered and emailed @benburkert !) is to simply add the removed method back, and a handy gem does that for us:

spec.add_dependency("file_exists", "~> 0.2")

or

gem "file_exists", "~> 0.2"

And then (before all other requires):

require 'file_exists'

Ref: https://github.com/Largo/file_exists

benburkert commented 1 year ago

thanks for investigating @pboling, mind submitting a PR with your preferred fix?

pboling commented 1 year ago

Will do!