Pagy v5.0.0 Release Notes
-
๐ฅ Breaking changes - 1. Code update
๐ Pagy 4 dropped the compatibility for old ruby versions
>2.5
and started to refactor the code using more modern syntax and paradigms and better performance. It deprecated the legacy ones, printing deprecation warnings and upgrading instruction in the log, but still supporting its legacy API. Pagy 5.0.0 cleans up and removes all that transitional support code.โฌ๏ธ The changes for upgrading your app cannot be fixed with simple search and replace, but fear not! Fixing them should just take a few minutes with the following steps:
- โฌ๏ธ Upgrade to the latest version of pagy 4
- โ Run your tests or app
- ๐ Check the log for any deprecations message starting with '[PAGY WARNING]'
- โก๏ธ Update your code as indicated by the messages
- โ Ensure that the log is now free from warnings
- โฌ๏ธ Upgrade to pagy 5
๐ FYI: Here is the list of the deprecations that are not supported anymore:
โ Removed support for deprecated variables
- 0๏ธโฃ
Pagy::VARS[:anchor]
is nowPagy::DEFAULT[:fragment]
โ Removed support for deprecated arguments order
- The argument order in
pagy_url_for(page, pagy)
is now inverted:pagy_url_for(pagy, page)
โ Removed support for deprecated positional arguments
The following optional positional arguments are passed with keywords arguments in all the pagy helpers:
- The
id
html attribute string with thepagy_id
keyword - The
url|absolute
flag with theabsolute
keyword - The
item_name
string with theitem_name
keyword - The
extra|link_extra
string with thelink_extra
keyword - The
text
string with thetext
keyword
๐ฅ Breaking changes - 2. Simple search and replace
๐ There are a few renaming that have not been deprecated in previous versions because they are extremely easy to fix with simple search and replace (while implementing deprecations would have been detrimental to performance and complex for no reason)
Consistency renaming
A few elements have been renamed: you code may or may not contain them. Just search and replace the following strings:
- 0๏ธโฃ Rename
Pagy::VARS
toPagy::DEFAULT
- Rename
enable_items_extra
toitems_extra
- Rename
enable_trim_extra
totrim_extra
- ๐ Rename
Pagy::Helpers
toPagy::UrlHelpers
- Rename
pagy_get_params
topagy_massage_params
Items accessor
๐ The items accessor does not adjust for the actual items in the last page anymore. This should not affect normal usage, so you can ignore this change unless you build something on that assumption.
If your code is relying on the actual number of items in the page, then just replace
@pagy.items
with@pagy.in
wherever you meant that.FYI: The
@pagy.items
is now always equal to@pagy.vars[:items]
(i.e. the requested items), while the@pagy.in
returns the actual items in the page (which could be less than theitems
when the page is the last page)๐ Changes
- โ Removed support for deprecations
- ๐จ Refactoring of Pagy and Pagy::Countless classes, I18n, and url helpers
- ๐จ Refactoring of the docker environment, addition of ready to use VSCode setup
- ๐ Changed general module structure (use of prepend instead of re-opening modules)
- โ Added gearbox extra for geared pagination
- โ Added configuration files for a full working VSCode devcontainer environment
- โ Added Run Configurations for RubyMine
- ๐ Improved the usage of e2e tests
- โก๏ธ Updated doc, gemfiles and github workflow
- ๐ Other minor fixes and improvements in code and doc