zeitwerk 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -5
- data/lib/zeitwerk/loader.rb +3 -2
- data/lib/zeitwerk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69ab50936501a8a78e6be01014ac8e97890297955088fdac78cf1d5adeea7e78
|
4
|
+
data.tar.gz: 2afe0ae004e102604e2b23133ef683bad6753479bd9be0ef37379676d5c47a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51ceaebc945976ba34a6025d225099ab69e337287a3577c1f1e484d0fc1e4d6efec00e2e132a9cb794d91101f1f484dc154ef6e97c3b0a392f16a9ec5c340bdb
|
7
|
+
data.tar.gz: ab59de0733cdbb0496d75ddb72ffbb744a4258ca7bca73ad0817312a07ac0e715d490c906cc24307dfb719bf3a4ac7cbf7fd9396c98ba66b224789dd987830d1
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Zeitwerk
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
|
5
|
+
[![Gem Version](https://img.shields.io/gem/v/zeitwerk.svg?style=for-the-badge)](https://rubygems.org/gems/zeitwerk)
|
6
|
+
[![Build Status](https://img.shields.io/travis/com/fxn/zeitwerk.svg?style=for-the-badge)](https://travis-ci.com/fxn/zeitwerk)
|
5
7
|
|
6
8
|
<!-- TOC -->
|
7
9
|
|
@@ -294,17 +296,27 @@ Zeitwerk is silent by default, but you can configure a callable as logger:
|
|
294
296
|
|
295
297
|
```ruby
|
296
298
|
loader.logger = method(:puts)
|
299
|
+
loader.logger = ->(msg) { ... }
|
297
300
|
```
|
298
301
|
|
299
|
-
|
302
|
+
as well as anything that responds to `debug`:
|
300
303
|
|
301
|
-
|
304
|
+
```ruby
|
305
|
+
loader.logger = Logger.new($stderr)
|
306
|
+
loader.logger = Rails.logger
|
307
|
+
```
|
308
|
+
|
309
|
+
In both cases, the corresponding methods are going to be passed exactly one argument with the message to be logged.
|
310
|
+
|
311
|
+
It is also possible to set a global default this way:
|
302
312
|
|
303
313
|
```ruby
|
304
314
|
Zeitwerk::Loader.default_logger = method(:puts)
|
305
315
|
```
|
306
316
|
|
307
|
-
If
|
317
|
+
If there is a logger configured, you'll see traces when autoloads are set, files loaded, and modules autovivified. While reloading, removed autoloads and unloaded objects are also traced.
|
318
|
+
|
319
|
+
As a curiosity, if your project has namespaces you'll notice in the traces Zeitwerk sets autoloads for _directories_. That's a technique used to be able to descend into subdirectories on demand, avoiding that way unnecessary tree walks.
|
308
320
|
|
309
321
|
#### Loader tag
|
310
322
|
|
data/lib/zeitwerk/loader.rb
CHANGED
@@ -11,7 +11,7 @@ module Zeitwerk
|
|
11
11
|
# @return [#camelize]
|
12
12
|
attr_accessor :inflector
|
13
13
|
|
14
|
-
# @return [#call, nil]
|
14
|
+
# @return [#call, #debug, nil]
|
15
15
|
attr_accessor :logger
|
16
16
|
|
17
17
|
# Absolute paths of the root directories. Stored in a hash to preserve
|
@@ -535,7 +535,8 @@ module Zeitwerk
|
|
535
535
|
# @param message [String]
|
536
536
|
# @return [void]
|
537
537
|
def log(message)
|
538
|
-
logger.
|
538
|
+
method_name = logger.respond_to?(:debug) ? :debug : :call
|
539
|
+
logger.send(method_name, "Zeitwerk@#{tag}: #{message}")
|
539
540
|
end
|
540
541
|
|
541
542
|
def enable_tracer
|
data/lib/zeitwerk/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.3.0
|
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-02-
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Zeitwerk implements constant autoloading with Ruby semantics. Each gem
|