listen 3.3.0.pre.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +105 -61
- data/bin/listen +3 -4
- data/lib/listen/adapter.rb +3 -3
- data/lib/listen/adapter/base.rb +4 -4
- data/lib/listen/adapter/bsd.rb +3 -4
- data/lib/listen/adapter/config.rb +1 -4
- data/lib/listen/adapter/darwin.rb +2 -2
- data/lib/listen/adapter/linux.rb +5 -2
- data/lib/listen/adapter/polling.rb +1 -1
- data/lib/listen/adapter/windows.rb +10 -14
- data/lib/listen/change.rb +10 -19
- data/lib/listen/cli.rb +3 -4
- data/lib/listen/directory.rb +5 -7
- data/lib/listen/event/config.rb +4 -5
- data/lib/listen/event/loop.rb +1 -4
- data/lib/listen/event/processor.rb +14 -10
- data/lib/listen/event/queue.rb +9 -9
- data/lib/listen/file.rb +6 -0
- data/lib/listen/fsm.rb +2 -2
- data/lib/listen/listener.rb +2 -0
- data/lib/listen/listener/config.rb +2 -4
- data/lib/listen/logger.rb +13 -12
- data/lib/listen/options.rb +9 -8
- data/lib/listen/queue_optimizer.rb +7 -12
- data/lib/listen/record.rb +28 -31
- data/lib/listen/record/entry.rb +1 -1
- data/lib/listen/record/symlink_detector.rb +4 -4
- data/lib/listen/silencer.rb +10 -8
- data/lib/listen/thread.rb +22 -15
- data/lib/listen/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8a5f611b09b7689da35117369be07e2cb74ed77575dc7d894c12629767ad82
|
4
|
+
data.tar.gz: c7995d9785eb3202fa13528489a0c48e54c70fc201c750cb885777d36151b316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb0d331747afe760ab96a3eecf20d041e1e9fec0a2c49b678289fe56250c2a357a4826c9d4c9da38c9db7f819e7d61f6b9f5245c23a34c4eb9f77868abde2ec0
|
7
|
+
data.tar.gz: 3c7d8b1f91224ea4a10b4f039e334fbb85c0eae14996bf2df9c32a9487325f94a5e1d1ce87abefa23dce2f50b0bac2069950d05ec1f561552fb9c8493c31fd83
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Listen
|
2
2
|
|
3
|
-
The
|
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.
|
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
6
|
|
7
7
|
[![Development Status](https://github.com/guard/listen/workflows/Development/badge.svg)](https://github.com/guard/listen/actions?workflow=Development)
|
8
8
|
[![Gem Version](https://badge.fury.io/rb/listen.svg)](http://badge.fury.io/rb/listen)
|
@@ -16,7 +16,7 @@ The Listen gem listens to file modifications and notifies you about the changes.
|
|
16
16
|
* You can watch multiple directories.
|
17
17
|
* Regexp-patterns for ignoring paths for more accuracy and speed
|
18
18
|
* Increased change detection accuracy on OS X HFS and VFAT volumes.
|
19
|
-
*
|
19
|
+
* Continuous Integration: tested on selected Ruby environments via [Github Workflows](https:///github.com/guard/listen/master/.github/workflows).
|
20
20
|
|
21
21
|
## Issues / limitations
|
22
22
|
|
@@ -25,37 +25,81 @@ The Listen gem listens to file modifications and notifies you about the changes.
|
|
25
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)).
|
26
26
|
* No directory/adapter-specific configuration options.
|
27
27
|
* Support for plugins planned for future.
|
28
|
-
* TCP functionality was removed in
|
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'`.
|
29
29
|
* Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.).
|
30
30
|
* Specs suite on JRuby and Rubinius aren't reliable on Travis CI, but should work.
|
31
31
|
* Windows and \*BSD adapter aren't continuously and automatically tested.
|
32
32
|
* OSX adapter has some performance limitations ([#342](https://github.com/guard/listen/issues/342)).
|
33
|
-
*
|
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
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
|
40
|
+
The simplest way to install `listen` is to use [Bundler](http://bundler.io).
|
41
41
|
|
42
42
|
```ruby
|
43
|
-
gem 'listen', '~> 3.
|
43
|
+
gem 'listen', '~> 3.3' # NOTE: for TCP functionality, use '~> 2.10' for now
|
44
|
+
```
|
45
|
+
|
46
|
+
## Complete Example
|
47
|
+
Here is a complete example of using the `listen` gem:
|
48
|
+
```ruby
|
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
|
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
|
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,
|
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)
|
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
|
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
|
188
|
+
|
189
|
+
`Listen` logs its activity to `Listen.logger`.
|
190
|
+
This is the primary method of debugging.
|
191
|
+
|
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
|
+
```
|
172
197
|
|
173
|
-
|
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`.
|
174
200
|
|
175
|
-
|
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.
|
176
212
|
|
213
|
+
Note: The alternate values `1`, `2`, `true` and `yes` shown above are deprecated and will be removed from `listen` v4.0.
|
177
214
|
|
178
|
-
|
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
|
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
|
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
|
264
|
+
### Issues and Troubleshooting
|
265
|
+
|
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).
|
223
267
|
|
224
|
-
*NOTE: without providing the output after setting the `LISTEN_GEM_DEBUGGING=
|
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
|
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
|
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
|
239
|
-
* not getting silent crashes within
|
240
|
-
* not running multiple instances of
|
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=
|
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
|
|
data/bin/listen
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'listen'
|
4
5
|
require 'listen/cli'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
Signal.trap('INT') { Thread.new { Listen.stop } }
|
9
|
-
end
|
7
|
+
if !defined?(JRUBY_VERSION) && Signal.list.keys.include?('INT')
|
8
|
+
Signal.trap('INT') { Thread.new { Listen.stop } }
|
10
9
|
end
|
11
10
|
|
12
11
|
Listen::CLI.start
|
data/lib/listen/adapter.rb
CHANGED
@@ -11,7 +11,7 @@ module Listen
|
|
11
11
|
module Adapter
|
12
12
|
OPTIMIZED_ADAPTERS = [Darwin, Linux, BSD, Windows].freeze
|
13
13
|
POLLING_FALLBACK_MESSAGE = 'Listen will be polling for changes.'\
|
14
|
-
'Learn more at https://github.com/guard/listen#listen-adapters.'
|
14
|
+
'Learn more at https://github.com/guard/listen#listen-adapters.'
|
15
15
|
|
16
16
|
class << self
|
17
17
|
def select(options = {})
|
@@ -24,14 +24,14 @@ module Listen
|
|
24
24
|
Polling
|
25
25
|
rescue
|
26
26
|
Listen.logger.warn format('Adapter: failed: %s:%s', $ERROR_POSITION.inspect,
|
27
|
-
|
27
|
+
$ERROR_POSITION * "\n")
|
28
28
|
raise
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def _usable_adapter_class
|
34
|
-
OPTIMIZED_ADAPTERS.
|
34
|
+
OPTIMIZED_ADAPTERS.find(&:usable?)
|
35
35
|
end
|
36
36
|
|
37
37
|
def _warn_polling_fallback(options)
|
data/lib/listen/adapter/base.rb
CHANGED
@@ -8,13 +8,11 @@ require 'listen/thread'
|
|
8
8
|
module Listen
|
9
9
|
module Adapter
|
10
10
|
class Base
|
11
|
-
attr_reader :options
|
11
|
+
attr_reader :options, :config
|
12
12
|
|
13
13
|
# TODO: only used by tests
|
14
14
|
DEFAULTS = {}.freeze
|
15
15
|
|
16
|
-
attr_reader :config
|
17
|
-
|
18
16
|
def initialize(config)
|
19
17
|
@started = false
|
20
18
|
@config = config
|
@@ -31,6 +29,7 @@ module Listen
|
|
31
29
|
end
|
32
30
|
|
33
31
|
# TODO: it's a separate method as a temporary workaround for tests
|
32
|
+
# rubocop:disable Metrics/MethodLength
|
34
33
|
def configure
|
35
34
|
if @configured
|
36
35
|
Listen.logger.warn('Adapter already configured!')
|
@@ -57,6 +56,7 @@ module Listen
|
|
57
56
|
@snapshots[dir] = snapshot
|
58
57
|
end
|
59
58
|
end
|
59
|
+
# rubocop:enable Metrics/MethodLength
|
60
60
|
|
61
61
|
def started?
|
62
62
|
@started
|
@@ -73,7 +73,7 @@ module Listen
|
|
73
73
|
@started = true
|
74
74
|
|
75
75
|
@run_thread = Listen::Thread.new("run_thread") do
|
76
|
-
@snapshots.
|
76
|
+
@snapshots.each_value do |snapshot|
|
77
77
|
_timed('Record.build()') { snapshot.record.build }
|
78
78
|
end
|
79
79
|
_run
|
data/lib/listen/adapter/bsd.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
module Listen
|
8
8
|
module Adapter
|
9
9
|
class BSD < Base
|
10
|
-
OS_REGEXP = /bsd|dragonfly/i
|
10
|
+
OS_REGEXP = /bsd|dragonfly/i.freeze
|
11
11
|
|
12
12
|
DEFAULTS = {
|
13
13
|
events: [
|
@@ -73,8 +73,7 @@ module Listen
|
|
73
73
|
def _change(event_flags)
|
74
74
|
{ modified: [:attrib, :extend],
|
75
75
|
added: [:write],
|
76
|
-
removed: [:rename, :delete]
|
77
|
-
}.each do |change, flags|
|
76
|
+
removed: [:rename, :delete] }.each do |change, flags|
|
78
77
|
return change unless (flags & event_flags).empty?
|
79
78
|
end
|
80
79
|
nil
|
@@ -87,7 +86,7 @@ module Listen
|
|
87
86
|
def _watch_for_new_file(event)
|
88
87
|
queue = event.watcher.queue
|
89
88
|
_find(_event_path(event).to_s) do |file_path|
|
90
|
-
unless queue.watchers.
|
89
|
+
unless queue.watchers.find { |_, v| v.path == file_path.to_s }
|
91
90
|
_watch_file(file_path, queue)
|
92
91
|
end
|
93
92
|
end
|
@@ -5,10 +5,7 @@ require 'pathname'
|
|
5
5
|
module Listen
|
6
6
|
module Adapter
|
7
7
|
class Config
|
8
|
-
attr_reader :directories
|
9
|
-
attr_reader :silencer
|
10
|
-
attr_reader :queue
|
11
|
-
attr_reader :adapter_options
|
8
|
+
attr_reader :directories, :silencer, :queue, :adapter_options
|
12
9
|
|
13
10
|
def initialize(directories, queue, silencer, adapter_options)
|
14
11
|
# Default to current directory if no directories are supplied
|
@@ -7,7 +7,7 @@ module Listen
|
|
7
7
|
# Adapter implementation for Mac OS X `FSEvents`.
|
8
8
|
#
|
9
9
|
class Darwin < Base
|
10
|
-
OS_REGEXP = /darwin(?<major_version>(1|2)\d+)/i
|
10
|
+
OS_REGEXP = /darwin(?<major_version>(1|2)\d+)/i.freeze
|
11
11
|
|
12
12
|
# The default delay between checking for changes.
|
13
13
|
DEFAULTS = { latency: 0.1 }.freeze
|
@@ -51,7 +51,7 @@ module Listen
|
|
51
51
|
|
52
52
|
def _process_changes(dirs)
|
53
53
|
dirs.each do |dir|
|
54
|
-
dir = Pathname.new(dir.sub(%r{
|
54
|
+
dir = Pathname.new(dir.sub(%r{/$}, ''))
|
55
55
|
|
56
56
|
@callbacks.each do |watched_dir, callback|
|
57
57
|
if watched_dir.eql?(dir) || Listen::Directory.ascendant_of?(watched_dir, dir)
|
data/lib/listen/adapter/linux.rb
CHANGED
@@ -4,13 +4,14 @@ module Listen
|
|
4
4
|
module Adapter
|
5
5
|
# @see https://github.com/nex3/rb-inotify
|
6
6
|
class Linux < Base
|
7
|
-
OS_REGEXP = /linux/i
|
7
|
+
OS_REGEXP = /linux/i.freeze
|
8
8
|
|
9
9
|
DEFAULTS = {
|
10
10
|
events: [
|
11
11
|
:recursive,
|
12
12
|
:attrib,
|
13
13
|
:create,
|
14
|
+
:modify,
|
14
15
|
:delete,
|
15
16
|
:move,
|
16
17
|
:close_write
|
@@ -21,7 +22,7 @@ module Listen
|
|
21
22
|
private
|
22
23
|
|
23
24
|
WIKI_URL = 'https://github.com/guard/listen'\
|
24
|
-
'/wiki/Increasing-the-amount-of-inotify-watchers'
|
25
|
+
'/wiki/Increasing-the-amount-of-inotify-watchers'
|
25
26
|
|
26
27
|
INOTIFY_LIMIT_MESSAGE = <<-EOS.gsub(/^\s*/, '')
|
27
28
|
FATAL: Listen error: unable to monitor directories for changes.
|
@@ -40,6 +41,7 @@ module Listen
|
|
40
41
|
@worker.run
|
41
42
|
end
|
42
43
|
|
44
|
+
# rubocop:disable Metrics/MethodLength
|
43
45
|
def _process_event(dir, event)
|
44
46
|
# NOTE: avoid using event.absolute_name since new API
|
45
47
|
# will need to have a custom recursion implemented
|
@@ -72,6 +74,7 @@ module Listen
|
|
72
74
|
|
73
75
|
_queue_change(:file, dir, rel_path, params)
|
74
76
|
end
|
77
|
+
# rubocop:enable Metrics/MethodLength
|
75
78
|
|
76
79
|
def _skip_event?(event)
|
77
80
|
# Event on root directory
|