listen 3.1.4 → 3.3.0.pre.3

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
- SHA1:
3
- metadata.gz: 05435b0c887f33c85311496c9a3f70893643e4c0
4
- data.tar.gz: 5fab5f773c1b319cb315aaa473e457b665c4d194
2
+ SHA256:
3
+ metadata.gz: 1d6639e347ad2eafe447bbb0c00b50ceab5e3f7a6b3bdce169482c910765198d
4
+ data.tar.gz: 617efbcc3815ea658bc886e02d9ee24a0dd142cc0273442d4323d55766c5d8ed
5
5
  SHA512:
6
- metadata.gz: e043ba05ee1b0183cc07312ba01e96271963415d4747537a2f0ebb9209c56686261bb23029a9d858e6ca2d45fa6fb70e24028f2a1a168f5a877bc006e44c59f7
7
- data.tar.gz: e71c649ef737b86eb4be5fac4ff41b04a63cc1d631899fe4c29e32f1a55a1ad5d0786fa320d052f2e94d97454a0b64639dd35a10b318ad530864f592e7697c49
6
+ metadata.gz: 5e55c50925feb8a8909978344e3061cec23ae2ee9cdba2583928da45bb907eb17284e7fb94aad431c9b1ba141f6401f98f131c6b774fe49619ea7bf353c6f352
7
+ data.tar.gz: 221ca770caf975a3bd686704e93888a852cba10e725f582c22076a42d0540b085f929faaf474b9d81690beb0c88fb647107e3bf296e738bd913d1c0f5097a442
@@ -31,8 +31,15 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
31
31
  * Make sure your patches are well tested. All specs run with `rake spec` must pass.
