listen 2.8.4 → 2.8.5

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -11
  3. data/lib/listen/adapter/base.rb +8 -4
  4. data/lib/listen/adapter/bsd.rb +8 -25
  5. data/lib/listen/adapter/tcp.rb +2 -1
  6. data/lib/listen/internals/logging.rb +12 -8
  7. data/lib/listen/listener.rb +1 -1
  8. data/lib/listen/version.rb +1 -1
  9. metadata +4 -121
  10. data/.gitignore +0 -28
  11. data/.hound.yml +0 -3
  12. data/.rspec +0 -2
  13. data/.rubocop.yml +0 -20
  14. data/.rubocop_todo.yml +0 -33
  15. data/.travis.yml +0 -15
  16. data/.yardopts +0 -11
  17. data/Gemfile +0 -48
  18. data/Guardfile +0 -16
  19. data/Rakefile +0 -151
  20. data/TROUBLESHOOTING.md +0 -139
  21. data/listen.gemspec +0 -33
  22. data/spec/acceptance/listen_spec.rb +0 -230
  23. data/spec/acceptance/tcp_spec.rb +0 -139
  24. data/spec/lib/listen/adapter/base_spec.rb +0 -31
  25. data/spec/lib/listen/adapter/bsd_spec.rb +0 -14
  26. data/spec/lib/listen/adapter/darwin_spec.rb +0 -145
  27. data/spec/lib/listen/adapter/linux_spec.rb +0 -93
  28. data/spec/lib/listen/adapter/polling_spec.rb +0 -48
  29. data/spec/lib/listen/adapter/tcp_spec.rb +0 -129
  30. data/spec/lib/listen/adapter/windows_spec.rb +0 -14
  31. data/spec/lib/listen/adapter_spec.rb +0 -75
  32. data/spec/lib/listen/change_spec.rb +0 -104
  33. data/spec/lib/listen/directory_spec.rb +0 -180
  34. data/spec/lib/listen/file_spec.rb +0 -252
  35. data/spec/lib/listen/listener_spec.rb +0 -482
  36. data/spec/lib/listen/record_spec.rb +0 -377
  37. data/spec/lib/listen/silencer_spec.rb +0 -100
  38. data/spec/lib/listen/tcp/broadcaster_spec.rb +0 -124
  39. data/spec/lib/listen/tcp/listener_spec.rb +0 -104
  40. data/spec/lib/listen/tcp/message_spec.rb +0 -138
  41. data/spec/lib/listen_spec.rb +0 -52
  42. data/spec/spec_helper.rb +0 -52
  43. data/spec/support/acceptance_helper.rb +0 -275
  44. data/spec/support/fixtures_helper.rb +0 -30
  45. data/spec/support/platform_helper.rb +0 -15
  46. data/vendor/hound/config/style_guides/ruby.yml +0 -259
