listen 2.7.9 → 2.7.11

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: b3cee3bca315051931b8206499fded313985faf4
4
- data.tar.gz: e2893da22d2bce0400f381d86d4b62f93220219c
3
+ metadata.gz: 50a3ac06e4268a2cd6b85ceae0dbf31f8683ab6f
4
+ data.tar.gz: 640a42142e94ab28e6d7414bedd864d5e7bf4d71
5
5
  SHA512:
6
- metadata.gz: 9574e5f1138f0a6fd05cb0a203564ff96f500892c0b4b8a5a4b8bf6f53163e6d7f16882f09a93047f8c65155018dad8ec1d0989203c9bc15728b7e3d2346b7f9
7
- data.tar.gz: 487371b7585da0c36c658b9aa0bc96243f0d7010bfcc881cbe28bdd0374ab796dc1149c1180c3ef923b430720a37bd9da8aa998d6aba46d283525d696b027014
6
+ metadata.gz: 2dc86cec1578b84961649ad4a1f685fc33bbc243397884c46cb3e047f3221e7b5f529c5940d5bf4be950f280dd0927899c7b4ba91e9844f8a77a736614905358
7
+ data.tar.gz: 1467477d54aa38100d861d73e3f1714906c2e7cddc9ae0917468934ab5a69ba13c0eeeabda7af3c89dcb5032938128406bcbbe50489ca5deb2b8de848058425f
data/README.md CHANGED
@@ -1,3 +1,5 @@
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.
2
+
1
3
  # Listen
2
4
 