32
32
  * Update the [Yard](http://yardoc.org/) documentation.
33
33
  * Update the [README](https://github.com/guard/listen/blob/master/README.md).
34
- * Update the [CHANGELOG](https://github.com/guard/listen/blob/master/CHANGELOG.md) for noteworthy changes.
35
34
  * Please **do not change** the version number.
36
35
 
36
+ The title of your PR will automatically be included in the release notes for the next version of the gem. A maintainer can add one of the following GitHub labels to the PR to automatically categorize it when the release notes are generated:
37
+
38
+ - ⚠️ Breaking
39
+ - ✨ Feature
40
+ - 🐛 Bug Fix
41
+ - 📚 Docs
42
+ - 🏠 Housekeeping
43
+
37
44
  For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
38
45
  `#guard` (irc.freenode.net).
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
- ## IMPORTANT: [Ruby 2.1 is officially outdated and unsupported!](https://www.ruby-lang.org/en/news/2016/03/30/ruby-2-1-9-released/) Please upgrade to Ruby 2.2 before installing Listen!
2
-
3
- ### (To install for older versions, update Bundler to a prerelease version: `gem install bundler --pre` and Bundler should correctly resolve to an earlier gems for your given Ruby version).
4
-
5
- :exclamation: Listen is currently accepting more maintainers. Please [read this](https://github.com/guard/guard/wiki/Maintainers) if you're interested in joining the team.
6
-
7
1
  # Listen
8
2
 
9
- [![Gem Version](https://badge.fury.io/rb/listen.png)](http://badge.fury.io/rb/listen) [![Build Status](https://travis-ci.org/guard/listen.png)](https://travis-ci.org/guard/listen) [![Dependency Status](https://gemnasium.com/guard/listen.png)](https://gemnasium.com/guard/listen) [![Code Climate](https://codeclimate.com/github/guard/listen.png)](https://codeclimate.com/github/guard/listen) [![Coverage Status](https://coveralls.io/repos/guard/listen/badge.png?branch=master)](https://coveralls.io/r/guard/listen)
3
+ The `listen` gem listens to file modifications and notifies you about the changes.
4
+
5
+ :exclamation: `Listen` is currently accepting more maintainers. Please [read this](https://github.com/guard/guard/wiki/Maintainers) if you're interested in joining the team.
10
6
 
11
- The Listen gem listens to file modifications and notifies you about the changes.
7
+ [![Development Status](https://github.com/guard/listen/workflows/Development/badge.svg)](https://github.com/guard/listen/actions?workflow=Development)
8
+ [![Gem Version](https://badge.fury.io/rb/listen.svg)](http://badge.fury.io/rb/listen)
9
+ [![Code Climate](https://codeclimate.com/github/guard/listen.svg)](https://codeclimate.com/github/guard/listen)
10
+ [![Coverage Status](https://coveralls.io/repos/guard/listen/badge.svg?branch=master)](https://coveralls.io/r/guard/listen)
12
11
 
13
12
  ## Features
14
13
 
@@ -26,36 +25,81 @@ The Listen gem listens to file modifications and notifies you about the changes.
26
25
  * Symlinked directories pointing within a watched directory are not supported ([#273](https://github.com/guard/listen/pull/273)- see [Duplicate directory errors](https://github.com/guard/listen/wiki/Duplicate-directory-errors)).
27
26
  * No directory/adapter-specific configuration options.
28
27
  * Support for plugins planned for future.
29
- * TCP functionality was removed in Listen [3.0.0](https://github.com/guard/listen/releases/tag/v3.0.0) ([#319](https://github.com/guard/listen/issues/319), [#218](https://github.com/guard/listen/issues/218)). There are plans to extract this feature to separate gems ([#258](https://github.com/guard/listen/issues/258)), until this is finished, you can use by locking the `listen` gem to version `'~> 2.10'`.
28
+ * TCP functionality was removed in `listen` [3.0.0](https://github.com/guard/listen/releases/tag/v3.0.0) ([#319](https://github.com/guard/listen/issues/319), [#218](https://github.com/guard/listen/issues/218)). There are plans to extract this feature to separate gems ([#258](https://github.com/guard/listen/issues/258)), until this is finished, you can use by locking the `listen` gem to version `'~> 2.10'`.
30
29
  * Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.).
31
30
  * Specs suite on JRuby and Rubinius aren't reliable on Travis CI, but should work.
32
31
  * Windows and \*BSD adapter aren't continuously and automatically tested.
33
32
  * OSX adapter has some performance limitations ([#342](https://github.com/guard/listen/issues/342)).
34
- * Ruby < 2.2.x is no longer supported - upgrade to Ruby 2.2 or 2.3
33
+ * FreeBSD users need patched version of rb-kqueue (as of 2020/11). See #475 for the issue, mat813/rb-kqueue#12 for the patch, and Bug 250432 in bugzilla.
34
+ * Listeners do not notify across forked processes, if you wish for multiple processes to receive change notifications you must [listen inside of each process](https://github.com/guard/listen/issues/398#issuecomment-223957952).
35
35
 
36
36
  Pull requests or help is very welcome for these.
37
37
 
38
38
  ## Install
39
39
 
40
- The simplest way to install Listen is to use [Bundler](http://bundler.io).
40
+ The simplest way to install `listen` is to use [Bundler](http://bundler.io).
41
+
42
+ ```ruby
43
+ gem 'listen', '~> 3.3' # NOTE: for TCP functionality, use '~> 2.10' for now
44
+ ```
41
45
 
46
+ ## Complete Example
47
+ Here is a complete example of using the `listen` gem:
42
48
  ```ruby
43
- gem 'listen', '~> 3.0' # NOTE: for TCP functionality, use '~> 2.10' for now
49
+ require 'listen'
50
+
51
+ listener = Listen.to('/srv/app') do |modified, added, removed|
52
+ puts(modified: modified, added: added, removed: removed)
53
+ end
54
+ listener.start
55
+ sleep
56
+ ```
57
+ Running the above in the background, you can see the callback block being called in response to each command:
58
+ ```
59
+ $ cd /srv/app
60
+ $ touch a.txt
61
+ {:modified=>[], :added=>["/srv/app/a.txt"], :removed=>[]}
62
+
63
+ $ echo more >> a.txt
64
+ {:modified=>["/srv/app/a.txt"], :added=>[], :removed=>[]}
65
+
66
+ $ mv a.txt b.txt
67
+ {:modified=>[], :added=>["/srv/app/b.txt"], :removed=>["/srv/app/a.txt"]}
68
+
69
+ $ vi b.txt
70
+ # add a line to this new file and press ZZ to save and exit
71
+ {:modified=>["/srv/app/b.txt"], :added=>[], :removed=>[]}
72
+
73
+ $ vi c.txt
74
+ # add a line and press ZZ to save and exit
75
+ {:modified=>[], :added=>["/srv/app/c.txt"], :removed=>[]}
76
+
77
+ $ rm b.txt c.txt
78
+ {:modified=>[], :added=>[], :removed=>["/srv/app/b.txt", "/srv/app/c.txt"]}
44
79
  ```
45
80
 
46
81
  ## Usage
47
82
 
48
- Call `Listen.to` with either a single directory or multiple directories, then define the "changes" callback in a block.
83
+ Call `Listen.to` with one or more directories and the "changes" callback passed as a block.
49
84
 
50
85
  ``` ruby
51
86
  listener = Listen.to('dir/to/listen', 'dir/to/listen2') do |modified, added, removed|
52
- puts "modified absolute path: #{modified}"
53
- puts "added absolute path: #{added}"
54
- puts "removed absolute path: #{removed}"
87
+ puts "modified absolute path array: #{modified}"
88
+ puts "added absolute path array: #{added}"
89
+ puts "removed absolute path array: #{removed}"
55
90
  end
56
- listener.start # not blocking
91
+ listener.start # starts a listener thread--does not block
92
+
93
+ # do whatever you want here...just don't exit the process :)
94
+
57
95
  sleep
58
96
  ```
97
+ ## Changes Callback
98
+
99
+ Changes to the listened-to directories are reported by the listener thread in a callback.
100
+ The callback receives **three** array parameters: `modified`, `added` and `removed`, in that order.
101
+ Each of these three is always an array with 0 or more entries.
102
+ Each array entry is an absolute path.
59
103
 
60
104
  ### Pause / unpause / stop
61
105
 
@@ -76,13 +120,14 @@ listener.unpause # resumes processing changes ("start" would do the same)
76
120
  listener.stop # stop both listening to changes and processing them
77
121
  ```
78
122
 
79
- Note: While paused, Listen keeps on collecting changes in the background - to clear them, call "stop"
123
+ Note: While paused, `listen` keeps on collecting changes in the background - to clear them, call `stop`.
80
124
 
81
- Note: You should keep track of all started listeners and stop them properly on finish.
125
+ Note: You should keep track of all started listeners and `stop` them properly on finish.
82
126
 
83
127
  ### Ignore / ignore!
84
128
 
85
- Listen ignores some directories and extensions by default (See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer), you can add ignoring patterns with the `ignore` option/method or overwrite default with `ignore!` option/method.
129
+ `Listen` ignores some directories and extensions by default (See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer).
130
+ You can add ignoring patterns with the `ignore` option/method or overwrite default with `ignore!` option/method.
86
131
 
87
132
  ``` ruby
88
133
  listener = Listen.to('dir/path/to/listen', ignore: /\.txt/) { |modified, added, removed| # ... }
@@ -94,11 +139,11 @@ sleep
94
139
 
95
140
  Note: `:ignore` regexp patterns are evaluated against relative paths.
96
141
 
97
- Note: Ignoring paths does not improve performance, except when Polling ([#274](https://github.com/guard/listen/issues/274))
142
+ Note: Ignoring paths does not improve performance, except when Polling ([#274](https://github.com/guard/listen/issues/274)).
98
143
 
99
144
  ### Only
100
145
 
101
- Listen catches all files (less the ignored ones) by default. If you want to only listen to a specific type of file (i.e., just `.rb` extension), you should use the `only` option/method.
146
+ `Listen` watches all files (less the ignored ones) by default. If you want to only listen to a specific type of file (i.e., just `.rb` extension), you should use the `only` option/method.
102
147
 
103
148
  ``` ruby
104
149
  listener = Listen.to('dir/path/to/listen', only: /\.rb$/) { |modified, added, removed| # ... }
@@ -110,35 +155,6 @@ sleep
110
155
  Note: `:only` regexp patterns are evaluated only against relative **file** paths.
111
156
 
112
157
 
113
- ## Changes callback
114
-
115
- Changes to the listened-to directories gets reported back to the user in a callback.
116
- The registered callback gets invoked, when there are changes, with **three** parameters:
117
- `modified`, `added` and `removed` paths, in that particular order.
118
- Paths are always returned in their absolute form.
119
-
120
- Example:
121
-
122
- ```ruby
123
- listener = Listen.to('path/to/app') do |modified, added, removed|
124
- # This block will be called when there are changes.
125
- end
126
- listener.start
127
- sleep
128
- ```
129
-
130
- or ...
131
-
132
- ```ruby
133
- # Create a callback
134
- callback = Proc.new do |modified, added, removed|
135
- # This proc will be called when there are changes.
136
- end
137
- listener = Listen.to('dir', &callback)
138
- listener.start
139
- sleep
140
- ```
141
-
142
158
  ## Options
143
159
 
144
160
  All the following options can be set through the `Listen.to` after the directory path(s) params.
@@ -168,16 +184,42 @@ polling_fallback_message: 'custom message' # Set a custom polling fallback
168
184
  # default: "Listen will be polling for changes. Learn more at https://github.com/guard/listen#listen-adapters."
169
185
  ```
170
186
 
171
- ## Debugging
187
+ ## Logging and Debugging
172
188
 
173
- Setting the environment variable `LISTEN_GEM_DEBUGGING=1` sets up the INFO level logger, while `LISTEN_GEM_DEBUGGING=2` sets up the DEBUG level logger.
189
+ `Listen` logs its activity to `Listen.logger`.
190
+ This is the primary method of debugging.
174
191
 
175
- You can also set `Listen.logger` to a custom logger.
192
+ ### Custom Logger
193
+ You can call `Listen.logger =` to set a custom `listen` logger for the process. For example:
194
+ ```
195
+ Listen.logger = Rails.logger
196
+ ```
176
197
 
198
+ ### Default Logger
199
+ If no custom logger is set, a default `listen` logger which logs to to `STDERR` will be created and assigned to `Listen.logger`.
177
200
 
178
- ## Listen adapters
201
+ The default logger defaults to the `error` logging level (severity).
202
+ You can override the logging level by setting the environment variable `LISTEN_GEM_DEBUGGING=<level>`.
203
+ For `<level>`, all standard `::Logger` levels are supported, with any mix of upper-/lower-case:
204
+ ```
205
+ export LISTEN_GEM_DEBUGGING=debug # or 2 [deprecated]
206
+ export LISTEN_GEM_DEBUGGING=info # or 1 or true or yes [deprecated]
207
+ export LISTEN_GEM_DEBUGGING=warn
208
+ export LISTEN_GEM_DEBUGGING=fatal
209
+ export LISTEN_GEM_DEBUGGING=error
210
+ ```
211
+ The default of `error` will be used if an unsupported value is set.
212
+
213
+ Note: The alternate values `1`, `2`, `true` and `yes` shown above are deprecated and will be removed from `listen` v4.0.
214
+
215
+ ### Disabling Logging
216
+ If you want to disable `listen` logging, set
217
+ ```
218
+ Listen.logger = ::Logger.new('/dev/null')
219
+ ```
220
+ ## Listen Adapters
179
221
 
180
- The Listen gem has a set of adapters to notify it when there are changes.
222
+ The `Listen` gem has a set of adapters to notify it when there are changes.
181
223
 
182
224
  There are 4 OS-specific adapters to support Darwin, Linux, \*BSD and Windows.
183
225
  These adapters are fast as they use some system-calls to implement the notifying function.
@@ -185,9 +227,9 @@ These adapters are fast as they use some system-calls to implement the notifying
185
227
  There is also a polling adapter - although it's much slower than other adapters,
186
228
  it works on every platform/system and scenario (including network filesystems such as VM shared folders).
187
229
 
188
- The Darwin and Linux adapters are dependencies of the Listen gem so they work out of the box. For other adapters a specific gem will have to be added to your Gemfile, please read below.
230
+ The Darwin and Linux adapters are dependencies of the `listen` gem so they work out of the box. For other adapters a specific gem will have to be added to your Gemfile, please read below.
189
231
 
190
- The Listen gem will choose the best adapter automatically, if present. If you
232
+ The `listen` gem will choose the best adapter automatically, if present. If you
191
233
  want to force the use of the polling adapter, use the `:force_polling` option
192
234
  while initializing the listener.
193
235
 
@@ -219,31 +261,33 @@ end
219
261
 
220
262
  Please visit the [installation section of the Listen WIKI](https://github.com/guard/listen/wiki#installation) for more information and options for potential fixes.
221
263
 
222
- ### Issues and troubleshooting
264
+ ### Issues and Troubleshooting
223
265
 
224
- *NOTE: without providing the output after setting the `LISTEN_GEM_DEBUGGING=1` environment variable, it can be almost impossible to guess why listen is not working as expected.*
266
+ If the gem doesn't work as expected, start by setting `LISTEN_GEM_DEBUGGING=debug` or `LISTEN_GEM_DEBUGGING=info` as described above in [Logging and Debugging](#logging-and-debugging).
267
+
268
+ *NOTE: without providing the output after setting the `LISTEN_GEM_DEBUGGING=debug` environment variable, it is usually impossible to guess why `listen` is not working as expected.*
225
269
 
226
270
  See [TROUBLESHOOTING](https://github.com/guard/listen/wiki/Troubleshooting)
227
271
 
228
272
  ## Performance
229
273
 
230
- If Listen seems slow or unresponsive, make sure you're not using the Polling adapter (you should see a warning upon startup if you are).
274
+ If `listen` seems slow or unresponsive, make sure you're not using the Polling adapter (you should see a warning upon startup if you are).
231
275
 
232
276
  Also, if the directories you're watching contain many files, make sure you're:
233
277
 
234
278
  * not using Polling (ideally)
235
279
  * using `:ignore` and `:only` options to avoid tracking directories you don't care about (important with Polling and on MacOS)
236
- * running Listen with the `:latency` and `:wait_for_delay` options not too small or too big (depends on needs)
280
+ * running `listen` with the `:latency` and `:wait_for_delay` options not too small or too big (depends on needs)
237
281
  * not watching directories with log files, database files or other frequently changing files
238
- * not using a version of Listen prior to 2.7.7
239
- * not getting silent crashes within Listen (see LISTEN_GEM_DEBUGGING=2)
240
- * not running multiple instances of Listen in the background
282
+ * not using a version of `listen` prior to 2.7.7
283
+ * not getting silent crashes within `listen` (see `LISTEN_GEM_DEBUGGING=debug`)
284
+ * not running multiple instances of `listen` in the background
241
285
  * using a file system with atime modification disabled (ideally)
242
286
  * not using a filesystem with inaccurate file modification times (ideally), e.g. HFS, VFAT
243
287
  * not buffering to a slow terminal (e.g. transparency + fancy font + slow gfx card + lots of output)
244
288
  * ideally not running a slow encryption stack, e.g. btrfs + ecryptfs
245
289
 
246
- When in doubt, LISTEN_GEM_DEBUGGING=2 can help discover the actual events and time they happened.
290
+ When in doubt, `LISTEN_GEM_DEBUGGING=debug` can help discover the actual events and time they happened.
247
291
 
248
292
  See also [Tips and Techniques](https://github.com/guard/listen/wiki/Tips-and-Techniques).
249
293
 
@@ -263,11 +307,29 @@ Pull requests are very welcome! Please try to follow these simple rules if appli
263
307
  For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
264
308
  `#guard` (irc.freenode.net).
265
309
 
310
+ ## Releasing
311
+
312
+ ### Prerequisites
313
+
314
+ * You must have commit rights to the GitHub repository.
315
+ * You must have push rights for rubygems.org.
316
+
317
+ ### How to release
318
+
319
+ 1. Run `bundle install` to make sure that you have all the gems necessary for testing and releasing.
320
+ 2. **Ensure all tests are passing by running `bundle exec rake`.**
321
+ 3. Determine which would be the correct next version number according to [semver](http://semver.org/).
322
+ 4. Update the version in `./lib/listen/version.rb`.
323
+ 5. Update the version in the Install section of `./README.md` (`gem 'listen', '~> X.Y'`).
324
+ 6. Commit the version in a single commit, the message should be "Preparing vX.Y.Z"
325
+ 7. Run `bundle exec rake release:full`; this will tag, push to GitHub, and publish to rubygems.org.
326
+ 8. Update and publish the release notes on the [GitHub releases page](https://github.com/guard/listen/releases) if necessary
327
+
266
328
  ## Acknowledgments
267
329
 
268
330
  * [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f).
269
331
  * [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][].
270
- * [Nathan Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
332
+ * [Natalie Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
271
333
  * [Mathieu Arnold (mat813)][] for [rb-kqueue][], a simple kqueue wrapper.
272
334
  * [Maher Sallam][] for [wdm][], windows support wouldn't exist without him.
273
335
  * [Yehuda Katz (wycats)][] for [vigilo][], that has been a great source of inspiration.
@@ -287,7 +349,7 @@ For questions please join us in our [Google group](http://groups.google.com/grou
287
349
  [fssm]: https://github.com/ttilley/fssm
288
350
  [rb-fsevent]: https://github.com/thibaudgg/rb-fsevent
289
351
  [Mathieu Arnold (mat813)]: https://github.com/mat813
290
- [Nathan Weizenbaum (nex3)]: https://github.com/nex3
352
+ [Natalie Weizenbaum (nex3)]: https://github.com/nex3
291
353
  [rb-inotify]: https://github.com/nex3/rb-inotify
292
354
  [stereobooster]: https://github.com/stereobooster
293
355
  [rb-fchange]: https://github.com/stereobooster/rb-fchange
@@ -1,28 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
4
+ require 'weakref'
2
5
  require 'listen/logger'
3
6
  require 'listen/listener'
4
7
 
5
- require 'listen/internals/thread_pool'
6
-
7
- # Show warnings about vulnerabilities, bugs and outdated Rubies, since previous
8
- # versions aren't tested or officially supported.
9
- require 'ruby_dep/warning'
10
- RubyDep::Warning.new.show_warnings
11
-
12
- # Always set up logging by default first time file is required
13
- #
14
- # NOTE: If you need to clear the logger completely, do so *after*
15
- # requiring this file. If you need to set a custom logger,
16
- # require the listen/logger file and set the logger before requiring
17
- # this file.
18
- Listen.setup_default_logger_if_unset
19
-
20
8
  # Won't print anything by default because of level - unless you've set
21
9
  # LISTEN_GEM_DEBUGGING or provided your own logger with a high enough level
22
- Listen::Logger.info "Listen loglevel set to: #{Listen.logger.level}"
23
- Listen::Logger.info "Listen version: #{Listen::VERSION}"
10
+ Listen.logger.info "Listen loglevel set to: #{Listen.logger.level}"
11
+ Listen.logger.info "Listen version: #{Listen::VERSION}"
24
12
 
25
13
  module Listen
14
+ @listeners = Queue.new
15
+
26
16
  class << self
27
17
  # Listens to file system modifications on a either single directory or
28
18
  # multiple directories.
@@ -37,21 +27,21 @@ module Listen
37
27
  # @return [Listen::Listener] the listener
38
28
  #
39
29
  def to(*args, &block)
40
- @listeners ||= []
41
30
  Listener.new(*args, &block).tap do |listener|
42
- @listeners << listener
31
+ @listeners.enq(WeakRef.new(listener))
43
32
  end
44
33
  end
45
34
 
46
35
  # This is used by the `listen` binary to handle Ctrl-C
47
36
  #
48
37
  def stop
49
- Internals::ThreadPool.stop
50
- @listeners ||= []
51
-
52
- # TODO: should use a mutex for this
53
- @listeners.each(&:stop)
54
- @listeners = nil
38
+ while (listener = @listeners.deq(true))
39
+ begin
40
+ listener.stop
41
+ rescue WeakRef::RefError
42
+ end
43
+ end
44
+ rescue ThreadError
55
45
  end
56
46
  end
57
47
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'listen/adapter/base'
2
4
  require 'listen/adapter/bsd'
3
5
  require 'listen/adapter/darwin'
@@ -13,15 +15,15 @@ module Listen
13
15
 
14
16
  class << self
15
17
  def select(options = {})
16
- _log :debug, 'Adapter: considering polling ...'
18
+ Listen.logger.debug 'Adapter: considering polling ...'
17
19
  return Polling if options[:force_polling]
18
- _log :debug, 'Adapter: considering optimized backend...'
20
+ Listen.logger.debug 'Adapter: considering optimized backend...'
19
21
  return _usable_adapter_class if _usable_adapter_class
20
- _log :debug, 'Adapter: falling back to polling...'
22
+ Listen.logger.debug 'Adapter: falling back to polling...'
21
23
  _warn_polling_fallback(options)
22
24
  Polling
23
25
  rescue
24
- _log :warn, format('Adapter: failed: %s:%s', $ERROR_POSITION.inspect,
26
+ Listen.logger.warn format('Adapter: failed: %s:%s', $ERROR_POSITION.inspect,
25
27
  $ERROR_POSITION * "\n")
26
28
  raise
27
29
  end
@@ -36,10 +38,6 @@ module Listen
36
38
  msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
37
39
  Kernel.warn "[Listen warning]:\n #{msg}" if msg
38
40
  end
39
-
40
- def _log(type, message)
41
- Listen::Logger.send(type, message)
42
- end
43
41
  end
44
42
  end
45
43
  end