listen 2.10.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/listen/adapter/base.rb +5 -4
- data/lib/listen/directory.rb +1 -1
- data/lib/listen/internals/thread_pool.rb +3 -1
- data/lib/listen/listener.rb +21 -7
- data/lib/listen/queue_optimizer.rb +1 -1
- data/lib/listen/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 617639ec10e92398c4bb2ac0ee386f9f51301b77
|
4
|
+
data.tar.gz: 56e366a55edf6c6f926f7d70a898ed86e02e0a76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc5839d65676759b511acbecbaef944fb8f23d4add9f5c210392b50cfab51f4ed8f4296584131f264a6b7d30218ab27c3e0c63ec6bfed0439d382112d1a34a1b
|
7
|
+
data.tar.gz: 63c675e1adeae3ba7fa84e35f0729558db2eefcf3ad5a0447773bbfed7328412da623cccbea50ff00ead0f4ff9a8c205793da1b6d2609b6a90f52f27e986e8f5
|
data/lib/listen/adapter/base.rb
CHANGED
@@ -28,7 +28,7 @@ module Listen
|
|
28
28
|
defaults = self.class.const_get('DEFAULTS')
|
29
29
|
@options = Listen::Options.new(options, defaults)
|
30
30
|
rescue
|
31
|
-
_log_exception 'adapter config failed: %s:%s'
|
31
|
+
_log_exception 'adapter config failed: %s:%s called from: %s', caller
|
32
32
|
raise
|
33
33
|
end
|
34
34
|
|
@@ -53,11 +53,12 @@ module Listen
|
|
53
53
|
|
54
54
|
def start
|
55
55
|
configure
|
56
|
+
calling_stack = caller.dup
|
56
57
|
Listen::Internals::ThreadPool.add do
|
57
58
|
begin
|
58
59
|
_run
|
59
60
|
rescue
|
60
|
-
_log_exception
|
61
|
+
_log_exception "run() in thread failed: %s:\n %s\n\ncalled from:\n %s", calling_stack
|
61
62
|
raise
|
62
63
|
end
|
63
64
|
end
|
@@ -83,8 +84,8 @@ module Listen
|
|
83
84
|
self.class.send(:_log, *args, &block)
|
84
85
|
end
|
85
86
|
|
86
|
-
def _log_exception(msg)
|
87
|
-
_log :error, format(msg, $ERROR_INFO, $ERROR_POSITION * "\n")
|
87
|
+
def _log_exception(msg, caller_stack)
|
88
|
+
_log :error, format(msg, $ERROR_INFO, $ERROR_POSITION * "\n", caller_stack * "\n")
|
88
89
|
end
|
89
90
|
|
90
91
|
def self._log(*args, &block)
|
data/lib/listen/directory.rb
CHANGED
@@ -26,7 +26,7 @@ module Listen
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# TODO: this is not tested properly
|
29
|
-
previous.reject
|
29
|
+
previous = previous.reject { |entry, _| current.include? path + entry }
|
30
30
|
|
31
31
|
_async_changes(dir, rel_path, queue, previous, options)
|
32
32
|
|
@@ -4,7 +4,9 @@ module Listen
|
|
4
4
|
# Just a wrapper for tests to avoid interfereing with Celluloid's threads
|
5
5
|
module ThreadPool
|
6
6
|
def self.add(&block)
|
7
|
-
|
7
|
+
Thread.new { block.call }.tap do |th|
|
8
|
+
(@threads ||= Queue.new) << th
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
def self.stop
|
data/lib/listen/listener.rb
CHANGED
@@ -188,12 +188,17 @@ module Listen
|
|
188
188
|
include Internals::Logging
|
189
189
|
|
190
190
|
def _init_options(options = {})
|
191
|
-
{
|
192
|
-
|
191
|
+
{
|
192
|
+
# Listener options
|
193
|
+
debug: false,
|
193
194
|
wait_for_delay: 0.1,
|
194
|
-
force_polling: false,
|
195
195
|
relative: false,
|
196
|
-
|
196
|
+
|
197
|
+
# Backend selecting options
|
198
|
+
force_polling: false,
|
199
|
+
polling_fallback_message: nil,
|
200
|
+
|
201
|
+
}.merge(options)
|
197
202
|
end
|
198
203
|
|
199
204
|
def _debug_level
|
@@ -209,7 +214,7 @@ module Listen
|
|
209
214
|
end
|
210
215
|
|
211
216
|
def _init_actors
|
212
|
-
|
217
|
+
adapter_options = { mq: self, directories: directories }
|
213
218
|
|
214
219
|
@supervisor = Celluloid::SupervisionGroup.run!(registry)
|
215
220
|
supervisor.add(Record, as: :record, args: self)
|
@@ -218,6 +223,9 @@ module Listen
|
|
218
223
|
# TODO: broadcaster should be a separate plugin
|
219
224
|
if @tcp_mode == :broadcaster
|
220
225
|
require 'listen/tcp/broadcaster'
|
226
|
+
|
227
|
+
# TODO: pass a TCP::Config class to make sure host and port are properly
|
228
|
+
# passed, even when nil
|
221
229
|
supervisor.add(TCP::Broadcaster, as: :broadcaster, args: [@host, @port])
|
222
230
|
|
223
231
|
# TODO: should be auto started, because if it crashes
|
@@ -226,10 +234,16 @@ module Listen
|
|
226
234
|
registry[:broadcaster].start
|
227
235
|
elsif @tcp_mode == :recipient
|
228
236
|
# TODO: adapter options should be configured in Listen.{on/to}
|
229
|
-
|
237
|
+
adapter_options.merge!(host: @host, port: @port)
|
238
|
+
end
|
239
|
+
|
240
|
+
# TODO: refactor
|
241
|
+
valid_adapter_options = _adapter_class.const_get(:DEFAULTS).keys
|
242
|
+
valid_adapter_options.each do |key|
|
243
|
+
adapter_options.merge!(key => options[key]) if options.key?(key)
|
230
244
|
end
|
231
245
|
|
232
|
-
supervisor.add(_adapter_class, as: :adapter, args:
|
246
|
+
supervisor.add(_adapter_class, as: :adapter, args: [adapter_options])
|
233
247
|
end
|
234
248
|
|
235
249
|
def _wait_for_changes
|
@@ -12,7 +12,7 @@ module Listen
|
|
12
12
|
else
|
13
13
|
smooshed = { modified: [], added: [], removed: [] }
|
14
14
|
changes.each do |_, change, dir, rel_path, _|
|
15
|
-
smooshed[change] << (dir + rel_path).to_s
|
15
|
+
smooshed[change] << (dir + rel_path).to_s if smooshed.key?(change)
|
16
16
|
end
|
17
17
|
smooshed.tap { |s| s.each { |_, v| v.uniq! } }
|
18
18
|
end
|
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.10.
|
4
|
+
version: 2.10.1
|
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-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.4.
|
128
|
+
rubygems_version: 2.4.7
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Listen to file modifications
|