@@ -1,230 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- describe 'Listen' do
5
- let(:base_options) { { wait_for_delay: 0.1, latency: 0.1 } }
6
- let(:polling_options) { {} }
7
- let(:options) { {} }
8
- let(:all_options) { base_options.merge(polling_options).merge(options) }
9
-
10
- let(:wrapper) { setup_listener(all_options, :track_changes) }
11
- before { wrapper.listener.start }
12
- after { wrapper.listener.stop }
13
-
14
- subject { wrapper }
15
-
16
- context 'with one listen dir' do
17
- let(:paths) { Pathname.new(Dir.pwd) }
18
- around { |example| fixtures { example.run } }
19
-
20
- context 'with change block raising' do
21
- let(:callback) { ->(_, _, _) { fail 'foo' } }
22
- let(:wrapper) { setup_listener(all_options, callback) }
23
-
24
- it 'warns the backtrace' do
25
- expect(Kernel).to receive(:warn).
26
- with(/exception while processing events: foo .*Backtrace:/)
27
- wrapper.listen { touch 'file.rb' }
28
- end
29
- end
30
-
31
- [false, true].each do |polling|
32
- context "force_polling option to #{polling}" do
33
- let(:polling_options) { { force_polling: polling } }
34
-
35
- context 'with default ignore options' do
36
- context 'with nothing in listen dir' do
37
-
38
- it { is_expected.to process_addition_of('file.rb') }
39
- it { is_expected.to process_addition_of('.hidden') }
40
-
41
- it 'listens to multiple files addition' do
42
- result = wrapper.listen do
43
- change_fs(:added, 'file1.rb')
44
- change_fs(:added, 'file2.rb')
45
- end
46
-
47
- expect(result).to eq(modified: [],
48
- added: %w(file1.rb file2.rb),
49
- removed: [])
50
- end
51
-
52
- it 'listens to file moved inside' do
53
- touch '../file.rb'
54
- expect(wrapper.listen do
55
- mv '../file.rb', 'file.rb'
56
- end).to eq(modified: [], added: ['file.rb'], removed: [])
57
- end
58
- end
59
-
60
- context 'existing file.rb in listen dir' do
61
- around do |example|
62
- change_fs(:added, 'file.rb')
63
- example.run
64
- end
65
-
66
- it { is_expected.to process_modification_of('file.rb') }
67
- it { is_expected.to process_removal_of('file.rb') }
68
-
69
- it 'listens to file.rb moved out' do
70
- expect(wrapper.listen do
71
- mv 'file.rb', '../file.rb'
72
- end).to eq(modified: [], added: [], removed: ['file.rb'])
73
- end
74
-
75
- it 'listens to file mode change' do
76
- prev_mode = File.stat('file.rb').mode
77
-
78
- result = wrapper.listen do
79
- windows? ? `attrib +r file.rb` : chmod(0444, 'file.rb')
80
- end
81
-
82
- new_mode = File.stat('file.rb').mode
83
- no_event = result[:modified].empty? && prev_mode == new_mode
84
-
85
- # Check if chmod actually works or an attrib event happens,
86
- # or expect nothing otherwise
87
- #
88
- # (e.g. fails for polling+vfat on Linux, but works with
89
- # INotify+vfat because you get an event regardless if mode
90
- # actually changes)
91
- #
92
- files = no_event ? [] : ['file.rb']
93
-
94
- expect(result).to eq(modified: files, added: [], removed: [])
95
- end
96
- end
97
-
98
- context 'hidden file in listen dir' do
99
- around do |example|
100
- change_fs(:added, '.hidden')
101
- example.run
102
- end
103
-
104
- it { is_expected.to process_modification_of('.hidden') }
105
- end
106
-
107
- context 'dir in listen dir' do
108
- around do |example|
109
- mkdir_p 'dir'
110
- example.run
111
- end
112
-
113
- it { is_expected.to process_addition_of('dir/file.rb') }
114
- end
115
-
116
- context 'dir with file in listen dir' do
117
- around do |example|
118
- mkdir_p 'dir'
119
- touch 'dir/file.rb'
120
- example.run
121
- end
122
-
123
- it 'listens to file move' do
124
- expected = { modified: [],
125
- added: %w(file.rb),
126
- removed: %w(dir/file.rb)
127
- }
128
-
129
- expect(wrapper.listen do
130
- mv 'dir/file.rb', 'file.rb'
131
- end).to eq expected
132
- end
133
- end
134
-
135
- context 'two dirs with files in listen dir' do
136
- around do |example|
137
- mkdir_p 'dir1'
138
- touch 'dir1/file1.rb'
139
- mkdir_p 'dir2'
140
- touch 'dir2/file2.rb'
141
- example.run
142
- end
143
-
144
- it 'listens to multiple file moves' do
145
- expected = {
146
- modified: [],
147
- added: ['dir1/file2.rb', 'dir2/file1.rb'],
148
- removed: ['dir1/file1.rb', 'dir2/file2.rb']
149
- }
150
-
151
- expect(wrapper.listen do
152
- mv 'dir1/file1.rb', 'dir2/file1.rb'
153
- mv 'dir2/file2.rb', 'dir1/file2.rb'
154
- end).to eq expected
155
- end
156
-
157
- it 'listens to dir move' do
158
- expected = { modified: [],
159
- added: ['dir2/dir1/file1.rb'],
160
- removed: ['dir1/file1.rb'] }
161
-
162
- expect(wrapper.listen do
163
- mv 'dir1', 'dir2/'
164
- end).to eq expected
165
- end
166
- end
167
-
168
- context 'with .bundle dir ignored by default' do
169
- around do |example|
170
- mkdir_p '.bundle'
171
- example.run
172
- end
173
-
174
- it { is_expected.not_to process_addition_of('.bundle/file.rb') }
175
- end
176
- end
177
-
178
- context 'when :ignore is *ignored_dir*' do
179
- context 'ignored dir with file in listen dir' do
180
- let(:options) { { ignore: /ignored_dir/ } }
181
-
182
- around do |example|
183
- mkdir_p 'ignored_dir'
184
- example.run
185
- end
186
-
187
- it { is_expected.not_to process_addition_of('ignored_dir/file.rb') }
188
- end
189
-
190
- context 'when :only is *.rb' do
191
- let(:options) { { only: /\.rb$/ } }
192
-
193
- it { is_expected.to process_addition_of('file.rb') }
194
- it { is_expected.not_to process_addition_of('file.txt') }
195
- end
196
-
197
- context 'when :ignore is bar.rb' do
198
- context 'when :only is *.rb' do
199
- let(:options) { { ignore: /bar\.rb$/, only: /\.rb$/ } }
200
-
201
- it { is_expected.to process_addition_of('file.rb') }
202
- it { is_expected.not_to process_addition_of('file.txt') }
203
- it { is_expected.not_to process_addition_of('bar.rb') }
204
- end
205
- end
206
-
207
- context 'when default ignore is *.rb' do
208
- let(:options) { { ignore: /\.rb$/ } }
209
-
210
- it { is_expected.not_to process_addition_of('file.rb') }
211
-
212
- context 'with #ignore on *.txt mask' do
213
- before { wrapper.listener.ignore(/\.txt/) }
214
-
215
- it { is_expected.not_to process_addition_of('file.rb') }
216
- it { is_expected.not_to process_addition_of('file.txt') }
217
- end
218
-
219
- context 'with #ignore! on *.txt mask' do
220
- before { wrapper.listener.ignore!(/\.txt/) }
221
-
222
- it { is_expected.to process_addition_of('file.rb') }
223
- it { is_expected.not_to process_addition_of('file.txt') }
224
- end
225
- end
226
- end
227
- end
228
- end
229
- end
230
- end
@@ -1,139 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Listen::Listener do
4
-
5
- let(:port) { 4000 }
6
- let(:broadcast_options) { { forward_to: port } }
7
- let(:paths) { Pathname.new(Dir.pwd) }
8
-
9
- around do |example|
10
- fixtures { example.run }
11
- Listen.stop
12
- end
13
-
14
- modes = if !windows? || Celluloid::VERSION > '0.15.2'
15
- [:recipient, :broadcaster]
16
- else
17
- [:broadcaster]
18
- end
19
-
20
- modes.each do |mode|
21
- context "when #{mode}" do
22
- if mode == :broadcaster
23
- subject { setup_listener(broadcast_options, :track_changes) }
24
- before { subject.listener.start }
25
- after { subject.listener.stop }
26
- else
27
- subject { setup_recipient(port, :track_changes) }
28
- let(:broadcaster) { setup_listener(broadcast_options) }
29
-
30
- before do
31
- broadcaster.listener.start
32
- # Travis on OSX is too slow
33
- subject.lag = 1.2
34
- subject.listener.start
35
- end
36
- after do
37
- broadcaster.listener.stop
38
- subject.listener.stop
39
- end
40
- end
41
-
42
- it { should process_addition_of('file.rb') }
43
-
44
- context 'when paused' do
45
- before { subject.listener.pause }
46
-
47
- context 'with no queued changes' do
48
- it { should_not process_addition_of('file.rb') }
49
-
50
- context 'when unpaused' do
51
- before { subject.listener.unpause }
52
- it { should process_addition_of('file.rb') }
53
- end
54
- end
55
-
56
- context 'with queued addition' do
57
- before { change_fs(:added, 'file.rb') }
58
- it { should_not process_modification_of('file.rb') }
59
-
60
- context 'when unpaused' do
61
- before { subject.listener.unpause }
62
- it { should process_queued_addition_of('file.rb') }
63
- it { should process_modification_of('file.rb') }
64
- end
65
- end
66
-
67
- context 'with queued modification' do
68
- before do
69
- change_fs(:added, 'file.rb')
70
- change_fs(:modified, 'file.rb')
71
- end
72
-
73
- it { should_not process_queued_addition_of('file.rb') }
74
- it { should_not process_queued_modification_of('file.rb') }
75
-
76
- context 'when unpaused' do
77
- before { subject.listener.unpause }
78
- it { should process_queued_addition_of('file.rb') }
79
-
80
- # NOTE: when adapter is 'local_fs?', the change optimizer
81
- # (_squash_changes) reduces the "add+mod" into a single "add"
82
- if mode == :broadcaster
83
- # "optimizing" on local fs (broadcaster) will remove
84
- # :modified from queue
85
- it { should_not process_queued_modification_of('file.rb') }
86
- else
87
- # optimization skipped, because it's TCP, so we'll have both
88
- # :modified and :added events for same file
89
- it { should process_queued_modification_of('file.rb') }
90
- end
91
-
92
- it { should process_modification_of('file.rb') }
93
- end
94
- end
95
- end
96
-
97
- context 'when stopped' do
98
- before { subject.listener.stop }
99
-
100
- context 'with no queued changes' do
101
- it { should_not process_addition_of('file.rb') }
102
-
103
- context 'when started' do
104
- before { subject.listener.start }
105
- it { should process_addition_of('file.rb') }
106
- end
107
- end
108
-
109
- context 'with queued addition' do
110
- before { change_fs(:added, 'file.rb') }
111
- it { should_not process_modification_of('file.rb') }
112
-
113
- context 'when started' do
114
- before { subject.listener.start }
115
- it { should_not process_queued_addition_of('file.rb') }
116
- it { should process_modification_of('file.rb') }
117
- end
118
- end
119
-
120
- context 'with queued modification' do
121
- before do
122
- change_fs(:added, 'file.rb')
123
- change_fs(:modified, 'file.rb')
124
- end
125
-
126
- it { should_not process_queued_addition_of('file.rb') }
127
- it { should_not process_queued_modification_of('file.rb') }
128
-
129
- context 'when started' do
130
- before { subject.listener.start }
131
- it { should_not process_queued_addition_of('file.rb') }
132
- it { should_not process_queued_modification_of('file.rb') }
133
- it { should process_modification_of('file.rb') }
134
- end
135
- end
136
- end
137
- end
138
- end
139
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Listen
4
-
5
- describe Adapter::Base do
6
-
7
- class FakeAdapter < described_class
8
- def initialize(*args)
9
- super(*args)
10
- end
11
- end
12
-
13
- subject { FakeAdapter.new(mq: mq, directories: []) }
14
-
15
- let(:mq) { instance_double(Listener) }
16
-
17
- describe '#_notify_change' do
18
- let(:dir) { Pathname.pwd }
19
-
20
- context 'listener is listening or paused' do
21
- let(:worker) { instance_double(Change) }
22
-
23
- it 'calls change on change_pool asynchronously' do
24
- expect(mq).to receive(:_queue_raw_change).
25
- with(:dir, dir, 'path', recursive: true)
26
-
27
- subject.send(:_queue_change, :dir, dir, 'path', recursive: true)
28
- end
29
- end
30
- end
31
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Listen::Adapter::BSD do
4
- describe 'class' do
5
- subject { described_class }
6
- it { should be_local_fs }
7
-
8
- if bsd?
9
- it { should be_usable }
10
- else
11
- it { should_not be_usable }
12
- end
13
- end
14
- end
@@ -1,145 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # This is just so stubs work
4
- require 'rb-fsevent'
5
-
6
- require 'listen/adapter/darwin'
7
-
8
- include Listen
9
-
10
- describe Adapter::Darwin do
11
- describe 'class' do
12
- subject { described_class }
13
- it { should be_local_fs }
14
-
15
- if darwin?
16
- it { should be_usable }
17
- else
18
- it { should_not be_usable }
19
- end
20
- end
21
-
22
- let(:options) { {} }
23
- let(:mq) { instance_double(Listener, options: options) }
24
-
25
- describe '#_latency' do
26
- subject do
27
- adapter = described_class.new(options.merge(mq: mq, directories: []))
28
- adapter.options.latency
29
- end
30
-
31
- context 'with no overriding option' do
32
- it { should eq 0.1 }
33
- end
34
-
35
- context 'with custom latency overriding' do
36
- let(:options) { { latency: 1234 } }
37
- it { should eq 1234 }
38
- end
39
- end
40
-
41
- describe 'multiple dirs' do
42
- subject do
43
- dirs = config.keys.map { |p| Pathname(p.to_s) }
44
- described_class.new(directories: dirs)
45
- end
46
-
47
- let(:foo1) { double('foo1') }
48
- let(:foo2) { double('foo2') }
49
- let(:foo3) { double('foo3') }
50
-
51
- before do
52
- allow(FSEvent).to receive(:new).and_return(*config.values, nil)
53
- config.each do |dir, obj|
54
- allow(obj).to receive(:watch).with(dir.to_s, latency: 0.1)
55
- end
56
- subject.configure
57
- end
58
-
59
- describe 'configuration' do
60
- context 'with 1 directory' do
61
- let(:config) { { dir1: foo1 } }
62
-
63
- it 'configures directory' do
64
- expect(foo1).to have_received(:watch).with('dir1', latency: 0.1)
65
- end
66
- end
67
-
68
- context 'with 2 directories' do
69
- let(:config) { { dir1: foo1, dir2: foo2 } }
70
-
71
- it 'configures directories' do
72
- expect(foo1).to have_received(:watch).with('dir1', latency: 0.1)
73
- expect(foo2).to have_received(:watch).with('dir2', latency: 0.1)
74
- end
75
- end
76
-
77
- context 'with 3 directories' do
78
- let(:config) { { dir1: foo1, dir2: foo2, dir3: foo3 } }
79
-
80
- it 'configures directories' do
81
- expect(foo1).to have_received(:watch).with('dir1', latency: 0.1)
82
- expect(foo2).to have_received(:watch).with('dir2', latency: 0.1)
83
- expect(foo3).to have_received(:watch).with('dir3', latency: 0.1)
84
- end
85
- end
86
- end
87
-
88
- describe 'running threads' do
89
- let(:running) { [] }
90
-
91
- before do
92
- started = Queue.new
93
- threads = Queue.new
94
- left = Queue.new
95
-
96
- # NOTE: Travis has a hard time creating threads on OSX
97
- thread_start_overhead = 3
98
- max_test_time = 3 * thread_start_overhead
99
- block_time = max_test_time + thread_start_overhead
100
-
101
- config.each do |name, obj|
102
- left << name # anything, we're just counting
103
- allow(obj).to receive(:run).once do
104
- threads << Thread.current
105
- started << name
106
- left.pop
107
- sleep block_time
108
- end
109
- end
110
-
111
- Timeout.timeout(max_test_time) do
112
- subject.start
113
- running << started.pop until left.empty?
114
- end
115
-
116
- running << started.pop until started.empty?
117
-
118
- killed = Queue.new
119
- killed << threads.pop.kill until threads.empty?
120
- killed.pop.join until killed.empty?
121
- end
122
-
123
- context 'with 1 directory' do
124
- let(:config) { { dir1: foo1 } }
125
- it 'runs all the workers without blocking' do
126
- expect(running.sort).to eq(config.keys)
127
- end
128
- end
129
-
130
- context 'with 2 directories' do
131
- let(:config) { { dir1: foo1, dir2: foo2 } }
132
- it 'runs all the workers without blocking' do
133
- expect(running.sort).to eq(config.keys)
134
- end
135
- end
136
-
137
- context 'with 3 directories' do
138
- let(:config) { { dir1: foo1, dir2: foo2, dir3: foo3 } }
139
- it 'runs all the workers without blocking' do
140
- expect(running.sort).to eq(config.keys)
141
- end
142
- end
143
- end
144
- end
145
- end