toy / image_optim

Optimize images using multiple utilities
https://github.com/toy/image_optim
MIT License
1.52k stars 109 forks source link

Support newer versions of psych/newer rubies #204

Closed oscillot closed 1 year ago

oscillot commented 1 year ago

This change addresses issue #203 where using a !ruby Range value in the config yaml would cause an error and fail to load the config. This issue is due to a breaking change in psych at version 4. This change checks what version of psych we are working with and returns the correct arguments in the correct format for loading the config file.

It also adds enough flexibility that if there is another breaking change in the future it should be simple enough to add another strategy and this should work correctly even if they bring their own version of psych to use.

Testing this was a bit challenging. I was able to test it on the latest version of each ruby ruby 2.3.x-3.1.x in rspec and by running the reproduction code in the issue, however I wasn't able to test ruby 2.2 or 2.1 so I'm leaving that to the github action to tell me how I did.

In addition to the specs that I added, I modified some specs that did message expectations against the YAML.load_file method, adding any_args so that the expectation works correctly across all of the variations of the load_file call, since any_args conceptually includes no_args.

@toy we briefly spoke about using respond_to? but I found this clearer and more explicit, though this is your project so let me know if you disagree would like me to pursue the other route

simon04 commented 1 year ago

Hi all, maintainer of the open-source freeCodeCamp/devdocs here. This issue is blocking the project from migrating from Ruby 2 to Ruby 3.

Any chance to get this PR merged and also released anytime soon? The outstanding suggested code changes seem easy to address to me.

Thanks in advance!

toy commented 1 year ago

Not sure if @oscillot got notifications, though I'll finish the PR if it doesn't progress soon

toy commented 1 year ago

v0.31.3 is out