listen 3.3.3 → 3.5.1
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 +4 -4
- data/CONTRIBUTING.md +2 -2
- data/README.md +113 -8
- data/lib/listen/adapter/base.rb +2 -2
- data/lib/listen/adapter/linux.rb +4 -4
- data/lib/listen/adapter/polling.rb +5 -4
- data/lib/listen/error.rb +10 -0
- data/lib/listen/event/config.rb +0 -4
- data/lib/listen/event/loop.rb +5 -4
- data/lib/listen/event/processor.rb +7 -9
- data/lib/listen/fsm.rb +3 -0
- data/lib/listen/monotonic_time.rb +27 -0
- data/lib/listen/record.rb +3 -15
- data/lib/listen/record/symlink_detector.rb +6 -6
- data/lib/listen/thread.rb +1 -1
- data/lib/listen/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 321b55dd88acb041f6dfa31d44047d4f90ebfa970adb85d82facd5ceff94db90
|
|
4
|
+
data.tar.gz: 4e4eb8728548f782d6b99b7b9b40473102f31315e27dae2bacf2b146c2609969
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 843e2fe248d9216087fc09e8a5e70f6ee10ed27e55fe993939c93ee1260d55fa3076a684579cae143f304e24b5ecc98318de0e00678e63bee9f52192b1e7292b
|
|
7
|
+
data.tar.gz: a74621cffdb908165c010b50848e07e9eef9eed9e53b3449533752f2a54caceb5d57c9e1e02c43560a3e6832d6210fd3540e838de34c6f6d1e391d496a5bf8de
|
data/CONTRIBUTING.md
CHANGED
|
@@ -4,7 +4,7 @@ Contribute to Listen
|
|
|
4
4
|
File an issue
|
|
5
5
|
-------------
|
|
6
6
|
|
|
7
|
-
If you haven't already, first see [TROUBLESHOOTING](https://github.com/guard/listen/
|
|
7
|
+
If you haven't already, first see [TROUBLESHOOTING](https://github.com/guard/listen/blob/master/README.md#Issues-and-Troubleshooting) for known issues, solutions and workarounds.
|
|
8
8
|
|
|
9
9
|
You can report bugs and feature requests to [GitHub Issues](https://github.com/guard/listen/issues).
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ Try to figure out where the issue belongs to: Is it an issue with Listen itself
|
|
|
16
16
|
|
|
17
17
|
**It's most likely that your bug gets resolved faster if you provide as much information as possible!**
|
|
18
18
|
|
|
19
|
-
The MOST useful information is debugging output from Listen (`LISTEN_GEM_DEBUGGING=1`) - see [TROUBLESHOOTING](https://github.com/guard/listen/
|
|
19
|
+
The MOST useful information is debugging output from Listen (`LISTEN_GEM_DEBUGGING=1`) - see [TROUBLESHOOTING](https://github.com/guard/listen/blob/master/README.md#Issues-and-Troubleshooting) for details.
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
Development
|
data/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The `listen` gem listens to file modifications and notifies you about the changes.
|
|
4
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
5
|
[](https://github.com/guard/listen/actions?workflow=Development)
|
|
8
6
|
[](http://badge.fury.io/rb/listen)
|
|
9
7
|
[](https://codeclimate.com/github/guard/listen)
|
|
@@ -22,7 +20,7 @@ The `listen` gem listens to file modifications and notifies you about the change
|
|
|
22
20
|
|
|
23
21
|
* Limited support for symlinked directories ([#279](https://github.com/guard/listen/issues/279)):
|
|
24
22
|
* Symlinks are always followed ([#25](https://github.com/guard/listen/issues/25)).
|
|
25
|
-
* Symlinked directories pointing within a watched directory are not supported ([#273](https://github.com/guard/listen/pull/273)
|
|
23
|
+
* Symlinked directories pointing within a watched directory are not supported ([#273](https://github.com/guard/listen/pull/273).
|
|
26
24
|
* No directory/adapter-specific configuration options.
|
|
27
25
|
* Support for plugins planned for future.
|
|
28
26
|
* 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'`.
|
|
@@ -40,7 +38,7 @@ Pull requests or help is very welcome for these.
|
|
|
40
38
|
The simplest way to install `listen` is to use [Bundler](http://bundler.io).
|
|
41
39
|
|
|
42
40
|
```ruby
|
|
43
|
-
gem 'listen'
|
|
41
|
+
gem 'listen'
|
|
44
42
|
```
|
|
45
43
|
|
|
46
44
|
## Complete Example
|
|
@@ -240,7 +238,7 @@ If you are on Windows, it's recommended to use the [`wdm`](https://github.com/Ma
|
|
|
240
238
|
Please add the following to your Gemfile:
|
|
241
239
|
|
|
242
240
|
```ruby
|
|
243
|
-
gem 'wdm', '>= 0.1.0'
|
|
241
|
+
gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
244
242
|
```
|
|
245
243
|
|
|
246
244
|
### On \*BSD
|
|
@@ -259,7 +257,82 @@ end
|
|
|
259
257
|
|
|
260
258
|
### Getting the [polling fallback message](#options)?
|
|
261
259
|
|
|
262
|
-
|
|
260
|
+
If you see:
|
|
261
|
+
```
|
|
262
|
+
Listen will be polling for changes.
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
This means the Listen gem can’t find an optimized adapter. Typically this is caused by:
|
|
266
|
+
|
|
267
|
+
- You’re on Windows and WDM gem isn’t installed.
|
|
268
|
+
- You’re running the app without Bundler or RubyGems.
|
|
269
|
+
- Using Sass which includes an ancient (the “dinosaur” type of ancient) version of the Listen gem.
|
|
270
|
+
|
|
271
|
+
Possible solutions:
|
|
272
|
+
|
|
273
|
+
1. Suppress the message by using the :force_polling option. Or, you could just ignore the message since it’s harmless.
|
|
274
|
+
2. Windows users: Install the WDM gem.
|
|
275
|
+
3. Upgrade Ruby (use RubyInstaller for Windows or RVM/rbenv for Mac) and RubyGems.
|
|
276
|
+
3. Run your apps using Bundler.
|
|
277
|
+
4. Sass users: Install the latest version of Listen and try again.
|
|
278
|
+
|
|
279
|
+
#### Simplified Bundler and Sass example
|
|
280
|
+
Create a Gemfile with these lines:
|
|
281
|
+
```
|
|
282
|
+
source 'https://rubygems.org'
|
|
283
|
+
gem 'listen'
|
|
284
|
+
gem 'sass'
|
|
285
|
+
```
|
|
286
|
+
Next, use Bundler to update gems:
|
|
287
|
+
```
|
|
288
|
+
$ bundle update
|
|
289
|
+
$ bundle exec sass --watch # ... or whatever app is using Listen.
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Increasing the amount of inotify watchers
|
|
293
|
+
|
|
294
|
+
If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:
|
|
295
|
+
```
|
|
296
|
+
$ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
|
|
297
|
+
$ sudo sysctl -p
|
|
298
|
+
```
|
|
299
|
+
If you are running ArchLinux, search the `/etc/sysctl.d/` directory for config files with the setting:
|
|
300
|
+
```
|
|
301
|
+
$ grep -H -s "fs.inotify.max_user_watches" /etc/sysctl.d/*
|
|
302
|
+
/etc/sysctl.d/40-max_user_watches.conf:fs.inotify.max_user_watches=100000
|
|
303
|
+
```
|
|
304
|
+
Then change the setting in the file you found above to a higher value (see [here](https://www.archlinux.org/news/deprecation-of-etcsysctlconf/) for why):
|
|
305
|
+
```
|
|
306
|
+
$ sudo sh -c "echo fs.inotify.max_user_watches=524288 > /etc/sysctl.d/40-max-user-watches.conf"
|
|
307
|
+
$ sudo sysctl --system
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
#### The technical details
|
|
311
|
+
Listen uses `inotify` by default on Linux to monitor directories for changes.
|
|
312
|
+
It's not uncommon to encounter a system limit on the number of files you can monitor.
|
|
313
|
+
For example, Ubuntu Lucid's (64bit) `inotify` limit is set to 8192.
|
|
314
|
+
|
|
315
|
+
You can get your current inotify file watch limit by executing:
|
|
316
|
+
```
|
|
317
|
+
$ cat /proc/sys/fs/inotify/max_user_watches
|
|
318
|
+
```
|
|
319
|
+
When this limit is not enough to monitor all files inside a directory, the limit must be increased for Listen to work properly.
|
|
320
|
+
|
|
321
|
+
You can set a new limit temporarily with:
|
|
322
|
+
```
|
|
323
|
+
$ sudo sysctl fs.inotify.max_user_watches=524288
|
|
324
|
+
$ sudo sysctl -p
|
|
325
|
+
```
|
|
326
|
+
If you like to make your limit permanent, use:
|
|
327
|
+
```
|
|
328
|
+
$ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
|
|
329
|
+
$ sudo sysctl -p
|
|
330
|
+
```
|
|
331
|
+
You may also need to pay attention to the values of `max_queued_events` and `max_user_instances` if Listen keeps on complaining.
|
|
332
|
+
|
|
333
|
+
#### More info
|
|
334
|
+
Man page for [inotify(7)](https://linux.die.net/man/7/inotify).
|
|
335
|
+
Blog post: [limit of inotify](https://blog.sorah.jp/2012/01/24/inotify-limitation).
|
|
263
336
|
|
|
264
337
|
### Issues and Troubleshooting
|
|
265
338
|
|
|
@@ -267,7 +340,35 @@ If the gem doesn't work as expected, start by setting `LISTEN_GEM_DEBUGGING=debu
|
|
|
267
340
|
|
|
268
341
|
*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.*
|
|
269
342
|
|
|
270
|
-
|
|
343
|
+
#### 3 steps before you start diagnosing problems
|
|
344
|
+
These 3 steps will:
|
|
345
|
+
|
|
346
|
+
- help quickly troubleshoot obscure problems (trust me, most of them are obscure)
|
|
347
|
+
- help quickly identify the area of the problem (a full list is below)
|
|
348
|
+
- help you get familiar with listen's diagnostic mode (it really comes in handy, trust me)
|
|
349
|
+
- help you create relevant output before you submit an issue (so we can respond with answers instead of tons of questions)
|
|
350
|
+
|
|
351
|
+
Step 1 - The most important option in Listen
|
|
352
|
+
For effective troubleshooting set the `LISTEN_GEM_DEBUGGING=info` variable before starting `listen`.
|
|
353
|
+
|
|
354
|
+
Step 2 - Verify polling works
|
|
355
|
+
Polling has to work ... or something is really wrong (and we need to know that before anything else).
|
|
356
|
+
|
|
357
|
+
(see force_polling option).
|
|
358
|
+
|
|
359
|
+
After starting `listen`, you should see something like:
|
|
360
|
+
```
|
|
361
|
+
INFO -- : Record.build(): 0.06773114204406738 seconds
|
|
362
|
+
```
|
|
363
|
+
Step 3 - Trigger some changes directly without using editors or apps
|
|
364
|
+
Make changes e.g. touch foo or echo "a" >> foo (for troubleshooting, avoid using an editor which could generate too many misleading events).
|
|
365
|
+
|
|
366
|
+
You should see something like:
|
|
367
|
+
```
|
|
368
|
+
INFO -- : listen: raw changes: [[:added, "/home/me/foo"]]
|
|
369
|
+
INFO -- : listen: final changes: {:modified=>[], :added=>["/home/me/foo"], :removed=>[]}
|
|
370
|
+
```
|
|
371
|
+
"raw changes" contains changes collected during the :wait_for_delay and :latency intervals, while "final changes" is what listen decided are relevant changes (for better editor support).
|
|
271
372
|
|
|
272
373
|
## Performance
|
|
273
374
|
|
|
@@ -289,7 +390,11 @@ Also, if the directories you're watching contain many files, make sure you're:
|
|
|
289
390
|
|
|
290
391
|
When in doubt, `LISTEN_GEM_DEBUGGING=debug` can help discover the actual events and time they happened.
|
|
291
392
|
|
|
292
|
-
|
|
393
|
+
## Tips and Techniques
|
|
394
|
+
- Watch only directories you're interested in.
|
|
395
|
+
- Set your editor to save quickly (e.g. without backup files, without atomic-save)
|
|
396
|
+
- Tweak the `:latency` and `:wait_for_delay` options until you get good results (see [options](#options)).
|
|
397
|
+
- Add `:ignore` rules to silence all events you don't care about (reduces a lot of noise, especially if you use it on directories)
|
|
293
398
|
|
|
294
399
|
## Development
|
|
295
400
|
|
data/lib/listen/adapter/base.rb
CHANGED
|
@@ -93,9 +93,9 @@ module Listen
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def _timed(title)
|
|
96
|
-
start =
|
|
96
|
+
start = MonotonicTime.now
|
|
97
97
|
yield
|
|
98
|
-
diff =
|
|
98
|
+
diff = MonotonicTime.now - start
|
|
99
99
|
Listen.logger.info format('%s: %.05f seconds', title, diff)
|
|
100
100
|
rescue
|
|
101
101
|
Listen.logger.warn "#{title} crashed: #{$ERROR_INFO.inspect}"
|
data/lib/listen/adapter/linux.rb
CHANGED
|
@@ -21,12 +21,12 @@ module Listen
|
|
|
21
21
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
'/
|
|
24
|
+
README_URL = 'https://github.com/guard/listen'\
|
|
25
|
+
'/blob/master/README.md#increasing-the-amount-of-inotify-watchers'
|
|
26
26
|
|
|
27
|
-
INOTIFY_LIMIT_MESSAGE = <<-EOS
|
|
27
|
+
INOTIFY_LIMIT_MESSAGE = <<-EOS
|
|
28
28
|
FATAL: Listen error: unable to monitor directories for changes.
|
|
29
|
-
Visit #{
|
|
29
|
+
Visit #{README_URL} for info on how to fix this.
|
|
30
30
|
EOS
|
|
31
31
|
|
|
32
32
|
def _configure(directory, &callback)
|
|
@@ -21,12 +21,13 @@ module Listen
|
|
|
21
21
|
|
|
22
22
|
def _run
|
|
23
23
|
loop do
|
|
24
|
-
start =
|
|
24
|
+
start = MonotonicTime.now
|
|
25
25
|
@polling_callbacks.each do |callback|
|
|
26
26
|
callback.call(nil)
|
|
27
|
-
nap_time = options.latency - (
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (nap_time = options.latency - (MonotonicTime.now - start)) > 0
|
|
28
|
+
# TODO: warn if nap_time is negative (polling too slow)
|
|
29
|
+
sleep(nap_time)
|
|
30
|
+
end
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
end
|
data/lib/listen/error.rb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Besides programming error exceptions like ArgumentError,
|
|
4
|
+
# all public interface exceptions should be declared here and inherit from Listen::Error.
|
|
5
|
+
module Listen
|
|
6
|
+
class Error < RuntimeError
|
|
7
|
+
class NotStarted < Error; end
|
|
8
|
+
class SymlinkLoop < Error; end
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/listen/event/config.rb
CHANGED
data/lib/listen/event/loop.rb
CHANGED
|
@@ -5,15 +5,15 @@ require 'thread'
|
|
|
5
5
|
require 'timeout'
|
|
6
6
|
require 'listen/event/processor'
|
|
7
7
|
require 'listen/thread'
|
|
8
|
+
require 'listen/error'
|
|
8
9
|
|
|
9
10
|
module Listen
|
|
10
11
|
module Event
|
|
11
12
|
class Loop
|
|
12
13
|
include Listen::FSM
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
15
|
+
Error = ::Listen::Error
|
|
16
|
+
NotStarted = ::Listen::Error::NotStarted # for backward compatibility
|
|
17
17
|
|
|
18
18
|
start_state :pre_start
|
|
19
19
|
state :pre_start
|
|
@@ -40,6 +40,7 @@ module Listen
|
|
|
40
40
|
|
|
41
41
|
MAX_STARTUP_SECONDS = 5.0
|
|
42
42
|
|
|
43
|
+
# @raises Error::NotStarted if background thread hasn't started in MAX_STARTUP_SECONDS
|
|
43
44
|
def start
|
|
44
45
|
# TODO: use a Fiber instead?
|
|
45
46
|
return unless state == :pre_start
|
|
@@ -52,7 +53,7 @@ module Listen
|
|
|
52
53
|
|
|
53
54
|
Listen.logger.debug("Waiting for processing to start...")
|
|
54
55
|
|
|
55
|
-
wait_for_state(:started, MAX_STARTUP_SECONDS) or
|
|
56
|
+
wait_for_state(:started, timeout: MAX_STARTUP_SECONDS) or
|
|
56
57
|
raise Error::NotStarted, "thread didn't start in #{MAX_STARTUP_SECONDS} seconds (in state: #{state.inspect})"
|
|
57
58
|
|
|
58
59
|
Listen.logger.debug('Processing started.')
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'listen/monotonic_time'
|
|
4
|
+
|
|
3
5
|
module Listen
|
|
4
6
|
module Event
|
|
5
7
|
class Processor
|
|
@@ -33,7 +35,7 @@ module Listen
|
|
|
33
35
|
|
|
34
36
|
def _wait_until_events_calm_down
|
|
35
37
|
loop do
|
|
36
|
-
now =
|
|
38
|
+
now = MonotonicTime.now
|
|
37
39
|
|
|
38
40
|
# Assure there's at least latency between callbacks to allow
|
|
39
41
|
# for accumulating changes
|
|
@@ -70,7 +72,7 @@ module Listen
|
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
def _remember_time_of_first_unprocessed_event
|
|
73
|
-
@_remember_time_of_first_unprocessed_event ||=
|
|
75
|
+
@_remember_time_of_first_unprocessed_event ||= MonotonicTime.now
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
def _reset_no_unprocessed_events
|
|
@@ -85,7 +87,7 @@ module Listen
|
|
|
85
87
|
# returns the event or `nil` when the event_queue is closed
|
|
86
88
|
def _wait_until_events
|
|
87
89
|
config.event_queue.pop.tap do |_event|
|
|
88
|
-
@_remember_time_of_first_unprocessed_event ||=
|
|
90
|
+
@_remember_time_of_first_unprocessed_event ||= MonotonicTime.now
|
|
89
91
|
end
|
|
90
92
|
end
|
|
91
93
|
|
|
@@ -96,10 +98,6 @@ module Listen
|
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
100
|
|
|
99
|
-
def _timestamp
|
|
100
|
-
config.timestamp
|
|
101
|
-
end
|
|
102
|
-
|
|
103
101
|
# for easier testing without sleep loop
|
|
104
102
|
def _process_changes(event)
|
|
105
103
|
_reset_no_unprocessed_events
|
|
@@ -113,13 +111,13 @@ module Listen
|
|
|
113
111
|
result = [hash[:modified], hash[:added], hash[:removed]]
|
|
114
112
|
return if result.all?(&:empty?)
|
|
115
113
|
|
|
116
|
-
block_start =
|
|
114
|
+
block_start = MonotonicTime.now
|
|
117
115
|
exception_note = " (exception)"
|
|
118
116
|
::Listen::Thread.rescue_and_log('_process_changes') do
|
|
119
117
|
config.call(*result)
|
|
120
118
|
exception_note = nil
|
|
121
119
|
end
|
|
122
|
-
Listen.logger.debug "Callback#{exception_note} took #{
|
|
120
|
+
Listen.logger.debug "Callback#{exception_note} took #{MonotonicTime.now - block_start} sec"
|
|
123
121
|
end
|
|
124
122
|
|
|
125
123
|
attr_reader :config
|
data/lib/listen/fsm.rb
CHANGED
|
@@ -53,6 +53,9 @@ module Listen
|
|
|
53
53
|
# if not already, waits for a state change (up to timeout seconds--`nil` means infinite)
|
|
54
54
|
# returns truthy iff the transition to one of the desired state has occurred
|
|
55
55
|
def wait_for_state(*wait_for_states, timeout: nil)
|
|
56
|
+
wait_for_states.each do |state|
|
|
57
|
+
state.is_a?(Symbol) or raise ArgumentError, "states must be symbols (got #{state.inspect})"
|
|
58
|
+
end
|
|
56
59
|
@mutex.synchronize do
|
|
57
60
|
if !wait_for_states.include?(@state)
|
|
58
61
|
@state_changed.wait(@mutex, timeout)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Listen
|
|
4
|
+
module MonotonicTime
|
|
5
|
+
class << self
|
|
6
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
|
7
|
+
|
|
8
|
+
def now
|
|
9
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
elsif defined?(Process::CLOCK_MONOTONIC_RAW)
|
|
13
|
+
|
|
14
|
+
def now
|
|
15
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
else
|
|
19
|
+
|
|
20
|
+
def now
|
|
21
|
+
Time.now.to_f
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/listen/record.rb
CHANGED
|
@@ -45,10 +45,11 @@ module Listen
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def dir_entries(rel_path)
|
|
48
|
-
subtree = if [
|
|
48
|
+
subtree = if ['', '.'].include? rel_path.to_s
|
|
49
49
|
@tree
|
|
50
50
|
else
|
|
51
|
-
|
|
51
|
+
@tree[rel_path.to_s] ||= _auto_hash
|
|
52
|
+
@tree[rel_path.to_s]
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
subtree.transform_values do |values|
|
|
@@ -57,19 +58,6 @@ module Listen
|
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
def _sub_tree(rel_path)
|
|
61
|
-
@tree.each_with_object({}) do |(path, meta), result|
|
|
62
|
-
next unless path.start_with?(rel_path)
|
|
63
|
-
|
|
64
|
-
if path == rel_path
|
|
65
|
-
result.merge!(meta)
|
|
66
|
-
else
|
|
67
|
-
sub_path = path.sub(%r{\A#{rel_path}/?}, '')
|
|
68
|
-
result[sub_path] = meta
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
61
|
def build
|
|
74
62
|
@tree = _auto_hash
|
|
75
63
|
# TODO: test with a file name given
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'set'
|
|
4
|
+
require 'listen/error'
|
|
4
5
|
|
|
5
6
|
module Listen
|
|
6
7
|
# @private api
|
|
7
8
|
class Record
|
|
8
9
|
class SymlinkDetector
|
|
9
|
-
|
|
10
|
+
README_URL = 'https://github.com/guard/listen/blob/master/README.md'
|
|
10
11
|
|
|
11
12
|
SYMLINK_LOOP_ERROR = <<-EOS
|
|
12
13
|
** ERROR: directory is already being watched! **
|
|
@@ -15,11 +16,10 @@ module Listen
|
|
|
15
16
|
|
|
16
17
|
is already being watched through: %s
|
|
17
18
|
|
|
18
|
-
MORE INFO: #{
|
|
19
|
+
MORE INFO: #{README_URL}
|
|
19
20
|
EOS
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
end
|
|
22
|
+
Error = ::Listen::Error # for backward compatibility
|
|
23
23
|
|
|
24
24
|
def initialize
|
|
25
25
|
@real_dirs = Set.new
|
|
@@ -27,14 +27,14 @@ module Listen
|
|
|
27
27
|
|
|
28
28
|
def verify_unwatched!(entry)
|
|
29
29
|
real_path = entry.real_path
|
|
30
|
-
@real_dirs.add?(real_path)
|
|
30
|
+
@real_dirs.add?(real_path) or _fail(entry.sys_path, real_path)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
35
|
def _fail(symlinked, real_path)
|
|
36
36
|
warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
|
|
37
|
-
raise Error, 'Failed due to looped symlinks'
|
|
37
|
+
raise ::Listen::Error::SymlinkLoop, 'Failed due to looped symlinks'
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
data/lib/listen/thread.rb
CHANGED
|
@@ -24,7 +24,7 @@ module Listen
|
|
|
24
24
|
|
|
25
25
|
def rescue_and_log(method_name, *args, caller_stack: nil)
|
|
26
26
|
yield(*args)
|
|
27
|
-
rescue
|
|
27
|
+
rescue => exception
|
|
28
28
|
_log_exception(exception, method_name, caller_stack: caller_stack)
|
|
29
29
|
end
|
|
30
30
|
|
data/lib/listen/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: listen
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thibaud Guillaume-Gentil
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rb-fsevent
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- lib/listen/change.rb
|
|
77
77
|
- lib/listen/cli.rb
|
|
78
78
|
- lib/listen/directory.rb
|
|
79
|
+
- lib/listen/error.rb
|
|
79
80
|
- lib/listen/event/config.rb
|
|
80
81
|
- lib/listen/event/loop.rb
|
|
81
82
|
- lib/listen/event/processor.rb
|
|
@@ -85,6 +86,7 @@ files:
|
|
|
85
86
|
- lib/listen/listener.rb
|
|
86
87
|
- lib/listen/listener/config.rb
|
|
87
88
|
- lib/listen/logger.rb
|
|
89
|
+
- lib/listen/monotonic_time.rb
|
|
88
90
|
- lib/listen/options.rb
|
|
89
91
|
- lib/listen/queue_optimizer.rb
|
|
90
92
|
- lib/listen/record.rb
|
|
@@ -101,10 +103,9 @@ metadata:
|
|
|
101
103
|
allowed_push_host: https://rubygems.org
|
|
102
104
|
bug_tracker_uri: https://github.com/guard/listen/issues
|
|
103
105
|
changelog_uri: https://github.com/guard/listen/releases
|
|
104
|
-
documentation_uri: https://www.rubydoc.info/gems/listen/3.
|
|
106
|
+
documentation_uri: https://www.rubydoc.info/gems/listen/3.5.1
|
|
105
107
|
homepage_uri: https://github.com/guard/listen
|
|
106
|
-
source_code_uri: https://github.com/guard/listen/tree/v3.
|
|
107
|
-
wiki_uri: https://github.com/guard/listen/wiki
|
|
108
|
+
source_code_uri: https://github.com/guard/listen/tree/v3.5.1
|
|
108
109
|
post_install_message:
|
|
109
110
|
rdoc_options: []
|
|
110
111
|
require_paths:
|
|
@@ -113,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
113
114
|
requirements:
|
|
114
115
|
- - ">="
|
|
115
116
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: 2.
|
|
117
|
+
version: 2.4.0
|
|
117
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
119
|
requirements:
|
|
119
120
|
- - ">="
|