zeitwerk 2.6.14 → 2.6.15

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: 06d0e5697b46d13993ad46322296a64f44e05a83087281944378fc79ee8067ba
4
- data.tar.gz: 00371f27991d326fcbdfbf4e8e0668925a24d81662bc64890b3fbe653ae00243
3
+ metadata.gz: 8177bcca0fd5895bbe28b19dc5fd04a810e2905f21f33924786a33a317c96207
4
+ data.tar.gz: 7e441521285fe28230dadfb4c5c9d40564e376dd651ddae043190c5fdd3ee526
5
5
  SHA512:
6
- metadata.gz: 6a2666faaf75882a06ad5a2b408e1cff593744b15fca61864a20c255a2868af22f8b60a7125c5d61f83374efa5e1a21ee627d17ea0ef8f3586a71efba4f3fa8e
7
- data.tar.gz: aad3c7421105576216338a3eb521bb44188d9f2a371f69e5a069e4b619ab1d101b1fb9477bc55ef7bf35c50942bd1ddb5c50571392e9e487eedb9a09e5e9a778
6
+ metadata.gz: 57e0e401c952a13d1b96a8993bbee930132f2b63252ff7cd6646ceeeb5a3de886d1c36a8cdbc06e9add3e16e76bacd08cc8e32b58289fa01e9eabea4dad25581
7
+ data.tar.gz: e56116c8325ab38f751b8497f8270544543e950f92624c755b5d3d7bb296b48ce4afa668e1b4daae546561ddfa344fd9c650c7114c9cd2c637a514f0ebd38c98
data/README.md CHANGED
@@ -1336,13 +1336,14 @@ This method does not parse file contents and does not guarantee files define the
1336
1336
  <a id="markdown-zeitwerkloaderall_expected_cpaths" name="zeitwerkloaderall_expected_cpaths"></a>
1337
1337
  #### `Zeitwerk::Loader#all_expected_cpaths`
1338
1338
 
1339
- The method `Zeitwerk::Loader#all_expected_cpaths` returns a hash that maps the absolute paths of the files and directories managed by the receiver to their corresponding expected constant paths.
1339
+ The method `Zeitwerk::Loader#all_expected_cpaths` returns a hash that maps the absolute paths of the files and directories managed by the receiver to their expected constant paths.
1340
1340
 
1341
- Ignored files or directories are not included in the result. Directories that do not contain any files with the ".rb" extension (recursively) are also excluded. Additionally, if a directory contains files with the ".rb" extension but all of them are ignored, it is treated as if it contains no ".rb" files.
1341
+ Ignored files, hidden files, and files whose extension is not ".rb" are not included in the result. Same for directories, hidden or ignored directories are not included in the result. Additionally, directories that contain no files with extension ".rb" (recursively) are also excluded, since those are not considered to represent Ruby namespaces.
1342
1342
 
1343
1343
  For example, if `lib` is the root directory of a gem with the following contents:
1344
1344
 
1345
1345
  ```
1346
+ lib/.DS_Store
1346
1347
  lib/my_gem.rb
1347
1348
  lib/my_gem/version.rb
1348
1349
  lib/my_gem/ignored.rb
@@ -1368,15 +1369,15 @@ lib/tasks/my_gem.rake
1368
1369
  }
1369
1370
  ```
1370
1371
 
1371
- As the names suggest, the previous example assumes `lib/my_gem/ignored.rb` is ignored (so, not present in the returned hash), and `lib/my_gem/collapsed` is a collapsed directory (so the expected namespace at that level is still `MyGem`, this is an edge case).
1372
+ In the previous example we assume `lib/my_gem/ignored.rb` is ignored, and therefore it is not present in the returned hash. Also, `lib/my_gem/collapsed` is a collapsed directory, so the expected namespace at that level is still `MyGem` (this is an edge case).
1372
1373
 
1373
- Directory paths are guaranteed to not have trailing slashes.
1374
+ The file `lib/.DS_Store` is hidden, hence excluded. The directory `lib/tasks` is also not present because it contains no files with extension ".rb".
1374
1375
 
1375
- Note that `lib/tasks` is not present in the hash because it contains no files with the ".rb" extension. The loader does not consider the `lib/tasks` directory to represent a Ruby namespace; therefore, it does not end up in the hash.
1376
+ Directory paths do not have trailing slashes.
1376
1377
 
1377
1378
  The order of the hash entries is undefined.
1378
1379
 
1379
- This method does not parse file contents and does not guarantee files define the corresponding constant paths. It just says which are the _expected_ ones.
1380
+ This method does not parse or execute file contents and does not guarantee files define the corresponding constant paths. It just says which are the _expected_ ones.
1380
1381
 
1381
1382
  <a id="markdown-encodings" name="encodings"></a>
1382
1383
  ### Encodings
@@ -209,9 +209,7 @@ module Zeitwerk::Loader::EagerLoad
209
209
  next_dirs = []
210
210
 
211
211
  suffix.split("::").each do |segment|
212
- until dirs.empty?
213
- dir = dirs.shift
214
-
212
+ while (dir = dirs.shift)
215
213
  ls(dir) do |basename, abspath, ftype|
216
214
  next unless ftype == :directory
217
215
 
@@ -43,18 +43,27 @@ module Zeitwerk::Loader::Helpers
43
43
  end
44
44
  end
45
45
 
46
+ # Looks for a Ruby file using breadth-first search. This type of search is
47
+ # important to list as less directories as possible and return fast in the
48
+ # common case in which there are Ruby files.
49
+ #
46
50
  # @sig (String) -> bool
47
51
  private def has_at_least_one_ruby_file?(dir)
48
52
  to_visit = [dir]
49
53
 
50
- until to_visit.empty?
51
- dir = to_visit.shift
54
+ while (dir = to_visit.shift)
55
+ children = Dir.children(dir)
56
+
57
+ children.each do |basename|
58
+ next if hidden?(basename)
59
+
60
+ abspath = File.join(dir, basename)
61
+ next if ignored_path?(abspath)
52
62
 
53
- ls(dir) do |_basename, abspath, ftype|
54
- if ftype == :file
55
- return true
63
+ if dir?(abspath)
64
+ to_visit << abspath unless roots.key?(abspath)
56
65
  else
57
- to_visit << abspath
66
+ return true if ruby?(abspath)
58
67
  end
59
68
  end
60
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "2.6.14"
4
+ VERSION = "2.6.15"
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.6.14
4
+ version: 2.6.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-14 00:00:00.000000000 Z
11
+ date: 2024-05-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Zeitwerk implements constant autoloading with Ruby semantics. Each gem