Hello community,

here is the log from the commit of package rubygem-zeitwerk for 
openSUSE:Factory checked in at 2020-07-16 12:19:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-zeitwerk (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-zeitwerk.new.3592 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-zeitwerk"

Thu Jul 16 12:19:26 2020 rev:6 rq:821253 version:2.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-zeitwerk/rubygem-zeitwerk.changes        
2020-07-14 08:01:47.842276832 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-zeitwerk.new.3592/rubygem-zeitwerk.changes  
    2020-07-16 12:21:42.223161989 +0200
@@ -1,0 +2,9 @@
+Thu Jul 16 08:43:36 UTC 2020 - Manuel Schnitzer <mschnit...@suse.com>
+
+- updated to version 2.4.0
+
+  * `Zeitwerk::Loader#push_dir` supports an optional `namespace` keyword 
argument. Pass a class or module object if you want the given root directory to 
be associated with it instead of `Object`. Said class or module object cannot 
be reloadable.
+
+  * The default inflector is even more performant.
+
+-------------------------------------------------------------------

Old:
----
  zeitwerk-2.3.1.gem

New:
----
  zeitwerk-2.4.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-zeitwerk.spec ++++++
--- /var/tmp/diff_new_pack.gQuVPJ/_old  2020-07-16 12:21:44.195163983 +0200
+++ /var/tmp/diff_new_pack.gQuVPJ/_new  2020-07-16 12:21:44.195163983 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-zeitwerk
-Version:        2.3.1
+Version:        2.4.0
 Release:        0
 %define mod_name zeitwerk
 %define mod_full_name %{mod_name}-%{version}

++++++ zeitwerk-2.3.1.gem -> zeitwerk-2.4.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2020-06-29 01:10:59.000000000 +0200
+++ new/README.md       2020-07-15 00:11:04.000000000 +0200
@@ -139,6 +139,22 @@
 app/controllers/admin/users_controller.rb -> Admin::UsersController
 ```
 
+Alternatively, you can associate a custom namespace to a root directory by 
passing a class or module object in the optional `namespace` keyword argument.
+
+For example, Active Job queue adapters have to define a constant after their 
name in `ActiveJob::QueueAdapters`.
+
+So, if you declare
+
+```ruby
+require "active_job"
+require "active_job/queue_adapters"
+loader.push_dir("#{__dir__}/adapters", namespace: ActiveJob::QueueAdapters)
+```
+
+your adapter can be stored directly in that directory instead of the canonical 
`lib/active_job/queue_adapters`.
+
+Please, note that the given namespace must be non-reloadable, though 
autoloaded constants in that namespace can be. That is, if you associate 
`app/api` with an existing `Api` module, that module should not be reloadable. 
However, if the project defines and autoloads the class `Api::V2::Deliveries`, 
that one can be reloaded.
+
 <a id="markdown-implicit-namespaces" name="implicit-namespaces"></a>
 ### Implicit namespaces
 
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/zeitwerk/inflector.rb 
new/lib/zeitwerk/inflector.rb
--- old/lib/zeitwerk/inflector.rb       2020-06-29 01:10:59.000000000 +0200
+++ new/lib/zeitwerk/inflector.rb       2020-07-15 00:11:04.000000000 +0200
@@ -15,7 +15,7 @@
     # @param _abspath [String]
     # @return [String]
     def camelize(basename, _abspath)
-      overrides[basename] || basename.split('_').map!(&:capitalize).join
+      overrides[basename] || basename.split('_').each(&:capitalize!).join
     end
 
     # Configures hard-coded inflections:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/zeitwerk/loader.rb new/lib/zeitwerk/loader.rb
--- old/lib/zeitwerk/loader.rb  2020-06-29 01:10:59.000000000 +0200
+++ new/lib/zeitwerk/loader.rb  2020-07-15 00:11:04.000000000 +0200
@@ -190,13 +190,19 @@
     # or descendants.
     #
     # @param path [<String, Pathname>]
+    # @param namespace [Class, Module]
     # @raise [Zeitwerk::Error]
     # @return [void]
-    def push_dir(path)
+    def push_dir(path, namespace: Object)
+      # Note that Class < Module.
+      unless namespace.is_a?(Module)
+        raise Error, "#{namespace.inspect} is not a class or module object, 
should be"
+      end
+
       abspath = File.expand_path(path)
       if dir?(abspath)
         raise_if_conflicting_directory(abspath)
-        root_dirs[abspath] = true
+        root_dirs[abspath] = namespace
       else
         raise Error, "the root directory #{abspath} does not exist"
       end
@@ -268,7 +274,9 @@
       mutex.synchronize do
         break if @setup
 
-        actual_root_dirs.each { |root_dir| set_autoloads_in_dir(root_dir, 
Object) }
+        actual_root_dirs.each do |root_dir, namespace|
+          set_autoloads_in_dir(root_dir, namespace)
+        end
         do_preload
 
         @setup = true
@@ -368,8 +376,11 @@
       mutex.synchronize do
         break if @eager_loaded
 
-        queue = actual_root_dirs.reject { |dir| 
eager_load_exclusions.member?(dir) }
-        queue.map! { |dir| [Object, dir] }
+        queue = []
+        actual_root_dirs.each do |root_dir, namespace|
+          queue << [namespace, root_dir] unless 
eager_load_exclusions.member?(root_dir)
+        end
+
         while to_eager_load = queue.shift
           namespace, dir = to_eager_load
 
@@ -498,7 +509,7 @@
 
     # @return [<String>]
     def actual_root_dirs
-      root_dirs.keys.delete_if do |root_dir|
+      root_dirs.reject do |root_dir, _namespace|
         !dir?(root_dir) || ignored_paths.member?(root_dir)
       end
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/zeitwerk/version.rb new/lib/zeitwerk/version.rb
--- old/lib/zeitwerk/version.rb 2020-06-29 01:10:59.000000000 +0200
+++ new/lib/zeitwerk/version.rb 2020-07-15 00:11:04.000000000 +0200
@@ -1,5 +1,5 @@
 # frozen_string_literal: true
 
 module Zeitwerk
-  VERSION = "2.3.1"
+  VERSION = "2.4.0"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2020-06-29 01:10:59.000000000 +0200
+++ new/metadata        2020-07-15 00:11:04.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: zeitwerk
 version: !ruby/object:Gem::Version
-  version: 2.3.1
+  version: 2.4.0
 platform: ruby
 authors:
 - Xavier Noria
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2020-06-28 00:00:00.000000000 Z
+date: 2020-07-14 00:00:00.000000000 Z
 dependencies: []
 description: |2
       Zeitwerk implements constant autoloading with Ruby semantics. Each gem


Reply via email to