listen 2.7.6 → 2.7.7
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/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.travis.yml +0 -0
- data/.yardopts +0 -0
- data/CHANGELOG.md +0 -0
- data/CONTRIBUTING.md +0 -0
- data/Gemfile +2 -0
- data/Guardfile +2 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/lib/listen.rb +0 -0
- data/lib/listen/adapter.rb +0 -0
- data/lib/listen/adapter/base.rb +47 -21
- data/lib/listen/adapter/bsd.rb +31 -25
- data/lib/listen/adapter/darwin.rb +13 -12
- data/lib/listen/adapter/linux.rb +45 -36
- data/lib/listen/adapter/polling.rb +12 -7
- data/lib/listen/adapter/tcp.rb +9 -4
- data/lib/listen/adapter/windows.rb +46 -58
- data/lib/listen/change.rb +12 -8
- data/lib/listen/cli.rb +0 -0
- data/lib/listen/directory.rb +30 -22
- data/lib/listen/file.rb +9 -8
- data/lib/listen/listener.rb +35 -12
- data/lib/listen/options.rb +23 -0
- data/lib/listen/queue_optimizer.rb +23 -13
- data/lib/listen/record.rb +98 -21
- data/lib/listen/silencer.rb +21 -40
- data/lib/listen/tcp.rb +0 -0
- data/lib/listen/tcp/broadcaster.rb +0 -0
- data/lib/listen/tcp/message.rb +0 -0
- data/lib/listen/version.rb +1 -1
- data/listen.gemspec +0 -0
- data/spec/acceptance/listen_spec.rb +0 -0
- data/spec/acceptance/tcp_spec.rb +0 -0
- data/spec/lib/listen/adapter/base_spec.rb +17 -16
- data/spec/lib/listen/adapter/bsd_spec.rb +0 -0
- data/spec/lib/listen/adapter/darwin_spec.rb +11 -4
- data/spec/lib/listen/adapter/linux_spec.rb +20 -29
- data/spec/lib/listen/adapter/polling_spec.rb +15 -13
- data/spec/lib/listen/adapter/tcp_spec.rb +6 -3
- data/spec/lib/listen/adapter/windows_spec.rb +0 -0
- data/spec/lib/listen/adapter_spec.rb +0 -0
- data/spec/lib/listen/change_spec.rb +21 -27
- data/spec/lib/listen/directory_spec.rb +60 -42
- data/spec/lib/listen/file_spec.rb +16 -20
- data/spec/lib/listen/listener_spec.rb +136 -99
- data/spec/lib/listen/record_spec.rb +205 -62
- data/spec/lib/listen/silencer_spec.rb +44 -114
- data/spec/lib/listen/tcp/broadcaster_spec.rb +0 -0
- data/spec/lib/listen/tcp/listener_spec.rb +8 -5
- data/spec/lib/listen/tcp/message_spec.rb +0 -0
- data/spec/lib/listen_spec.rb +0 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/support/acceptance_helper.rb +15 -4
- data/spec/support/fixtures_helper.rb +0 -0
- data/spec/support/platform_helper.rb +0 -0
- metadata +3 -2
@@ -1,156 +1,86 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
RSpec::Matchers.define :accept do |type, path|
|
4
|
+
match { |actual| !actual.silenced?(Pathname(path), type) }
|
5
|
+
end
|
6
|
+
|
3
7
|
describe Listen::Silencer do
|
4
8
|
let(:options) { {} }
|
5
|
-
|
6
|
-
let(:listener) do
|
7
|
-
instance_double(
|
8
|
-
Listen::Listener,
|
9
|
-
directories: [Pathname.pwd, Pathname.new('/Users/Shared/')],
|
10
|
-
options: options
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:silencer) { Listen::Silencer.new(listener) }
|
9
|
+
before { subject.configure(options) }
|
15
10
|
|
16
11
|
describe '#silenced?' do
|
17
|
-
|
18
|
-
|
19
|
-
context 'default ignore' do
|
20
|
-
|
21
|
-
|
22
|
-
(
|
23
|
-
it
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
it "doesn't silence #{dir}foo" do
|
28
|
-
expect(silencer.silenced?(pwd + "#{dir}foo", :dir)).to be_falsey
|
29
|
-
end
|
30
|
-
|
31
|
-
it "doesn't silence foo#{dir}" do
|
32
|
-
expect(silencer.silenced?(pwd + "foo#{dir}", :dir)).to be_falsey
|
33
|
-
end
|
12
|
+
it { should accept(:file, Pathname('some_dir') + 'some_file.rb') }
|
13
|
+
|
14
|
+
context 'with default ignore' do
|
15
|
+
hidden_ignored = %w(.git .svn .hg .rbx .bundle)
|
16
|
+
other_ignored = %w(bundle vendor/bundle log tmp vendor/ruby)
|
17
|
+
(hidden_ignored + other_ignored).each do |dir|
|
18
|
+
it { should_not accept(:dir, dir) }
|
19
|
+
it { should accept(:dir, "#{dir}foo") }
|
20
|
+
it { should accept(:dir, "foo#{dir}") }
|
34
21
|
end
|
35
22
|
|
36
|
-
|
23
|
+
ignored = %w(.DS_Store foo.tmp foo~)
|
37
24
|
|
38
25
|
# Gedit swap files
|
39
|
-
|
26
|
+
ignored += %w(.goutputstream-S3FBGX)
|
40
27
|
|
41
28
|
# Kate editor swap files
|
42
|
-
|
29
|
+
ignored += %w(foo.rbo54321.new foo.rbB22583.new foo.rb.kate-swp)
|
43
30
|
|
44
31
|
# Intellij swap files
|
45
|
-
|
32
|
+
ignored += %w(foo.rb___jb_bak___ foo.rb___jb_old___)
|
46
33
|
|
47
34
|
# Vim swap files
|
48
|
-
|
35
|
+
ignored += %w(foo.swp foo.swx foo.swpx 4913)
|
49
36
|
|
50
|
-
|
51
|
-
it
|
52
|
-
expect(silencer.silenced?(pwd + path, :file)).to be_truthy
|
53
|
-
end
|
37
|
+
ignored.each do |path|
|
38
|
+
it { should_not accept(:file, path) }
|
54
39
|
end
|
55
40
|
|
56
41
|
%w(foo.tmpl file.new file54321.new a.swf 14913 49131).each do |path|
|
57
|
-
it
|
58
|
-
expect(silencer.silenced?(pwd + path, :file)).to be_falsey
|
59
|
-
end
|
42
|
+
it { should accept(:file, path) }
|
60
43
|
end
|
61
44
|
end
|
62
45
|
|
63
|
-
context '
|
46
|
+
context 'when ignoring *.pid' do
|
64
47
|
let(:options) { { ignore: /\.pid$/ } }
|
65
|
-
|
66
|
-
it 'silences path matching custom ignore regex' do
|
67
|
-
expect(silencer.silenced?(pwd + 'foo.pid', :file)).to be_truthy
|
68
|
-
end
|
48
|
+
it { should_not accept(:file, 'foo.pid') }
|
69
49
|
end
|
70
50
|
|
71
|
-
context '
|
51
|
+
context 'when ignoring foo/bar* and *.pid' do
|
72
52
|
let(:options) { { ignore: [%r{^foo/bar}, /\.pid$/] } }
|
73
|
-
|
74
|
-
it
|
75
|
-
expect(silencer.silenced?(pwd + 'foo/bar/baz', :file)).to be_truthy
|
76
|
-
expect(silencer.silenced?(pwd + 'foo.pid', :file)).to be_truthy
|
77
|
-
end
|
53
|
+
it { should_not accept(:file, 'foo/bar/baz') }
|
54
|
+
it { should_not accept(:file, 'foo.pid') }
|
78
55
|
end
|
79
56
|
|
80
|
-
context '
|
57
|
+
context 'when ignoring only *.pid' do
|
81
58
|
let(:options) { { ignore!: /\.pid$/ } }
|
82
|
-
|
83
|
-
it
|
84
|
-
expect(silencer.silenced?(pwd + 'foo.pid', :file)).to be_truthy
|
85
|
-
end
|
86
|
-
|
87
|
-
it "doesn't silence default ignored directory" do
|
88
|
-
expect(silencer.silenced?(pwd + '.git', :file)).to be_falsey
|
89
|
-
end
|
59
|
+
it { should_not accept(:file, 'foo.pid') }
|
60
|
+
it { should accept(:file, '.git') }
|
90
61
|
end
|
91
62
|
|
92
|
-
context '
|
63
|
+
context 'when accepting only *foo*' do
|
93
64
|
let(:options) { { only: %r{foo} } }
|
94
|
-
|
95
|
-
it
|
96
|
-
expect(silencer.silenced?(pwd + 'foo', :file)).to be_falsey
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'silences other directory' do
|
100
|
-
expect(silencer.silenced?(pwd + 'bar', :file)).to be_truthy
|
101
|
-
end
|
65
|
+
it { should accept(:file, 'foo') }
|
66
|
+
it { should_not accept(:file, 'bar') }
|
102
67
|
end
|
103
68
|
|
104
|
-
context '
|
69
|
+
context 'when accepting only foo/* and *.txt' do
|
105
70
|
let(:options) { { only: [%r{^foo/}, %r{\.txt$}] } }
|
106
|
-
|
107
|
-
it
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
it "doesn't silence good file" do
|
112
|
-
expect(silencer.silenced?(pwd + 'bar.txt', :file)).to be_falsey
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'silences other directory' do
|
116
|
-
expect(silencer.silenced?(pwd + 'bar/baz.rb', :file)).to be_truthy
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'silences other file' do
|
120
|
-
expect(silencer.silenced?(pwd + 'bar.rb', :file)).to be_truthy
|
121
|
-
end
|
71
|
+
it { should accept(:file, 'foo/bar.rb') }
|
72
|
+
it { should accept(:file, 'bar.txt') }
|
73
|
+
it { should_not accept(:file, 'bar/baz.rb') }
|
74
|
+
it { should_not accept(:file, 'bar.rb') }
|
122
75
|
end
|
123
76
|
|
124
|
-
context '
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
expect(silencer.silenced?(pwd + 'foo.rb', :file)).to be_truthy
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
context 'when matching :only' do
|
135
|
-
context 'when matching :ignore' do
|
136
|
-
it 'silences' do
|
137
|
-
expect(silencer.silenced?(pwd + 'bar.pid', :file)).to be_truthy
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'when not matching :ignore' do
|
142
|
-
it 'does not silence' do
|
143
|
-
expect(silencer.silenced?(pwd + 'foo.pid', :file)).to be_falsey
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
77
|
+
context 'when accepting only *.pid' do
|
78
|
+
context 'when ignoring bar*' do
|
79
|
+
let(:options) { { only: /\.pid$/, ignore: %r{^bar} } }
|
80
|
+
it { should_not accept(:file, 'foo.rb') }
|
81
|
+
it { should_not accept(:file, 'bar.pid') }
|
82
|
+
it { should accept(:file, 'foo.pid') }
|
147
83
|
end
|
148
84
|
end
|
149
|
-
|
150
|
-
it "doesn't silence normal path" do
|
151
|
-
path = (pwd + 'some_dir') + 'some_file.rb'
|
152
|
-
expect(silencer.silenced?(path, :file)).to be_falsey
|
153
|
-
end
|
154
85
|
end
|
155
|
-
|
156
86
|
end
|
File without changes
|
@@ -17,7 +17,7 @@ describe Listen::Listener do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:record) { instance_double(Listen::Record, terminate: true, build: true) }
|
20
|
-
let(:silencer) { instance_double(Listen::Silencer,
|
20
|
+
let(:silencer) { instance_double(Listen::Silencer, configure: nil) }
|
21
21
|
let(:adapter) { instance_double(Listen::Adapter::Base) }
|
22
22
|
let(:async) { instance_double(Listen::TCP::Broadcaster, broadcast: true) }
|
23
23
|
let(:broadcaster) { instance_double(Listen::TCP::Broadcaster, async: async) }
|
@@ -26,11 +26,12 @@ describe Listen::Listener do
|
|
26
26
|
before do
|
27
27
|
allow(Celluloid::Registry).to receive(:new) { registry }
|
28
28
|
allow(Celluloid::SupervisionGroup).to receive(:run!) { supervisor }
|
29
|
-
allow(registry).to receive(:[]).with(:silencer) { silencer }
|
30
29
|
allow(registry).to receive(:[]).with(:adapter) { adapter }
|
31
30
|
allow(registry).to receive(:[]).with(:record) { record }
|
32
31
|
allow(registry).to receive(:[]).with(:change_pool) { change_pool }
|
33
32
|
allow(registry).to receive(:[]).with(:broadcaster) { broadcaster }
|
33
|
+
|
34
|
+
allow(Listen::Silencer).to receive(:new) { silencer }
|
34
35
|
end
|
35
36
|
|
36
37
|
describe '#initialize' do
|
@@ -78,15 +79,17 @@ describe Listen::Listener do
|
|
78
79
|
end
|
79
80
|
|
80
81
|
subject.stop
|
81
|
-
subject.queue(:file, :modified, 'foo')
|
82
|
+
subject.queue(:file, :modified, Pathname.pwd, 'foo')
|
82
83
|
expect(broadcaster).not_to receive(:async)
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
87
|
+
let(:dir) { Pathname.pwd }
|
88
|
+
|
86
89
|
it 'broadcasts changes asynchronously' do
|
87
|
-
message = Listen::TCP::Message.new(:file, :modified, 'foo', {})
|
90
|
+
message = Listen::TCP::Message.new(:file, :modified, dir, 'foo', {})
|
88
91
|
expect(async).to receive(:broadcast).with message.payload
|
89
|
-
subject.queue(:file, :modified, 'foo')
|
92
|
+
subject.queue(:file, :modified, Pathname.pwd, 'foo')
|
90
93
|
end
|
91
94
|
end
|
92
95
|
end
|
File without changes
|
data/spec/lib/listen_spec.rb
CHANGED
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
@@ -185,14 +185,25 @@ class ListenerWrapper
|
|
185
185
|
end
|
186
186
|
|
187
187
|
def listen(reset_queue = true)
|
188
|
-
|
188
|
+
# Give previous events time to be received, queued and processed
|
189
|
+
# so they complete and don't interfere
|
190
|
+
sleep lag
|
189
191
|
|
190
|
-
|
191
|
-
sleep lag
|
192
|
+
@timed_changes.allow_changes(reset_queue) do
|
192
193
|
|
193
194
|
yield
|
194
195
|
|
195
|
-
|
196
|
+
# Polling sleep (default: 1s)
|
197
|
+
adapter = @listener.sync(:adapter)
|
198
|
+
if adapter.is_a?(Listen::Adapter::Polling)
|
199
|
+
sleep adapter.options.latency
|
200
|
+
end
|
201
|
+
|
202
|
+
# Lag should include:
|
203
|
+
# 0.1s - 0.2s if the test needs Listener queue to be processed
|
204
|
+
# 0.1s in case the system is busy
|
205
|
+
# 0.1s - for celluloid overhead and scheduling
|
206
|
+
sleep lag
|
196
207
|
end
|
197
208
|
|
198
209
|
# Keep this to detect a lag too small (changes during this sleep
|
File without changes
|
File without changes
|
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.7
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/listen/directory.rb
|
158
158
|
- lib/listen/file.rb
|
159
159
|
- lib/listen/listener.rb
|
160
|
+
- lib/listen/options.rb
|
160
161
|
- lib/listen/queue_optimizer.rb
|
161
162
|
- lib/listen/record.rb
|
162
163
|
- lib/listen/silencer.rb
|