listen 2.7.7 → 2.7.8

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: e6d5e368c0d42f2b677a88efcd2b983eb1551278
4
- data.tar.gz: 656135661cb4e2c2bd82c9acdbf9d0779a1c707a
3
+ metadata.gz: 75b73ca8c3df5774760e1a9e9cd4281a4fb91f7b
4
+ data.tar.gz: f09049b304ca5bf11a288ee36cc81ff7f0f4d624
5
5
  SHA512:
6
- metadata.gz: d3b07e9530ffa906cf9cc1413dba58b990dc5e720e7c42f4364ac84790e47c43d10bfa5aa5afcbe43e360e1f6c459a5f7ffb15f7dc20ef8467127c6d1c8c93de
7
- data.tar.gz: c6e078178e2879ec66de6c54a52542aa973d9de372edda0c8e74356d7fd1377330f569ef8ae73bf61b4f09962fe341d53dec6201bfdd4261275163fcdfb1a035
6
+ metadata.gz: beb3b0ff8fd1e133ea01b700a147f4aeac44bf670fdb3c16f4e66da5fc24545645a51899cbd241add9be9887091a5312dd196606b23229c3d574f9e4f9db390a
7
+ data.tar.gz: c5f4d09de7c8f336aee3f4c8c69e8707e174de4692c83beb7640213bae9254dcffaa07642ea212c632eb38c4ed5fd75ca2871af859589c06fff0e86179f8f516
data/README.md CHANGED
@@ -10,7 +10,7 @@ The Listen gem listens to file modifications and notifies you about the changes.
10
10
  * OS-specific adapters on MRI for Mac OS X 10.6+, Linux, ~~\*BSD~~ and Windows, [more info](#listen-adapters) below.
11
11
  * Detects file modification, addition and removal.
12
12
  * Allows supplying regexp-patterns to ignore paths for better results.
13
- * File content checksum comparison for modifications made under the same second (OS X only).
13
+ * File content checksum comparison for modifications made under the same second (OS X HFS volumes, VFAT volumes).
14
14
  * Forwarding file events over TCP, [more info](#forwarding-file-events-over-tcp) below.
15
15
  * Tested on MRI Ruby environments (1.9+ only) via [Travis CI](https://travis-ci.org/guard/listen),
16
16
 
@@ -22,8 +22,10 @@ Please note that:
22
22
 
23
23
  ## Pending features
24
24
 
25
- * Non-recursive directory scanning. [#111](https://github.com/guard/listen/issues/111)
25
+ * ~~Non-recursive directory scanning~~ [#111](https://github.com/guard/listen/issues/111)
26
26
  * Symlinks support. [#25](https://github.com/guard/listen/issues/25)
27
+ * Directory/adapter specific configuration options
28
+ * Support for plugins
27
29
 
28
30
  Pull request or help is very welcome for these.
29
31
 
@@ -55,14 +57,21 @@ Listeners can also be easily paused/unpaused:
55
57
 
56
58
  ``` ruby
57
59
  listener = Listen.to('dir/path/to/listen') { |modified, added, removed| # ... }
60
+
58
61
  listener.start
59
- listener.listen? # => true
60
- listener.pause # stop listening to changes
62
+ listener.paused? # => false
63
+ listener.processing? # => true
64
+
65
+ listener.pause # stops processing changes (but keeps on collecting them)
61
66
  listener.paused? # => true
62
- listener.unpause # start listening to changes again
63
- listener.stop # stop completely the listener
67
+ listener.processing? # => false
68
+
69
+ listener.unpause # resumes processing changes ("start" would do the same)
70
+ listener.stop # stop both listening to changes and processing them
64
71
  ```
65
72
 
73
+ Note: While paused, Listen keeps on collecting changes in the background - to clear them, call "stop"
74
+
66
75
  Note: You should keep track of all started listeners and stop them properly on finish.
67
76
 
68
77
  ### Ignore / ignore!
@@ -90,7 +99,8 @@ listener.only /_spec\.rb$/ # overwrite all existing only patterns.
90
99
  sleep
91
100
  ```
92
101
 
93
- Note: Only regexp patterns are evaluated only against relative **file** paths.
102
+ Note: ':only' regexp patterns are evaluated only against relative **file** paths.
103
+
94
104
 
95
105
  ## Changes callback
96
106
 
@@ -225,6 +235,22 @@ Listen traps SIGINT signal to properly finalize listeners. If you plan
225
235
  on trapping this signal yourself - make sure to call `Listen.stop` in
226
236
  signal handler.
227
237
 
238
+ ## Performance
239
+
240
+ 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).
241
+
242
+ Also, if the directories you're watching contain many files, make sure you're:
243
+
244
+ * not using Polling (ideally)
245
+ * using `:ignore` and `:only` options to avoid tracking directories you don't care about
246
+ * not using a version of Listen prior to 2.7.7
247
+ * not getting silent crashes within Listen (see LISTEN_GEM_DEBUGGING=2)
248
+ * not running multiple instances of Listen in the background
249
+ * using a file system with atime modification disabled (ideally)
250
+ * not using a filesystem with inaccurate file modification times (ideally), e.g. HFS, VFAT
251
+ * running Listen with the latency option not too small or too big (depends on needs)
252
+
253
+ When in doubt, LISTEN_GEM_DEBUGGING=2 can help discover the actual events and time they happened.
228
254
 
229
255
  ## Forwarding file events over TCP
230
256
 
@@ -3,8 +3,6 @@ require 'listen/listener'
3
3
 
4
4
  module Listen
5
5
  class << self
6
- attr_accessor :stopping
7
-
8
6
  # Listens to file system modifications on a either single directory or
9
7
  # multiple directories.
10
8
  #
@@ -21,13 +19,12 @@ module Listen
21
19
  # @return [Listen::Listener] the listener
22
20
  #
23
21
  def to(*args, &block)
24
- boot_celluloid
25
- @stopping = false
22
+ Celluloid.boot unless Celluloid.running?
26
23
  options = args.last.is_a?(Hash) ? args.last : {}
27
24
  if target = options.delete(:forward_to)
28
- Listener.new(target, :broadcaster, *args, &block)
25
+ _add_listener(target, :broadcaster, *args, &block)
29
26
  else
30
- Listener.new(*args, &block)
27
+ _add_listener(*args, &block)
31
28
  end
32
29
  end
33
30
 
@@ -36,7 +33,15 @@ module Listen
36
33
  # Use it for testing purpose or when you are sure that Celluloid could be
37
34
  # ended.
38
35
  #
36
+ # This is used by the `listen` binary to handle Ctrl-C
37
+ #
39
38
  def stop
39
+ @listeners ||= []
40
+ @listeners.each do |listener|
41
+ # call stop to halt the main loop
42
+ listener.stop
43
+ end
44
+
40
45
  Celluloid.shutdown
41
46
  end
42
47
 
@@ -52,13 +57,16 @@ module Listen
52
57
  # @return [Listen::Listener] the listener
53
58
  #
54
59
  def on(target, *args, &block)
55
- Listener.new(target, :recipient, *args, &block)
60
+ _add_listener(target, :recipient, *args, &block)
56
61
  end
57
62
 
58
63
  private
59
64
 
60
- def boot_celluloid
61
- Celluloid.boot unless Celluloid.running?
65
+ def _add_listener(*args, &block)
66
+ @listeners ||= []
67
+ Listener.new(*args, &block).tap do |listener|
68
+ @listeners << listener
69
+ end
62
70
  end
63
71
  end
64
72
  end
@@ -79,8 +79,12 @@ module Listen
79
79
  @mq.send(:_queue_raw_change, type, dir, rel_path, options)
80
80
  end
81
81
 
82
- def _log(type, message)
83
- Celluloid.logger.send(type, message)
82
+ def _log(*args)
83
+ self.class.send(:_log, *args)
84
+ end
85
+
86
+ def self._log(*args)
87
+ Celluloid.logger.send(*args)
84
88
  end
85
89
  end
86
90
  end
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '2.7.7'
2
+ VERSION = '2.7.8'
3
3
  end
@@ -14,12 +14,6 @@ describe Listen do
14
14
  described_class.to('/path', forward_to: 4000)
15
15
  end
16
16
  end
17
-
18
- it 'sets stopping at false' do
19
- allow(Listen::Listener).to receive(:new)
20
- Listen.to('/path')
21
- expect(Listen.stopping).to be_falsey
22
- end
23
17
  end
24
18
 
25
19
  describe '.stop' do
@@ -40,7 +40,6 @@ Thread.abort_on_exception = true
40
40
  Celluloid.logger.level = Logger::ERROR
41
41
 
42
42
  RSpec.configuration.before(:each) do
43
- Listen.stopping = false
44
43
  Celluloid.boot
45
44
  end
46
45
 
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: 2.7.7
4
+ version: 2.7.8
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: 2014-06-05 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid