rubycocos / markdown

markdown tools, libraries & scripts
Creative Commons Zero v1.0 Universal
52 stars 6 forks source link

Use File.exist? for 3.2.0 compatibility #12

Closed ishiikurisu closed 2 months ago

ishiikurisu commented 2 months ago

Ever since updating some projects to Ruby 3.2.0, this library was broken. The fix was to include a snippet like the following in the code:

unless File.respond_to?(:exists?)
  class << File
    alias_method :exists?, :exist?
  end
end

This PR includes a version of this fix to this library which should be compatible with versions both before and after 3.2.0.

ishiikurisu commented 2 months ago

I'm unaware of other features broken because of this update, so maybe it is relevant to check for other changes?

geraldb commented 2 months ago

thanks for highlighting the breaking change with File.exists? - note - might be better to simply rename File.exists? to File.exist?, no?

ishiikurisu commented 2 months ago

Checked the documentation and using just File.exist? seems to be safe so I updated the PR accordingly. Good call!

geraldb commented 2 months ago

thks. let's give it a try. i try to push a new gem with your changes.