3
5
  [![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)
@@ -38,7 +38,7 @@ module Listen
38
38
  end
39
39
 
40
40
  def self._log(type, message)
41
- Celluloid.logger.send(type, message)
41
+ Celluloid::Logger.send(type, message)
42
42
  end
43
43
  end
44
44
  end
@@ -84,7 +84,7 @@ module Listen
84
84
  end
85
85
 
86
86
  def self._log(*args)
87
- Celluloid.logger.send(*args)
87
+ Celluloid::Logger.send(*args)
88
88
  end
89
89
  end
90
90
  end
@@ -12,13 +12,16 @@ module Listen
12
12
 
13
13
  def _configure(dir, &callback)
14
14
  require 'rb-fsevent'
15
- @worker ||= FSEvent.new
16
15
  opts = { latency: options.latency }
17
- @worker.watch(dir.to_s, opts, &callback)
16
+
17
+ @workers ||= Queue.new
18
+ @workers << FSEvent.new.tap do |worker|
19
+ worker.watch(dir.to_s, opts, &callback)
20
+ end
18
21
  end
19
22
 
20
23
  def _run
21
- @worker.run
24
+ @workers.pop.run while !@workers.empty?
22
25
  end
23
26
 
24
27
  def _process_event(dir, event)
@@ -20,7 +20,8 @@ module Listen
20
20
 
21
21
  # Initializes and starts a Celluloid::IO-powered TCP-recipient
22
22
  def start
23
- attempts = 3
23
+ attempts ||= 3
24
+ _log :info, "TCP: opening socket #{options.host}:#{options.port}"
24
25
  @socket = TCPSocket.new(options.host, options.port)
25
26
  @buffer = ''
26
27
  async.run
@@ -30,7 +31,7 @@ module Listen
30
31
  sleep 1
31
32
  attempts -= 1
32
33
  _log :warn, "TCP.start: #{$!.inspect}"
33
- retry if retries > 0
34
+ retry if attempts > 0
34
35
  _log :error, "TCP.start: #{$!.inspect}:#{$@.join("\n")}"
35
36
  raise
36
37
  rescue
@@ -52,7 +52,7 @@ module Listen
52
52
  private
53
53
 
54
54
  def _log(type, message)
55
- Celluloid.logger.send(type, message)
55
+ Celluloid::Logger.send(type, message)
56
56
  end
57
57
  end
58
58
  end
@@ -14,11 +14,15 @@ module Listen
14
14
  current = Set.new(path.children)
15
15
 
16
16
  if options[:silence]
17
- _log :debug, "Recording: #{rel_path}: #{options.inspect}"\
18
- " [#{previous.inspect}] -> (#{current.inspect})"
17
+ _log(:debug) do
18
+ "Recording: #{rel_path}: #{options.inspect}"\
19
+ " [#{previous.inspect}] -> (#{current.inspect})"
20
+ end
19
21
  else
20
- _log :debug, "Scanning: #{rel_path}: #{options.inspect}"\
22
+ _log(:debug) do
23
+ "Scanning: #{rel_path}: #{options.inspect}"\
21
24
  " [#{previous.inspect}] -> (#{current.inspect})"
25
+ end
22
26
  end
23
27
 
24
28
  current.each do |full_path|
@@ -42,7 +46,7 @@ module Listen
42
46
  _async_changes(dir, path, queue, previous, options)
43
47
  _change(queue, :file, dir, rel_path, options)
44
48
  rescue
45
- _log :warn, "scanning DIED: #{$!}:#{$@.join("\n")}"
49
+ _log(:warn) { "scanning DIED: #{$!}:#{$@.join("\n")}" }
46
50
  raise
47
51
  end
48
52
 
@@ -68,8 +72,11 @@ module Listen
68
72
  end
69
73
  end
70
74
 
71
- def self._log(type, message)
72
- Celluloid.logger.send(type, message)
75
+ def self._log(type, &block)
76
+ return unless Celluloid.logger
77
+ Celluloid.logger.send(type) do
78
+ block.call
79
+ end
73
80
  end
74
81
  end
75
82
  end
@@ -18,6 +18,9 @@ module Listen
18
18
  # TODO: deprecate
19
19
  attr_reader :options, :directories
20
20
  attr_reader :registry, :supervisor
21
+
22
+ # TODO: deprecate
23
+ # NOTE: these are VERY confusing (broadcast + recipient modes)
21
24
  attr_reader :host, :port
22
25
 
23
26
  # Initializes the directories listener.
@@ -34,8 +37,10 @@ module Listen
34
37
  @options = _init_options(args.last.is_a?(Hash) ? args.pop : {})
35
38
 
36
39
  # Setup logging first
37
- Celluloid.logger.level = _debug_level
38
- _log :info, "Celluloid loglevel set to: #{Celluloid.logger.level}"
40
+ if Celluloid.logger
41
+ Celluloid.logger.level = _debug_level
42
+ _log :info, "Celluloid loglevel set to: #{Celluloid.logger.level}"
43
+ end
39
44
 
40
45
  @silencer = Silencer.new
41
46
  _reconfigure_silencer({})
@@ -176,10 +181,6 @@ module Listen
176
181
  end
177
182
 
178
183
  def _debug_level
179
- # TODO: remove? (since there are BSD warnings anyway)
180
- bsd = RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/
181
- return Logger::DEBUG if bsd
182
-
183
184
  debugging = ENV['LISTEN_GEM_DEBUGGING'] || options[:debug]
184
185
  case debugging.to_s
185
186
  when /2/
@@ -192,10 +193,13 @@ module Listen
192
193
  end
193
194
 
194
195
  def _init_actors
196
+ options = [mq: self, directories: directories]
197
+
195
198
  @supervisor = Celluloid::SupervisionGroup.run!(registry)
196
199
  supervisor.add(Record, as: :record, args: self)
197
200
  supervisor.pool(Change, as: :change_pool, args: self)
198
201
 
202
+ # TODO: broadcaster should be a separate plugin
199
203
  if @tcp_mode == :broadcaster
200
204
  require 'listen/tcp/broadcaster'
201
205
  supervisor.add(TCP::Broadcaster, as: :broadcaster, args: [@host, @port])
@@ -204,9 +208,11 @@ module Listen
204
208
  # a new instance is spawned by supervisor, but it's 'start' isn't
205
209
  # called
206
210
  registry[:broadcaster].start
211
+ elsif @tcp_mode == :recipient
212
+ # TODO: adapter options should be configured in Listen.{on/to}
213
+ options.first.merge!(host: @host, port: @port)
207
214
  end
208
215
 
209
- options = [mq: self, directories: directories]
210
216
  supervisor.add(_adapter_class, as: :adapter, args: options)
211
217
  end
212
218
 
@@ -248,7 +254,7 @@ module Listen
248
254
  end
249
255
 
250
256
  def _log(type, message)
251
- Celluloid.logger.send(type, message)
257
+ Celluloid::Logger.send(type, message)
252
258
  end
253
259
 
254
260
  def _adapter_class
@@ -65,9 +65,9 @@ module Listen
65
65
  _fast_build(directory.to_s)
66
66
  end
67
67
 
68
- Celluloid.logger.info "Record.build took #{Time.now.to_f - start} seconds"
68
+ Celluloid::Logger.info "Record.build(): #{Time.now.to_f - start} seconds"
69
69
  rescue
70
- Celluloid.logger.warn "build crashed: #{$!.inspect}"
70
+ Celluloid::Logger.warn "build crashed: #{$!.inspect}"
71
71
  raise
72
72
  end
73
73
 
@@ -16,6 +16,7 @@ module Listen
16
16
  #
17
17
  def initialize(host, port)
18
18
  @sockets = []
19
+ _log :debug, "Broadcaster: starting tcp server: #{host}:#{port}"
19
20
  @server = TCPServer.new(host, port)
20
21
  rescue
21
22
  _log :error, "Broadcaster.initialize: #{$!.inspect}:#{$@.join("\n")}"
@@ -60,7 +61,7 @@ module Listen
60
61
  private
61
62
 
62
63
  def _log(type, message)
63
- Celluloid.logger.send(type, message)
64
+ Celluloid::Logger.send(type, message)
64
65
  end
65
66
 
66
67
  def _unicast(socket, payload)
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '2.7.9'
2
+ VERSION = '2.7.11'
3
3
  end
@@ -86,7 +86,7 @@ describe Listener do
86
86
  subject.start
87
87
  end
88
88
 
89
- it 'supervises adaper' do
89
+ it 'supervises adapter' do
90
90
  allow(Adapter).to receive(:select) { Adapter::Polling }
91
91
  options = [mq: subject, directories: []]
92
92
  expect(supervisor).to receive(:add).
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.9
4
+ version: 2.7.11
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-20 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid