pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/ruby-zeitwerk devel/ruby-zeitwerk: update to 2.5.1



details:   https://anonhg.NetBSD.org/pkgsrc/rev/495c90dbe399
branches:  trunk
changeset: 769205:495c90dbe399
user:      taca <taca%pkgsrc.org@localhost>
date:      Tue Nov 09 14:46:28 2021 +0000

description:
devel/ruby-zeitwerk: update to 2.5.1

2.5.1 (20 October 2021)

* Restores support for namespaces that are not hashable. For example
  namespaces that override the hash method with a different arity as shown
  in #188.

2.5.0 (20 October 2021)

Breaking changes

* Requires Ruby 2.5.
* Deletes the long time deprecated preload API. Instead of:

        loader.preload("app/models/user.rb")

  just reference the constant on setup:

        loader.on_setup { User }

  If you want to eager load a namespace, use the constants API:

        loader.on_setup do
          Admin.constants(false).each { |cname| Admin.const_get(cname) }
        end

Bug fixes

* Fixes a bug in which a certain valid combination of overlapping trees
  managed by different loaders and ignored directories was mistakenly
  reported as having conflicting directories.
* Detects external namespaces defined with Module#autoload. If your project
  reopens a 3rd party namespace, Zeitwerk already detected it and did not
  consider the namespace to be managed by the loader (automatically
  descends, ignored for reloads, etc.). However, the loader did not do that
  if the namespace had only an autoload in the 3rd party code yet to be
  executed. Now it does.

Callbacks

* Implements Zeitwerk::Loader#on_setup, which allows you to configure blocks
  of code to be executed on setup and on each reload. When the callback is
  fired, the loader is ready, you can refer to project constants in the
  block.
  See the documentation for further details.

* There is a new catch-all Zeitwerk::Loader#on_load that takes no argument
  and is triggered for all loaded objects:

        loader.on_load do |cpath, value, abspath|
          # ...
        end

  Please, remember that if you want to trace the activity of a loader,
  Zeitwerk::Loader#log! logs plenty of information.
  See the documentation for further details.

* The block of the existing Zeitwerk::Loader#on_load receives also the value
  stored in the constant, and the absolute path to its corresponding file or
  directory:

        loader.on_load("Service::NotificationsGateway") do |klass, abspath|
          # ...
        end

  Remember that blocks can be defined to take less arguments than passed. So
  this change is backwards compatible. If you had

        loader.on_load("Service::NotificationsGateway") do
          Service::NotificationsGateway.endpoint = ...
        end

  That works.

* Implements Zeitwerk::Loader#on_unload, which allows you to configure
  blocks of code to be executed before a certain class or module gets
  unloaded:

        loader.on_unload("Country") do |klass, _abspath|
          klass.clear_cache
        end

  These callbacks are invoked during unloading, which happens in an
  unspecified order. Therefore, they should not refer to reloadable
  constants.

  You can also be called for all unloaded objects:

        loader.on_unload do |cpath, value, abspath|
          # ...
        end

  Please, remember that if you want to trace the activity of a loader,
  Zeitwerk::Loader#log! logs plenty of information.
  See the documentation for further details.

Assorted

* Performance improvements.
* Documentation improvements.
* The method Zeitwerk::Loader#eager_load accepts a force flag:

        loader.eager_load(force: true)

* If passed, eager load exclusions configured with do_not_eager_load are not
  honoured (but ignored files and directories are).
* This may be handy for test suites that eager load in order to ensure all
  files define the expected constant.
* Eliminates internal use of File.realpath. One visible consequence is that
  in logs root dirs are shown as configured if they contain symlinks.
* When an autoloaded file does not define the expected constant, Ruby clears
  state differently starting with Ruby 3.1. Unloading has been revised to be
  compatible with both behaviours.
* Logging prints a few new traces.

