listen 3.0.3 → 3.0.4

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
2
  SHA1:
3
- metadata.gz: 00459a29639db27606681aa701f668d53134b3f8
4
- data.tar.gz: a181ae4cf18614fd7622c668c1959eb51403674d
3
+ metadata.gz: 0c7fe2432921c30a0fc8bd2552a7bd2bac7b62b1
4
+ data.tar.gz: b0fab87bbb62064ab57b6ddf9c8c9e08a9fa4d6a
5
5
  SHA512:
6
- metadata.gz: 9a6946eb30532c847e6b6a059f99b50c7d1c7a51c77471fb65f864486d83a094e5a16ff725091ddd988cedbdf598fc333db7537ff2c36d4b4446178fc620dca3
7
- data.tar.gz: b2a0b44994e84253bffe43872c309bef6e83edb65837ddc1d98d166c017f346f5ad835e00c042d39abddf7dedf5b7b954e090137fd7e6d0179cdac542cca3d14
6
+ metadata.gz: fcf5fda1fd7cd0a63652d481cf2570f724cad065fa3ff63d7fc81cf02f74f6fb3856c97625fbcbe5a067d8b4a30e15ca03d2a60f48556b7400af7e5e535e866d
7
+ data.tar.gz: 6bd097ccf35884c62428ee1271c4b695ba90236adde490d39d44cbf18f883026599abdd30b11059c155d468b4b04e51401cf974998d70741360119d2f6ab2605
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ### :warning: Listen is [looking for new maintainers](https://groups.google.com/forum/#!topic/guard-dev/2Td0QTvTIsE). Please [contact me](mailto:thibaud@thibaud.gg) if you're interested.
1
+ :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.
2
2
 
3
3
  # Listen
4
4
 
@@ -6,19 +6,6 @@
6
6
 
7
7
  The Listen gem listens to file modifications and notifies you about the changes.
8
8
 
9
- ## Known issues / Quickfixes / Workarounds
10
-
11
- *NOTE: TCP functionality has been removed from Listen 3.x - please use Listen
12
- 2.x until alternative server and client gems are created/released for 3.x.*
13
-
14
- *NOTE: Ruby 1.9.3 is no longer maintained (and may not work with Listen) - it's best to upgrade to Ruby 2.2.2*
15
-
16
- For other issues, just head over here: https://github.com/guard/listen/wiki/Quickfixes,-known-issues-and-workarounds
17
-
18
- ## Tips and Techniques
19
-
20
- Make sure you know these few basic tricks: https://github.com/guard/listen/wiki/Tips-and-Techniques
21
-
22
9
  ## Features
23
10
 
