zeitwerk 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2af50b4d74832ccd3c08e3445c09a941ed56758c57acd20e8d88436f79e16ea2
4
- data.tar.gz: 23f693ca2b9fc44870c26991cd91c587031825e9d29c90dd5285f2c7a3731f6a
3
+ metadata.gz: b7d5a0f54405ad45dd6afc9bf54bde579f66a75fb142cdbbfb5476157dd75493
4
+ data.tar.gz: b81311bb19c3b699a6720a3bb3d6df503b858a439c5f1f2605e029117de36bcb
5
5
  SHA512:
6
- metadata.gz: 1d47e1a735c5314ec56f9c16d66695222209109dddb7da3a663969b852295eed82d8eee56fc48a48cb6b0604e508940f474533e98c7d824175c344420a64baec
7
- data.tar.gz: be275743889771c745fc90d300a4cbd01911b5b4547c41ea1df6429af1357b9328fb69293a03a282677295f27528220f180f1ca943f43b5567677b856baa3e06
6
+ metadata.gz: 4f6fd6e8f7bd479ca6935d1f57d065151aff3be6977ad068f6b4ecdce200bbd131f4db4f2cc1bc2a719cb332b538cf24be55eb936a51572ac5c06676d21763f2
7
+ data.tar.gz: d4266c65e380b356ff4df7394f2f1882f72ac32b5226dedd717f6b4064c8ac1b8fd3d70ec08b6f9838debfc3690d2f3eee2d6885e446f087a686a619c872c718
data/README.md CHANGED
@@ -32,6 +32,7 @@
32
32
  - [Autoloading, explicit namespaces, and debuggers](#autoloading-explicit-namespaces-and-debuggers)
33
33
  - [Pronunciation](#pronunciation)
34
34
  - [Supported Ruby versions](#supported-ruby-versions)
35
+ - [Testing](#testing)
35
36
  - [Motivation](#motivation)
36
37
  - [Thanks](#thanks)
37
38
  - [License](#license)
@@ -599,6 +600,32 @@ As a workaround, you can eager load. Zeitwerk tries hard to succeed or fail cons
599
600
 
600
601
  Zeitwerk works with MRI 2.4.4 and above.
601
602
 
603
+ <a id="markdown-testing" name="testing"></a>
604
+ ## Testing
605
+
606
+ In order to run the test suite of Zeitwerk, `cd` into the project root and execute
607
+
608
+ ```
609
+ bin/test
610
+ ```
611
+
612
+ To run one particular suite, pass its file name as an argument:
613
+
614
+ ```
615
+ bin/test test/lib/zeitwerk/test_eager_load.rb
616
+ ```
617
+
618
+ Furthermore, the project has a development dependency on [`minitest-focus`](https://github.com/seattlerb/minitest-focus). To run an individual test mark it with `focus`:
619
+
620
+ ```ruby
621
+ focus
622
+ test "capitalizes the first letter" do
623
+ assert_equal "User", camelize("user")
624
+ end
625
+ ```
626
+
627
+ and run `bin/test`.
628
+
602
629
  <a id="markdown-motivation" name="motivation"></a>
603
630
  ## Motivation
604
631
 
@@ -613,6 +640,8 @@ I'd like to thank [@matthewd](https://github.com/matthewd) for the discussions w
613
640
 
614
641
  Also, would like to thank [@Shopify](https://github.com/Shopify), [@rafaelfranca](https://github.com/rafaelfranca), and [@dylanahsmith](https://github.com/dylanahsmith), for sharing [this PoC](https://github.com/Shopify/autoload_reloader). The technique Zeitwerk uses to support explicit namespaces was copied from that project.
615
642
 
643
+ Jean Boussier ([@casperisfine](https://github.com/casperisfine), [@byroot](https://github.com/byroot)) deserves special mention. Jean migrated autoloading in Shopify when Zeitwerk integration in Rails was yet unreleased. His work and positive attitude have been outstanding, and thanks to his feedback the interface and performance of Zeitwerk are way, way better. Kudos man ❤️.
644
+
616
645
  Finally, many thanks to [@schurig](https://github.com/schurig) for recording an [audio file](http://share.hashref.com/zeitwerk/zeitwerk_pronunciation.mp3) with the pronunciation of "Zeitwerk" in perfect German. 💯
617
646
 
618
647
  <a id="markdown-license" name="license"></a>
@@ -28,7 +28,7 @@ module Zeitwerk
28
28
  #
29
29
  # inflector.camelize("html_parser", abspath) # => "HTMLParser"
30
30
  # inflector.camelize("mysql_adapter", abspath) # => "MySQLAdapter"
31
- # inflector.camelize("users_controller", abspath) # => "PostsController"
31
+ # inflector.camelize("users_controller", abspath) # => "UsersController"
32
32
  #
33
33
  # @param inflections [{String => String}]
34
34
  # @return [void]
@@ -623,8 +623,14 @@ module Zeitwerk
623
623
  # @param parent [Module]
624
624
  # @param cname [Symbol]
625
625
  # @return [String, nil]
626
- def strict_autoload_path(parent, cname)
627
- parent.autoload?(cname) if cdef?(parent, cname)
626
+ if method(:autoload?).arity == 1
627
+ def strict_autoload_path(parent, cname)
628
+ parent.autoload?(cname) if cdef?(parent, cname)
629
+ end
630
+ else
631
+ def strict_autoload_path(parent, cname)
632
+ parent.autoload?(cname, false)
633
+ end
628
634
  end
629
635
 
630
636
  # This method is called this way because I prefer `preload` to be the method
@@ -14,7 +14,7 @@ module Zeitwerk::Loader::Callbacks
14
14
  if logger && cdef?(*cref)
15
15
  log("constant #{cpath(*cref)} loaded from file #{file}")
16
16
  elsif !cdef?(*cref)
17
- raise NameError, "expected file #{file} to define constant #{cpath(*cref)}, but didn't"
17
+ raise Zeitwerk::NameError, "expected file #{file} to define constant #{cpath(*cref)}, but didn't"
18
18
  end
19
19
  end
20
20
 
@@ -9,7 +9,13 @@ module Zeitwerk::RealModName
9
9
  #
10
10
  # @param mod [Class, Module]
11
11
  # @return [String, nil]
12
- def real_mod_name(mod)
13
- UNBOUND_METHOD_MODULE_NAME.bind(mod).call
12
+ if UnboundMethod.method_defined?(:bind_call)
13
+ def real_mod_name(mod)
14
+ UNBOUND_METHOD_MODULE_NAME.bind_call(mod)
15
+ end
16
+ else
17
+ def real_mod_name(mod)
18
+ UNBOUND_METHOD_MODULE_NAME.bind(mod).call
19
+ end
14
20
  end
15
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "2.2.0"
4
+ VERSION = "2.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeitwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-09 00:00:00.000000000 Z
11
+ date: 2019-11-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zeitwerk implements constant autoloading with Ruby semantics. Each gem