Skip to content

fix!: Guard against zero sizes and require Ruby 3.4 - #146

Merged
elektronaut merged 2 commits into
mainfrom
vector2d-upstream-compat-check
Sep 20, 2026
Merged

elektronaut merged 2 commits into
mainfrom
vector2d-upstream-compat-check

Conversation

@elektronaut

Copy link
Copy Markdown
Owner

Prep for the vector2d 3.0 bump; the pin stays at ~> 2.3 until 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/ItBlockParameter also rewrites the numbered block parameters in Breakpoints). 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#fit returned the image's own size, crop_geometry a zero crop, and Model#resize did nothing at all. Sizes that are zero on both axes now raise InvalidSizeOptions under 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 on main.

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.
@elektronaut
elektronaut merged commit 645ce79 into main Sep 20, 2026
6 checks passed
@elektronaut
elektronaut deleted the vector2d-upstream-compat-check branch September 20, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant