fix!: Guard against zero sizes and require Ruby 3.4 - #146
Merged
Merged
Conversation
vector2d 3.0 sets its own floor at 3.4, deliberately: its matrix interop isn't ractor-safe before then. dynamic_image can't follow it onto 3.3, and 3.3 is close to EOL regardless. The 3.4 rubocop target enables Style/ItBlockParameter, which rewrites the numbered block parameters in Breakpoints to `it`. BREAKING CHANGE: Ruby 3.4 is now the minimum version, up from 3.3.
vector2d 3.0 treats a zero axis as unconstrained rather than degenerate, so the zero vector leaves the receiver unchanged instead of fitting to NaN. That quietly turns "0x0" from an error into a request for the whole image: ImageSizing#fit returns the image's own size, crop_geometry returns a zero crop, and Model#resize does nothing at all. A single zero axis still means that axis is unconstrained, which is the documented way to ask for a fixed width or height. Only a vector that is zero throughout is rejected, and it now raises InvalidSizeOptions under both 2.3 and 3.0 — the same error a size smaller than a pixel raises. The resize spec for a sub-pixel size moves from "0x0" to "1x1" so it still covers the sub-pixel guard rather than the new one. ImageSizing gives up its private vector helper to stay inside Metrics/ClassLength; the class already built vectors with Vector2d.new in two other places.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prep for the vector2d 3.0 bump; the pin stays at
~> 2.3until 3.0 ships.vector2d 3.0 requires Ruby 3.4, so the gemspec, CI matrix and rubocop target follow it (the 3.4 target's
Style/ItBlockParameteralso rewrites the numbered block parameters inBreakpoints). It also treats a zero axis as unconstrained rather than degenerate, which quietly turned"0x0"from an error into a request for the whole image —ImageSizing#fitreturned the image's own size,crop_geometrya zero crop, andModel#resizedid nothing at all. Sizes that are zero on both axes now raiseInvalidSizeOptionsunder both 2.3 and 3.0, while a single zero axis still means that axis is unconstrained.Green against both vector2d 2.3.0 and
main(592 examples, SQLite and PostgreSQL), with a differential probe over ~17k sizing cases showing no remaining behavioural difference between the two;RSpec (3.3)has been removed from the required checks onmain.