listen 2.7.8 → 2.7.9

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: 75b73ca8c3df5774760e1a9e9cd4281a4fb91f7b
4
- data.tar.gz: f09049b304ca5bf11a288ee36cc81ff7f0f4d624
3
+ metadata.gz: b3cee3bca315051931b8206499fded313985faf4
4
+ data.tar.gz: e2893da22d2bce0400f381d86d4b62f93220219c
5
5
  SHA512:
6
- metadata.gz: beb3b0ff8fd1e133ea01b700a147f4aeac44bf670fdb3c16f4e66da5fc24545645a51899cbd241add9be9887091a5312dd196606b23229c3d574f9e4f9db390a
7
- data.tar.gz: c5f4d09de7c8f336aee3f4c8c69e8707e174de4692c83beb7640213bae9254dcffaa07642ea212c632eb38c4ed5fd75ca2871af859589c06fff0e86179f8f516
6
+ metadata.gz: 9574e5f1138f0a6fd05cb0a203564ff96f500892c0b4b8a5a4b8bf6f53163e6d7f16882f09a93047f8c65155018dad8ec1d0989203c9bc15728b7e3d2346b7f9
7
+ data.tar.gz: 487371b7585da0c36c658b9aa0bc96243f0d7010bfcc881cbe28bdd0374ab796dc1149c1180c3ef923b430720a37bd9da8aa998d6aba46d283525d696b027014
data/bin/listen CHANGED
@@ -5,7 +5,7 @@ require 'listen/cli'
5
5
 
6
6
  unless defined?(JRUBY_VERSION)
7
7
  if Signal.list.keys.include?('INT')
8
- Signal.trap('INT') { Listen.stop }
8
+ Signal.trap('INT') { Thread.new { Listen.stop } }
9
9
  end
10
10
  end
11
11
 
@@ -37,10 +37,13 @@ module Listen
37
37
  #
38
38
  def stop
39
39
  @listeners ||= []
40
+
41
+ # TODO: should use a mutex for this
40
42
  @listeners.each do |listener|
41
43
  # call stop to halt the main loop
42
44
  listener.stop
43
45
  end
46
+ @listeners = nil
44
47
 
45
48
  Celluloid.shutdown
46
49
  end
@@ -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
- _queue_change(:dir, dir, Pathname(rel_path).dirname, {})
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
@@ -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
@@ -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
- return unless root.key?(dirname)
97
- root[dirname].delete(basename)
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)
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '2.7.8'
2
+ VERSION = '2.7.9'
3
3
  end
@@ -79,19 +79,39 @@ describe Listen::Record do
79
79
  end
80
80
 
81
81
  describe '#unset_path' do
82
- context 'path is present' do
83
- before { record.update_file(dir, 'path/file.rb', mtime: 1.1) }
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
- it 'unsets path' do
86
- record.unset_path(dir, 'path/file.rb')
87
- expect(record.paths).to eq('/dir' => { 'path' => {} })
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 'path not present' do
92
- it 'unsets path' do
93
- record.unset_path(dir, 'path/file.rb')
94
- expect(record.paths).to eq('/dir' => { 'path' => {} })
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
@@ -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.8
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-12 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid