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 +4 -4
- data/README.md +2 -0
- data/lib/listen/adapter.rb +1 -1
- data/lib/listen/adapter/base.rb +1 -1
- data/lib/listen/adapter/darwin.rb +6 -3
- data/lib/listen/adapter/tcp.rb +3 -2
- data/lib/listen/change.rb +1 -1
- data/lib/listen/directory.rb +13 -6
- data/lib/listen/listener.rb +14 -8
- data/lib/listen/record.rb +2 -2
- data/lib/listen/tcp/broadcaster.rb +2 -1
- data/lib/listen/version.rb +1 -1
- data/spec/lib/listen/listener_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50a3ac06e4268a2cd6b85ceae0dbf31f8683ab6f
|
4
|
+
data.tar.gz: 640a42142e94ab28e6d7414bedd864d5e7bf4d71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/listen/adapter.rb
CHANGED
data/lib/listen/adapter/base.rb
CHANGED
@@ -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
|
-
|
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
|
-
@
|
24
|
+
@workers.pop.run while !@workers.empty?
|
22
25
|
end
|
23
26
|
|
24
27
|
def _process_event(dir, event)
|
data/lib/listen/adapter/tcp.rb
CHANGED
@@ -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
|
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
|
34
|
+
retry if attempts > 0
|
34
35
|
_log :error, "TCP.start: #{$!.inspect}:#{$@.join("\n")}"
|
35
36
|
raise
|
36
37
|
rescue
|
data/lib/listen/change.rb
CHANGED
data/lib/listen/directory.rb
CHANGED
@@ -14,11 +14,15 @@ module Listen
|
|
14
14
|
current = Set.new(path.children)
|
15
15
|
|
16
16
|
if options[:silence]
|
17
|
-
_log
|
18
|
-
"
|
17
|
+
_log(:debug) do
|
18
|
+
"Recording: #{rel_path}: #{options.inspect}"\
|
19
|
+
" [#{previous.inspect}] -> (#{current.inspect})"
|
20
|
+
end
|
19
21
|
else
|
20
|
-
_log
|
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
|
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,
|
72
|
-
Celluloid.logger
|
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
|
data/lib/listen/listener.rb
CHANGED
@@ -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
|
38
|
-
|
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.
|
257
|
+
Celluloid::Logger.send(type, message)
|
252
258
|
end
|
253
259
|
|
254
260
|
def _adapter_class
|
data/lib/listen/record.rb
CHANGED
@@ -65,9 +65,9 @@ module Listen
|
|
65
65
|
_fast_build(directory.to_s)
|
66
66
|
end
|
67
67
|
|
68
|
-
Celluloid.
|
68
|
+
Celluloid::Logger.info "Record.build(): #{Time.now.to_f - start} seconds"
|
69
69
|
rescue
|
70
|
-
Celluloid.
|
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.
|
64
|
+
Celluloid::Logger.send(type, message)
|
64
65
|
end
|
65
66
|
|
66
67
|
def _unicast(socket, payload)
|
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: 2.7.
|
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-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|