diffstat:

 devel/ruby-zeitwerk/Makefile |  4 ++--
 devel/ruby-zeitwerk/PLIST    |  4 +++-
 devel/ruby-zeitwerk/distinfo |  8 ++++----
 3 files changed, 9 insertions(+), 7 deletions(-)

diffs (43 lines):

diff -r ff68316e96f9 -r 495c90dbe399 devel/ruby-zeitwerk/Makefile
--- a/devel/ruby-zeitwerk/Makefile      Tue Nov 09 14:41:15 2021 +0000
+++ b/devel/ruby-zeitwerk/Makefile      Tue Nov 09 14:46:28 2021 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.4 2021/01/11 13:33:22 taca Exp $
+# $NetBSD: Makefile,v 1.5 2021/11/09 14:46:28 taca Exp $
 
-DISTNAME=      zeitwerk-2.4.2
+DISTNAME=      zeitwerk-2.5.1
 CATEGORIES=    devel
 
 MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
diff -r ff68316e96f9 -r 495c90dbe399 devel/ruby-zeitwerk/PLIST
--- a/devel/ruby-zeitwerk/PLIST Tue Nov 09 14:41:15 2021 +0000
+++ b/devel/ruby-zeitwerk/PLIST Tue Nov 09 14:46:28 2021 +0000
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.1 2020/01/19 15:04:46 taca Exp $
+@comment $NetBSD: PLIST,v 1.2 2021/11/09 14:46:28 taca Exp $
 ${GEM_HOME}/cache/${GEM_NAME}.gem
 ${GEM_LIBDIR}/MIT-LICENSE
 ${GEM_LIBDIR}/README.md
@@ -10,6 +10,8 @@
 ${GEM_LIBDIR}/lib/zeitwerk/kernel.rb
 ${GEM_LIBDIR}/lib/zeitwerk/loader.rb
 ${GEM_LIBDIR}/lib/zeitwerk/loader/callbacks.rb
+${GEM_LIBDIR}/lib/zeitwerk/loader/config.rb
+${GEM_LIBDIR}/lib/zeitwerk/loader/helpers.rb
 ${GEM_LIBDIR}/lib/zeitwerk/real_mod_name.rb
 ${GEM_LIBDIR}/lib/zeitwerk/registry.rb
 ${GEM_LIBDIR}/lib/zeitwerk/version.rb
diff -r ff68316e96f9 -r 495c90dbe399 devel/ruby-zeitwerk/distinfo
--- a/devel/ruby-zeitwerk/distinfo      Tue Nov 09 14:41:15 2021 +0000
+++ b/devel/ruby-zeitwerk/distinfo      Tue Nov 09 14:46:28 2021 +0000
@@ -1,5 +1,5 @@
-$NetBSD: distinfo,v 1.6 2021/10/26 10:19:53 nia Exp $
+$NetBSD: distinfo,v 1.7 2021/11/09 14:46:28 taca Exp $
 
-BLAKE2s (zeitwerk-2.4.2.gem) = 147cc4ecddb8aca5782bdc56256aedca89f9593ee2623ce3a768d40961338410
-SHA512 (zeitwerk-2.4.2.gem) = d475b8dbc37f4feadeba283d2ec0865023a1871a5a237ac71f3abd92c92b747120aa95dbc0863d4ff9daddfdf4e1c6ae857382cbefe8e9dae1aa24a719de0c59
-Size (zeitwerk-2.4.2.gem) = 26624 bytes
+BLAKE2s (zeitwerk-2.5.1.gem) = b8c50df87f970328ae7e1a5d59179ebe62537a764b6b0811ee31cadac5a5f527
+SHA512 (zeitwerk-2.5.1.gem) = 7e9013cb2344254404f0130bb82fa04651edfd9f3e4e91d5144308be1eb34e815071073bc7f7a53bc58a2defddbabc434074b6653959ed7ac51d036d8a421cbd
+Size (zeitwerk-2.5.1.gem) = 30208 bytes



Home | Main Index | Thread Index | Old Index