24
11
  * OS-optimized adapters on MRI for Mac OS X 10.6+, Linux, \*BSD and Windows, [more info](#listen-adapters) below.
@@ -28,21 +15,21 @@ Make sure you know these few basic tricks: https://github.com/guard/listen/wiki/
28
15
  * Increased change detection accuracy on OS X HFS and VFAT volumes.
29
16
  * Tested on MRI Ruby environments (2.0+ only) via [Travis CI](https://travis-ci.org/guard/listen),
30
17
 
31
- NOTE: TCP functionality has been moved to a separate gem (listen-server and listen-client)
32
-
33
- NOTES:
34
- - Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.)
35
- - Specs suite on JRuby and Rubinius aren't reliable on Travis CI, but should work.
36
- - Windows and \*BSD adapter aren't continuously and automaticaly tested.
37
-
18
+ ## Issues / limitations
38
19
 
39
- ## Pending features / issues
20
+ * Limited support for symlinked directories ([#279](https://github.com/guard/listen/issues/279)):
21
+ * Symlinks are always followed ([#25](https://github.com/guard/listen/issues/25)).
22
+ * 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)).
23
+ * No directory/adapter-specific configuration options.
24
+ * Support for plugins planned for future.
25
+ * 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'`.
26
+ * Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.).
27
+ * Specs suite on JRuby and Rubinius aren't reliable on Travis CI, but should work.
28
+ * Windows and \*BSD adapter aren't continuously and automatically tested.
29
+ * OSX adapter has some performance limitations ([#342](https://github.com/guard/listen/issues/342)).
30
+ * Ruby 1.9.3 is no longer maintained (and may not work with Listen) - it's best to upgrade to Ruby 2.2.2.
40
31
 
41
- * symlinked directories aren't fully transparent yet: https://github.com/guard/listen/issues/279
42
- * Directory/adapter specific configuration options
43
- * Support for plugins
44
-
45
- Pull request or help is very welcome for these.
32
+ Pull requests or help is very welcome for these.
46
33
 
47
34
  ## Install
48
35
 
@@ -52,7 +39,6 @@ The simplest way to install Listen is to use [Bundler](http://bundler.io).
52
39
  gem 'listen', '~> 3.0' # NOTE: for TCP functionality, use '~> 2.10' for now
53
40
  ```
54
41
 
55
-
56
42
  ## Usage
57
43
 
58
44
  Call `Listen.to` with either a single directory or multiple directories, then define the "changes" callback in a block.
@@ -72,7 +58,7 @@ sleep
72
58
  Listeners can also be easily paused/unpaused:
73
59
 
74
60
  ``` ruby
75
- listener = Listen.to('dir/path/to/listen') { |modified, added, removed| # ... }
61
+ listener = Listen.to('dir/path/to/listen') { |modified, added, removed| puts 'handle changes here...' }
76
62
 
77
63
  listener.start
78
64
  listener.paused? # => false
@@ -102,13 +88,13 @@ listener.ignore /\.rb/ # ignore rb extension in addition of pkg.
102
88
  sleep
103
89
  ```
104
90
 
105
- Note: Ignoring regexp patterns are evaluated against relative paths.
91
+ Note: `:ignore` regexp patterns are evaluated against relative paths.
106
92
 
107
- Note: ignoring paths does not improve performance - except when Polling
93
+ Note: Ignoring paths does not improve performance, except when Polling ([#274](https://github.com/guard/listen/issues/274))
108
94
 
109
95
  ### Only
110
96
 
111
- Listen catches all files (less the ignored once) by default, if you want to only listen to a specific type of file (ie: just rb extension) you should use the `only` option/method.
97
+ 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.
112
98
 
113
99
  ``` ruby
114
100
  listener = Listen.to('dir/path/to/listen', only: /\.rb$/) { |modified, added, removed| # ... }
@@ -117,7 +103,7 @@ listener.only /_spec\.rb$/ # overwrite all existing only patterns.
117
103
  sleep
118
104
  ```
119
105
 
120
- Note: ':only' regexp patterns are evaluated only against relative **file** paths.
106
+ Note: `:only` regexp patterns are evaluated only against relative **file** paths.
121
107
 
122
108
 
123
109
  ## Changes callback
@@ -174,14 +160,15 @@ force_polling: true # Force the use of the polling a
174
160
  relative: false # Whether changes should be relative to current dir or not
175
161
  # default: false
176
162
 
177
- debug: true # Enable Listen logger
178
- # default: false
179
-
180
163
  polling_fallback_message: 'custom message' # Set a custom polling fallback message (or disable it with false)
181
164
  # default: "Listen will be polling for changes. Learn more at https://github.com/guard/listen#listen-adapters."
182
165
  ```
183
166
 
184
- Also, setting the environment variable `LISTEN_GEM_DEBUGGING=1` does the same as `debug: true` above.
167
+ ## Debugging
168
+
169
+ 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.
170
+
171
+ You can also set `Listen.logger` to a custom logger.
185
172
 
186
173
 
187
174
  ## Listen adapters
@@ -202,7 +189,7 @@ while initializing the listener.
202
189
 
203
190
  ### On Windows
204
191
 
205
- If your are on Windows, it's recommended to use the [`wdm`](https://github.com/Maher4Ever/wdm) adapter instead of polling.
192
+ If you are on Windows, it's recommended to use the [`wdm`](https://github.com/Maher4Ever/wdm) adapter instead of polling.
206
193
 
207
194
  Please add the following to your Gemfile:
208
195
 
@@ -212,7 +199,7 @@ gem 'wdm', '>= 0.1.0' if Gem.win_platform?
212
199
 
213
200
  ### On \*BSD
214
201
 
215
- If your are on \*BSD you can try to use the [`rb-kqueue`](https://github.com/mat813/rb-kqueue) adapter instead of polling.
202
+ If you are on \*BSD you can try to use the [`rb-kqueue`](https://github.com/mat813/rb-kqueue) adapter instead of polling.
216
203
 
217
204
  Please add the following to your Gemfile:
218
205
 
@@ -234,7 +221,6 @@ Please visit the [installation section of the Listen WIKI](https://github.com/gu
234
221
 
235
222
  See [TROUBLESHOOTING](https://github.com/guard/listen/wiki/Troubleshooting)
236
223
 
237
-
238
224
  ## Performance
239
225
 
240
226
  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).
@@ -255,6 +241,8 @@ Also, if the directories you're watching contain many files, make sure you're:
255
241
 
256
242
  When in doubt, LISTEN_GEM_DEBUGGING=2 can help discover the actual events and time they happened.
257
243
 
244
+ See also [Tips and Techniques](https://github.com/guard/listen/wiki/Tips-and-Techniques).
245
+
258
246
  ## Development
259
247
 
260
248
  * Documentation hosted at [RubyDoc](http://rubydoc.info/github/guard/listen/master/frames).
@@ -9,6 +9,9 @@ module Listen
9
9
  attr_reader :adapter_options
10
10
 
11
11
  def initialize(directories, queue, silencer, adapter_options)
12
+ # Default to current directory if no directories are supplied
13
+ directories = [Dir.pwd] if directories.to_a.empty?
14
+
12
15
  # TODO: fix (flatten, array, compact?)
13
16
  @directories = directories.map do |directory|
14
17
  Pathname.new(directory.to_s).realpath
@@ -16,32 +16,27 @@ module Listen
16
16
  # NOTE: each directory gets a DIFFERENT callback!
17
17
  def _configure(dir, &callback)
18
18
  require 'rb-fsevent'
19
+
19
20
  opts = { latency: options.latency }
20
21
 
21
22
  @workers ||= ::Queue.new
22
23
  @workers << FSEvent.new.tap do |worker|
24
+ _log :debug, "fsevent: watching: #{dir.to_s.inspect}"
23
25
  worker.watch(dir.to_s, opts, &callback)
24
26
  end
25
27
  end
26
28
 
27
- # NOTE: _run is called within a thread, so run every other
28
- # worker in it's own thread
29
29
  def _run
30
30
  first = @workers.pop
31
- until @workers.empty?
32
- next_worker = @workers.pop
33
- Listen::Internals::ThreadPool.add do
34
- begin
35
- next_worker.run
36
- rescue
37
- _log_exception 'run() in extra thread(s) failed: %s: %s'
38
- end
39
- end
40
- end
41
- first.run
31
+
32
+ # NOTE: _run is called within a thread, so run every other
33
+ # worker in it's own thread
34
+ _run_workers_in_background(_to_array(@workers))
35
+ _run_worker(first)
42
36
  end
43
37
 
44
38
  def _process_event(dir, event)
39
+ _log :debug, "fsevent: processing event: #{event.inspect}"
45
40
  event.each do |path|
46
41
  new_path = Pathname.new(path.sub(/\/$/, ''))
47
42
  _log :debug, "fsevent: #{new_path}"
@@ -50,6 +45,27 @@ module Listen
50
45
  _queue_change(:dir, dir, rel_path, recursive: true)
51
46
  end
52
47
  end
48
+
49
+ def _run_worker(worker)
50
+ _log :debug, "fsevent: running worker: #{worker.inspect}"
51
+ worker.run
52
+ rescue
53
+ _log_exception 'fsevent: running worker failed: %s: %s'
54
+ end
55
+
56
+ def _run_workers_in_background(workers)
57
+ workers.each do |worker|
58
+ # NOTE: while passing local variables to the block below is not
59
+ # thread safe, using 'worker' from the enumerator above is ok
60
+ Listen::Internals::ThreadPool.add { _run_worker(worker) }
61
+ end
62
+ end
63
+
64
+ def _to_array(queue)
65
+ workers = []
66
+ workers << queue.pop until queue.empty?
67
+ workers
68
+ end
53
69
  end
54
70
  end
55
71
  end
@@ -27,7 +27,7 @@ module Listen
27
27
  EOS
28
28
 
29
29
  def _configure(directory, &callback)
30
- Kernel.require 'rb-inotify'
30
+ require 'rb-inotify'
31
31
  @worker ||= ::INotify::Notifier.new
32
32
  @worker.watch(directory.to_s, *options.events, &callback)
33
33
  rescue Errno::ENOSPC
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '3.0.3'
2
+ VERSION = '3.0.4'
3
3
  end
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.0.3
4
+ version: 3.0.4
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: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb-fsevent