listen 2.7.8 → 2.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/listen +1 -1
- data/lib/listen.rb +3 -0
- data/lib/listen/adapter/linux.rb +2 -1
- data/lib/listen/listener.rb +2 -0
- data/lib/listen/record.rb +7 -4
- data/lib/listen/version.rb +1 -1
- data/spec/lib/listen/record_spec.rb +29 -12
- data/spec/lib/listen_spec.rb +12 -3
- 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: b3cee3bca315051931b8206499fded313985faf4
|
4
|
+
data.tar.gz: e2893da22d2bce0400f381d86d4b62f93220219c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9574e5f1138f0a6fd05cb0a203564ff96f500892c0b4b8a5a4b8bf6f53163e6d7f16882f09a93047f8c65155018dad8ec1d0989203c9bc15728b7e3d2346b7f9
|
7
|
+
data.tar.gz: 487371b7585da0c36c658b9aa0bc96243f0d7010bfcc881cbe28bdd0374ab796dc1149c1180c3ef923b430720a37bd9da8aa998d6aba46d283525d696b027014
|
data/bin/listen
CHANGED
data/lib/listen.rb
CHANGED
data/lib/listen/adapter/linux.rb
CHANGED
@@ -51,7 +51,8 @@ module Listen
|
|
51
51
|
|
52
52
|
if /1|true/ =~ ENV['LISTEN_GEM_SIMULATE_FSEVENT']
|
53
53
|
if (event.flags & [:moved_to, :moved_from]) || _dir_event?(event)
|
54
|
-
|
54
|
+
rel_path = path.dirname.relative_path_from(dir).to_s
|
55
|
+
_queue_change(:dir, dir, rel_path, {})
|
55
56
|
else
|
56
57
|
_queue_change(:dir, dir, rel_path, {})
|
57
58
|
end
|
data/lib/listen/listener.rb
CHANGED
@@ -271,8 +271,10 @@ module Listen
|
|
271
271
|
hash = _smoosh_changes(changes)
|
272
272
|
result = [hash[:modified], hash[:added], hash[:removed]]
|
273
273
|
|
274
|
+
block_start = Time.now.to_f
|
274
275
|
# TODO: condition not tested, but too complex to test ATM
|
275
276
|
block.call(*result) unless result.all?(&:empty?)
|
277
|
+
_log :debug, "Callback took #{Time.now.to_f - block_start} seconds"
|
276
278
|
end
|
277
279
|
|
278
280
|
attr_reader :wait_thread
|
data/lib/listen/record.rb
CHANGED
@@ -24,8 +24,6 @@ module Listen
|
|
24
24
|
|
25
25
|
def unset_path(dir, rel_path)
|
26
26
|
dirname, basename = Pathname(rel_path).split.map(&:to_s)
|
27
|
-
|
28
|
-
@paths[dir.to_s][dirname] ||= {}
|
29
27
|
_fast_unset_path(dir, dirname, basename)
|
30
28
|
end
|
31
29
|
|
@@ -93,8 +91,13 @@ module Listen
|
|
93
91
|
root = @paths[dir.to_s]
|
94
92
|
# this may need to be reworked to properly remove
|
95
93
|
# entries from a tree, without adding non-existing dirs to the record
|
96
|
-
|
97
|
-
|
94
|
+
if [nil, '', '.'].include? dirname
|
95
|
+
return unless root.key?(basename)
|
96
|
+
root.delete(basename)
|
97
|
+
else
|
98
|
+
return unless root.key?(dirname)
|
99
|
+
root[dirname].delete(basename)
|
100
|
+
end
|
98
101
|
end
|
99
102
|
|
100
103
|
def _fast_build(root)
|
data/lib/listen/version.rb
CHANGED
@@ -79,19 +79,39 @@ describe Listen::Record do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
describe '#unset_path' do
|
82
|
-
context '
|
83
|
-
|
82
|
+
context 'within watched dir' do
|
83
|
+
context 'when path is present' do
|
84
|
+
before { record.update_file(dir, 'file.rb', mtime: 1.1) }
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
it 'unsets path' do
|
87
|
+
record.unset_path(dir, 'file.rb')
|
88
|
+
expect(record.paths).to eq('/dir' => {})
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when path not present' do
|
93
|
+
it 'unsets path' do
|
94
|
+
record.unset_path(dir, 'file.rb')
|
95
|
+
expect(record.paths).to eq('/dir' => {})
|
96
|
+
end
|
88
97
|
end
|
89
98
|
end
|
90
99
|
|
91
|
-
context '
|
92
|
-
|
93
|
-
record.
|
94
|
-
|
100
|
+
context 'within subdir' do
|
101
|
+
context 'when path is present' do
|
102
|
+
before { record.update_file(dir, 'path/file.rb', mtime: 1.1) }
|
103
|
+
|
104
|
+
it 'unsets path' do
|
105
|
+
record.unset_path(dir, 'path/file.rb')
|
106
|
+
expect(record.paths).to eq('/dir' => { 'path' => {} })
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when path not present' do
|
111
|
+
it 'unsets path' do
|
112
|
+
record.unset_path(dir, 'path/file.rb')
|
113
|
+
expect(record.paths).to eq('/dir' => {})
|
114
|
+
end
|
95
115
|
end
|
96
116
|
end
|
97
117
|
end
|
@@ -142,9 +162,6 @@ describe Listen::Record do
|
|
142
162
|
context 'with file.rb in record' do
|
143
163
|
before { record.update_file(dir, 'file.rb', mtime: 1.1) }
|
144
164
|
it { should eq('file.rb' => { mtime: 1.1 }) }
|
145
|
-
context 'when file is removed' do
|
146
|
-
before { record.update_file(dir, 'file.rb', mtime: 1.1) }
|
147
|
-
end
|
148
165
|
end
|
149
166
|
|
150
167
|
context 'with subdir/file.rb in record' do
|
data/spec/lib/listen_spec.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Listen do
|
4
|
+
let(:listener) { instance_double(Listen::Listener, stop: nil) }
|
5
|
+
|
6
|
+
after do
|
7
|
+
Listen.stop
|
8
|
+
end
|
9
|
+
|
4
10
|
describe '.to' do
|
5
11
|
it 'initalizes listener' do
|
6
|
-
expect(Listen::Listener).to receive(:new).with('/path')
|
12
|
+
expect(Listen::Listener).to receive(:new).with('/path') { listener }
|
7
13
|
described_class.to('/path')
|
8
14
|
end
|
9
15
|
|
10
16
|
context 'when using :forward_to option' do
|
11
17
|
it 'initializes TCP-listener in broadcast-mode' do
|
12
18
|
expect(Listen::Listener).to receive(:new).
|
13
|
-
with(4000, :broadcaster, '/path', {})
|
19
|
+
with(4000, :broadcaster, '/path', {}) { listener }
|
14
20
|
described_class.to('/path', forward_to: 4000)
|
15
21
|
end
|
16
22
|
end
|
@@ -18,6 +24,9 @@ describe Listen do
|
|
18
24
|
|
19
25
|
describe '.stop' do
|
20
26
|
it 'stops all listeners & Celluloid' do
|
27
|
+
allow(Listen::Listener).to receive(:new).with('/path') { listener }
|
28
|
+
expect(listener).to receive(:stop)
|
29
|
+
described_class.to('/path')
|
21
30
|
Listen.stop
|
22
31
|
|
23
32
|
# TODO: running? returns internal_pool on 0.15.2
|
@@ -36,7 +45,7 @@ describe Listen do
|
|
36
45
|
describe '.on' do
|
37
46
|
it 'initializes TCP-listener in recipient-mode' do
|
38
47
|
expect(Listen::Listener).to receive(:new).
|
39
|
-
with(4000, :recipient, '/path')
|
48
|
+
with(4000, :recipient, '/path') { listener }
|
40
49
|
described_class.on(4000, '/path')
|
41
50
|
end
|
42
51
|
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: 2.7.
|
4
|
+
version: 2.7.9
|
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-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|