zeitwerk 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27e00c74f6a46e57850f8b6ad1453efac2d7f287a5f8d8e390d5afe59c30b0a
4
- data.tar.gz: e3350166f6c3c6276a684d6f969a9045a06efc9a4308390dbc893df5eb3647a0
3
+ metadata.gz: 69ab50936501a8a78e6be01014ac8e97890297955088fdac78cf1d5adeea7e78
4
+ data.tar.gz: 2afe0ae004e102604e2b23133ef683bad6753479bd9be0ef37379676d5c47a09
5
5
  SHA512:
6
- metadata.gz: d4ef494343f7c01dd1ac0d61f9feff1bc58aae0d05e12d903d639e121f28a845f49d8de76914c1f85c5387aa8905d79b5dd58e16b6bbd5c631454669a52fe91b
7
- data.tar.gz: 4c758643e0a9e57d8b5462c638b62c3149d7efaa2f604ebd30e70019486cb24a3268a537110282d644621545ffaa0072358bb9bc11d642c04840312ac5ebea94
6
+ metadata.gz: 51ceaebc945976ba34a6025d225099ab69e337287a3577c1f1e484d0fc1e4d6efec00e2e132a9cb794d91101f1f484dc154ef6e97c3b0a392f16a9ec5c340bdb
7
+ data.tar.gz: ab59de0733cdbb0496d75ddb72ffbb744a4258ca7bca73ad0817312a07ac0e715d490c906cc24307dfb719bf3a4ac7cbf7fd9396c98ba66b224789dd987830d1
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Zeitwerk
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/zeitwerk.svg)](https://badge.fury.io/rb/zeitwerk)
4
- [![Build Status](https://travis-ci.com/fxn/zeitwerk.svg?branch=master)](https://travis-ci.com/fxn/zeitwerk)
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
- If there is a logger configured, the loader is going to print traces when autoloads are set, files loaded, and modules autovivified. While reloading, removed autoloads and unloaded objects are also traced.
302
+ as well as anything that responds to `debug`:
300
303
 
301
- It is possible to set a global default this way:
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 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.
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
 
@@ -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.call("Zeitwerk@#{tag}: #{message}")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zeitwerk
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
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: 1.2.0
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-17 00:00:00.000000000 Z
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