fluid_cli 0.1.5 → 0.1.6
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/lib/fluid_cli/api.rb +9 -3
- data/lib/fluid_cli/http_request.rb +7 -1
- data/lib/fluid_cli/theme/syncer.rb +93 -13
- data/lib/fluid_cli/version.rb +1 -1
- data/lib/fluid_cli.rb +1 -0
- metadata +16 -97
- data/vendor/deps/listen/.github/release-drafter.yml +0 -17
- data/vendor/deps/listen/.github/workflows/development.yml +0 -67
- data/vendor/deps/listen/.github/workflows/push.yml +0 -12
- data/vendor/deps/listen/.gitignore +0 -28
- data/vendor/deps/listen/.rspec +0 -3
- data/vendor/deps/listen/.rubocop.yml +0 -283
- data/vendor/deps/listen/.yardopts +0 -11
- data/vendor/deps/listen/CHANGELOG.md +0 -1
- data/vendor/deps/listen/CONTRIBUTING.md +0 -45
- data/vendor/deps/listen/Gemfile +0 -33
- data/vendor/deps/listen/Guardfile +0 -26
- data/vendor/deps/listen/LICENSE.txt +0 -22
- data/vendor/deps/listen/README.md +0 -490
- data/vendor/deps/listen/Rakefile +0 -154
- data/vendor/deps/listen/bin/listen +0 -11
- data/vendor/deps/listen/lib/listen/adapter/base.rb +0 -129
- data/vendor/deps/listen/lib/listen/adapter/bsd.rb +0 -104
- data/vendor/deps/listen/lib/listen/adapter/config.rb +0 -31
- data/vendor/deps/listen/lib/listen/adapter/darwin.rb +0 -77
- data/vendor/deps/listen/lib/listen/adapter/linux.rb +0 -108
- data/vendor/deps/listen/lib/listen/adapter/polling.rb +0 -40
- data/vendor/deps/listen/lib/listen/adapter/windows.rb +0 -96
- data/vendor/deps/listen/lib/listen/adapter.rb +0 -43
- data/vendor/deps/listen/lib/listen/backend.rb +0 -40
- data/vendor/deps/listen/lib/listen/change.rb +0 -69
- data/vendor/deps/listen/lib/listen/cli.rb +0 -65
- data/vendor/deps/listen/lib/listen/directory.rb +0 -93
- data/vendor/deps/listen/lib/listen/error.rb +0 -11
- data/vendor/deps/listen/lib/listen/event/config.rb +0 -39
- data/vendor/deps/listen/lib/listen/event/loop.rb +0 -92
- data/vendor/deps/listen/lib/listen/event/processor.rb +0 -128
- data/vendor/deps/listen/lib/listen/event/queue.rb +0 -52
- data/vendor/deps/listen/lib/listen/file.rb +0 -95
- data/vendor/deps/listen/lib/listen/fsm.rb +0 -131
- data/vendor/deps/listen/lib/listen/listener/config.rb +0 -41
- data/vendor/deps/listen/lib/listen/listener.rb +0 -136
- data/vendor/deps/listen/lib/listen/logger.rb +0 -65
- data/vendor/deps/listen/lib/listen/monotonic_time.rb +0 -27
- data/vendor/deps/listen/lib/listen/options.rb +0 -24
- data/vendor/deps/listen/lib/listen/queue_optimizer.rb +0 -129
- data/vendor/deps/listen/lib/listen/record/entry.rb +0 -66
- data/vendor/deps/listen/lib/listen/record/symlink_detector.rb +0 -47
- data/vendor/deps/listen/lib/listen/record.rb +0 -122
- data/vendor/deps/listen/lib/listen/silencer/controller.rb +0 -50
- data/vendor/deps/listen/lib/listen/silencer.rb +0 -106
- data/vendor/deps/listen/lib/listen/thread.rb +0 -54
- data/vendor/deps/listen/lib/listen/version.rb +0 -5
- data/vendor/deps/listen/lib/listen.rb +0 -47
- data/vendor/deps/listen/listen.gemspec +0 -40
- data/vendor/deps/listen/spec/acceptance/listen_spec.rb +0 -320
- data/vendor/deps/listen/spec/lib/listen/adapter/base_spec.rb +0 -101
- data/vendor/deps/listen/spec/lib/listen/adapter/bsd_spec.rb +0 -13
- data/vendor/deps/listen/spec/lib/listen/adapter/config_spec.rb +0 -122
- data/vendor/deps/listen/spec/lib/listen/adapter/darwin_spec.rb +0 -82
- data/vendor/deps/listen/spec/lib/listen/adapter/linux_spec.rb +0 -199
- data/vendor/deps/listen/spec/lib/listen/adapter/polling_spec.rb +0 -83
- data/vendor/deps/listen/spec/lib/listen/adapter/windows_spec.rb +0 -13
- data/vendor/deps/listen/spec/lib/listen/adapter_spec.rb +0 -69
- data/vendor/deps/listen/spec/lib/listen/backend_spec.rb +0 -82
- data/vendor/deps/listen/spec/lib/listen/change_spec.rb +0 -102
- data/vendor/deps/listen/spec/lib/listen/cli_spec.rb +0 -116
- data/vendor/deps/listen/spec/lib/listen/directory_spec.rb +0 -284
- data/vendor/deps/listen/spec/lib/listen/event/config_spec.rb +0 -33
- data/vendor/deps/listen/spec/lib/listen/event/loop_spec.rb +0 -118
- data/vendor/deps/listen/spec/lib/listen/event/processor_spec.rb +0 -250
- data/vendor/deps/listen/spec/lib/listen/event/queue_spec.rb +0 -118
- data/vendor/deps/listen/spec/lib/listen/file_spec.rb +0 -254
- data/vendor/deps/listen/spec/lib/listen/fsm_spec.rb +0 -147
- data/vendor/deps/listen/spec/lib/listen/listener/config_spec.rb +0 -29
- data/vendor/deps/listen/spec/lib/listen/listener_spec.rb +0 -321
- data/vendor/deps/listen/spec/lib/listen/logger_spec.rb +0 -212
- data/vendor/deps/listen/spec/lib/listen/monotonic_time_spec.rb +0 -58
- data/vendor/deps/listen/spec/lib/listen/queue_optimizer_spec.rb +0 -111
- data/vendor/deps/listen/spec/lib/listen/record_spec.rb +0 -424
- data/vendor/deps/listen/spec/lib/listen/silencer/controller_spec.rb +0 -97
- data/vendor/deps/listen/spec/lib/listen/silencer_spec.rb +0 -109
- data/vendor/deps/listen/spec/lib/listen/thread_spec.rb +0 -133
- data/vendor/deps/listen/spec/lib/listen_spec.rb +0 -25
- data/vendor/deps/listen/spec/spec_helper.rb +0 -49
- data/vendor/deps/listen/spec/support/acceptance_helper.rb +0 -260
- data/vendor/deps/listen/spec/support/fixtures_helper.rb +0 -32
- data/vendor/deps/listen/spec/support/platform_helper.rb +0 -17
- data/vendor/deps/observer/.github/dependabot.yml +0 -6
- data/vendor/deps/observer/.github/workflows/test.yml +0 -33
- data/vendor/deps/observer/.gitignore +0 -8
- data/vendor/deps/observer/BSDL +0 -22
- data/vendor/deps/observer/COPYING +0 -56
- data/vendor/deps/observer/Gemfile +0 -9
- data/vendor/deps/observer/README.md +0 -139
- data/vendor/deps/observer/Rakefile +0 -10
- data/vendor/deps/observer/bin/console +0 -14
- data/vendor/deps/observer/bin/setup +0 -8
- data/vendor/deps/observer/lib/observer.rb +0 -229
- data/vendor/deps/observer/observer.gemspec +0 -32
- data/vendor/deps/observer/test/test_observer.rb +0 -66
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
include Listen
|
|
4
|
-
|
|
5
|
-
RSpec.describe Listener do
|
|
6
|
-
let(:realdir1) { fake_path('/foo/dir1', children: []) }
|
|
7
|
-
let(:realdir2) { fake_path('/foo/dir2', children: []) }
|
|
8
|
-
|
|
9
|
-
let(:dir1) { fake_path('dir1', realpath: realdir1) }
|
|
10
|
-
let(:dir2) { fake_path('dir2', realpath: realdir2) }
|
|
11
|
-
|
|
12
|
-
let(:dirs) { ['dir1'] }
|
|
13
|
-
|
|
14
|
-
let(:block) { instance_double(Proc) }
|
|
15
|
-
|
|
16
|
-
subject do
|
|
17
|
-
described_class.new(*(dirs + [options]).compact) do |*changes|
|
|
18
|
-
block.call(*changes)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
let(:options) { {} }
|
|
23
|
-
|
|
24
|
-
let(:record) { instance_double(Record, build: true, root: 'dir2') }
|
|
25
|
-
let(:silencer) { instance_double(Silencer, configure: nil) }
|
|
26
|
-
|
|
27
|
-
let(:backend_class) { class_double('Listen::Backend') }
|
|
28
|
-
|
|
29
|
-
let(:backend) { instance_double(Backend) }
|
|
30
|
-
|
|
31
|
-
let(:optimizer_config) { instance_double(QueueOptimizer::Config) }
|
|
32
|
-
let(:optimizer) { instance_double(QueueOptimizer) }
|
|
33
|
-
|
|
34
|
-
let(:processor_config) { instance_double(Event::Config) }
|
|
35
|
-
let(:processor) { instance_double(Event::Loop) }
|
|
36
|
-
|
|
37
|
-
let(:event_queue) { instance_double(Event::Queue) }
|
|
38
|
-
|
|
39
|
-
let(:default_latency) { 0.1 }
|
|
40
|
-
let(:backend_wait_for_delay) { 0.123 }
|
|
41
|
-
|
|
42
|
-
let(:processing_thread) { instance_double(Thread) }
|
|
43
|
-
|
|
44
|
-
before do
|
|
45
|
-
allow(Silencer).to receive(:new) { silencer }
|
|
46
|
-
|
|
47
|
-
allow(Backend).to receive(:new).
|
|
48
|
-
with(anything, event_queue, silencer, anything).
|
|
49
|
-
and_return(backend)
|
|
50
|
-
|
|
51
|
-
allow(backend).to receive(:min_delay_between_events).
|
|
52
|
-
and_return(backend_wait_for_delay)
|
|
53
|
-
|
|
54
|
-
# TODO: use a configuration object to clean this up
|
|
55
|
-
|
|
56
|
-
allow(QueueOptimizer::Config).to receive(:new).with(backend, silencer).
|
|
57
|
-
and_return(optimizer_config)
|
|
58
|
-
|
|
59
|
-
allow(QueueOptimizer).to receive(:new).with(optimizer_config).
|
|
60
|
-
and_return(optimizer)
|
|
61
|
-
|
|
62
|
-
allow(Event::Queue).to receive(:new).and_return(event_queue)
|
|
63
|
-
|
|
64
|
-
allow(Event::Config).to receive(:new).
|
|
65
|
-
with(anything, event_queue, optimizer, backend_wait_for_delay).
|
|
66
|
-
and_return(processor_config)
|
|
67
|
-
|
|
68
|
-
allow(Event::Loop).to receive(:new).with(processor_config).
|
|
69
|
-
and_return(processor)
|
|
70
|
-
|
|
71
|
-
allow(Record).to receive(:new).and_return(record)
|
|
72
|
-
|
|
73
|
-
allow(Pathname).to receive(:new).with('dir1').and_return(dir1)
|
|
74
|
-
allow(Pathname).to receive(:new).with('dir2').and_return(dir2)
|
|
75
|
-
|
|
76
|
-
allow(Thread).to receive(:new).and_return(processing_thread)
|
|
77
|
-
allow(processing_thread).to receive(:alive?).and_return(true)
|
|
78
|
-
allow(processing_thread).to receive(:wakeup)
|
|
79
|
-
allow(processing_thread).to receive(:join)
|
|
80
|
-
|
|
81
|
-
allow(block).to receive(:call)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe 'initialize' do
|
|
85
|
-
it { should_not be_paused }
|
|
86
|
-
|
|
87
|
-
context 'with a block' do
|
|
88
|
-
let(:myblock) { instance_double(Proc) }
|
|
89
|
-
let(:block) { proc { myblock.call } }
|
|
90
|
-
subject do
|
|
91
|
-
described_class.new('dir1') do |*args|
|
|
92
|
-
myblock.call(*args)
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it 'passes the block to the event processor' do
|
|
97
|
-
allow(Event::Config).to receive(:new) do |*_args, &some_block|
|
|
98
|
-
expect(some_block).to be
|
|
99
|
-
some_block.call
|
|
100
|
-
processor_config
|
|
101
|
-
end
|
|
102
|
-
expect(myblock).to receive(:call)
|
|
103
|
-
subject
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context 'with directories' do
|
|
108
|
-
subject { described_class.new('dir1', 'dir2') }
|
|
109
|
-
|
|
110
|
-
it 'passes directories to backend' do
|
|
111
|
-
allow(Backend).to receive(:new).
|
|
112
|
-
with(%w[dir1 dir2], anything, anything, anything).
|
|
113
|
-
and_return(backend)
|
|
114
|
-
subject
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe '#start' do
|
|
120
|
-
before do
|
|
121
|
-
allow(backend).to receive(:start)
|
|
122
|
-
allow(silencer).to receive(:silenced?) { false }
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it 'sets paused to false' do
|
|
126
|
-
allow(processor).to receive(:start)
|
|
127
|
-
subject.start
|
|
128
|
-
expect(subject).to_not be_paused
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it 'starts adapter' do
|
|
132
|
-
expect(backend).to receive(:start)
|
|
133
|
-
allow(processor).to receive(:start)
|
|
134
|
-
subject.start
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
describe '#stop' do
|
|
139
|
-
before do
|
|
140
|
-
allow(backend).to receive(:start)
|
|
141
|
-
allow(processor).to receive(:start)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
context 'when fully started' do
|
|
145
|
-
before do
|
|
146
|
-
subject.start
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it 'terminates' do
|
|
150
|
-
allow(backend).to receive(:stop)
|
|
151
|
-
allow(processor).to receive(:stop)
|
|
152
|
-
subject.stop
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
context 'when only initialized' do
|
|
157
|
-
before do
|
|
158
|
-
subject
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
it 'terminates' do
|
|
162
|
-
allow(backend).to receive(:stop)
|
|
163
|
-
allow(processor).to receive(:stop)
|
|
164
|
-
subject.stop
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
describe '#pause' do
|
|
170
|
-
before do
|
|
171
|
-
allow(backend).to receive(:start)
|
|
172
|
-
allow(processor).to receive(:start)
|
|
173
|
-
subject.start
|
|
174
|
-
end
|
|
175
|
-
it 'sets paused to true' do
|
|
176
|
-
allow(processor).to receive(:pause)
|
|
177
|
-
subject.pause
|
|
178
|
-
expect(subject).to be_paused
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
describe 'unpause with start' do
|
|
183
|
-
before do
|
|
184
|
-
allow(backend).to receive(:start)
|
|
185
|
-
allow(processor).to receive(:start)
|
|
186
|
-
subject.start
|
|
187
|
-
allow(processor).to receive(:pause)
|
|
188
|
-
subject.pause
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it 'sets paused to false' do
|
|
192
|
-
subject.start
|
|
193
|
-
expect(subject).to_not be_paused
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
describe '#paused?' do
|
|
198
|
-
before do
|
|
199
|
-
allow(backend).to receive(:start)
|
|
200
|
-
allow(processor).to receive(:start)
|
|
201
|
-
subject.start
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it 'returns true when paused' do
|
|
205
|
-
allow(processor).to receive(:pause)
|
|
206
|
-
subject.pause
|
|
207
|
-
expect(subject).to be_paused
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
it 'returns false when not paused' do
|
|
211
|
-
expect(subject).not_to be_paused
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
describe '#listen?' do
|
|
216
|
-
context 'when processing' do
|
|
217
|
-
before do
|
|
218
|
-
allow(backend).to receive(:start)
|
|
219
|
-
allow(processor).to receive(:start)
|
|
220
|
-
subject.start
|
|
221
|
-
end
|
|
222
|
-
it { should be_processing }
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
context 'when stopped' do
|
|
226
|
-
it { should_not be_processing }
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
context 'when paused' do
|
|
230
|
-
before do
|
|
231
|
-
allow(backend).to receive(:start)
|
|
232
|
-
allow(processor).to receive(:start)
|
|
233
|
-
subject.start
|
|
234
|
-
allow(processor).to receive(:pause)
|
|
235
|
-
subject.pause
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
it { should_not be_processing }
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
# TODO: move these to silencer_controller?
|
|
243
|
-
describe '#ignore' do
|
|
244
|
-
context 'with existing ignore options' do
|
|
245
|
-
let(:options) { { ignore: /bar/ } }
|
|
246
|
-
|
|
247
|
-
it 'adds up to existing ignore options' do
|
|
248
|
-
expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
|
|
249
|
-
|
|
250
|
-
subject
|
|
251
|
-
|
|
252
|
-
expect(silencer).to receive(:configure).once.
|
|
253
|
-
with({ ignore: [/bar/, /foo/] })
|
|
254
|
-
|
|
255
|
-
subject.ignore(/foo/)
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
context 'with existing ignore options (array)' do
|
|
260
|
-
let(:options) { { ignore: [/bar/] } }
|
|
261
|
-
|
|
262
|
-
it 'adds up to existing ignore options' do
|
|
263
|
-
expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
|
|
264
|
-
|
|
265
|
-
subject
|
|
266
|
-
|
|
267
|
-
expect(silencer).to receive(:configure).once.
|
|
268
|
-
with({ ignore: [/bar/, /foo/] })
|
|
269
|
-
|
|
270
|
-
subject.ignore(/foo/)
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
# TODO: move these to silencer_controller?
|
|
276
|
-
describe '#ignore!' do
|
|
277
|
-
context 'with no existing options' do
|
|
278
|
-
let(:options) { {} }
|
|
279
|
-
|
|
280
|
-
it 'sets options' do
|
|
281
|
-
expect(silencer).to receive(:configure).with(options)
|
|
282
|
-
subject
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
context 'with existing ignore! options' do
|
|
287
|
-
let(:options) { { ignore!: /bar/ } }
|
|
288
|
-
|
|
289
|
-
it 'overwrites existing ignore options' do
|
|
290
|
-
expect(silencer).to receive(:configure).once.with({ ignore!: [/bar/] })
|
|
291
|
-
subject
|
|
292
|
-
expect(silencer).to receive(:configure).once.with({ ignore!: [/foo/] })
|
|
293
|
-
subject.ignore!([/foo/])
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
context 'with existing ignore options' do
|
|
298
|
-
let(:options) { { ignore: /bar/ } }
|
|
299
|
-
|
|
300
|
-
it 'deletes ignore options' do
|
|
301
|
-
expect(silencer).to receive(:configure).once.with({ ignore: [/bar/] })
|
|
302
|
-
subject
|
|
303
|
-
expect(silencer).to receive(:configure).once.with({ ignore!: [/foo/] })
|
|
304
|
-
subject.ignore!([/foo/])
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
describe '#only' do
|
|
310
|
-
context 'with existing only options' do
|
|
311
|
-
let(:options) { { only: /bar/ } }
|
|
312
|
-
|
|
313
|
-
it 'overwrites existing ignore options' do
|
|
314
|
-
expect(silencer).to receive(:configure).once.with({ only: [/bar/] })
|
|
315
|
-
subject
|
|
316
|
-
expect(silencer).to receive(:configure).once.with({ only: [/foo/] })
|
|
317
|
-
subject.only([/foo/])
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
end
|
|
321
|
-
end
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'listen/logger'
|
|
4
|
-
|
|
5
|
-
RSpec.describe 'logger.rb' do
|
|
6
|
-
around do |spec|
|
|
7
|
-
orig_logger = Listen.instance_variable_get(:@logger)
|
|
8
|
-
|
|
9
|
-
spec.run
|
|
10
|
-
|
|
11
|
-
Listen.logger = orig_logger
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe 'Listen.logger' do
|
|
15
|
-
ENV_VARIABLE_NAME = 'LISTEN_GEM_DEBUGGING'
|
|
16
|
-
|
|
17
|
-
let(:logger) { instance_double(::Logger, "logger") }
|
|
18
|
-
|
|
19
|
-
around do |spec|
|
|
20
|
-
orig_debugging_env_variable = ENV.fetch(ENV_VARIABLE_NAME, :not_set)
|
|
21
|
-
|
|
22
|
-
spec.run
|
|
23
|
-
|
|
24
|
-
if orig_debugging_env_variable == :not_set
|
|
25
|
-
ENV.delete(ENV_VARIABLE_NAME)
|
|
26
|
-
else
|
|
27
|
-
ENV[ENV_VARIABLE_NAME] = orig_debugging_env_variable
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe 'logger=' do
|
|
32
|
-
it 'allows the logger to be set' do
|
|
33
|
-
Listen.logger = logger
|
|
34
|
-
expect(Listen.logger).to be(logger)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'allows nil to be set (implying default logger)' do
|
|
38
|
-
Listen.logger = nil
|
|
39
|
-
expect(Listen.logger).to be_kind_of(::Logger)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
describe 'logger' do
|
|
44
|
-
before do
|
|
45
|
-
Listen.instance_variable_set(:@logger, nil)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'returns default logger if none set' do
|
|
49
|
-
expect(Listen.logger).to be_kind_of(::Logger)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
['debug', 'DEBUG', '2', 'level2', '2 '].each do |env_value|
|
|
53
|
-
it "infers DEBUG level from #{ENV_VARIABLE_NAME}=#{env_value.inspect}" do
|
|
54
|
-
ENV[ENV_VARIABLE_NAME] = env_value
|
|
55
|
-
expect(Listen.logger.level).to eq(::Logger::DEBUG)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
['info', 'INFO', 'true', ' true', 'TRUE', 'TRUE ', 'yes', 'YES', ' yesss!', '1', 'level1'].each do |env_value|
|
|
60
|
-
it "infers INFO level from #{ENV_VARIABLE_NAME}=#{env_value.inspect}" do
|
|
61
|
-
ENV[ENV_VARIABLE_NAME] = env_value
|
|
62
|
-
expect(Listen.logger.level).to eq(::Logger::INFO)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
['warn', 'WARN', ' warn', 'warning'].each do |env_value|
|
|
67
|
-
it "infers WARN level from #{ENV_VARIABLE_NAME}=#{env_value.inspect}" do
|
|
68
|
-
ENV[ENV_VARIABLE_NAME] = env_value
|
|
69
|
-
expect(Listen.logger.level).to eq(::Logger::WARN)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
['error', 'ERROR', 'OTHER'].each do |env_value|
|
|
74
|
-
it "infers ERROR level from #{ENV_VARIABLE_NAME}=#{env_value.inspect}" do
|
|
75
|
-
ENV[ENV_VARIABLE_NAME] = env_value
|
|
76
|
-
expect(Listen.logger.level).to eq(::Logger::ERROR)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
['fatal', 'FATAL', ' fatal'].each do |env_value|
|
|
81
|
-
it "infers FATAL level from #{ENV_VARIABLE_NAME}=#{env_value.inspect}" do
|
|
82
|
-
ENV[ENV_VARIABLE_NAME] = env_value
|
|
83
|
-
expect(Listen.logger.level).to eq(::Logger::FATAL)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
describe 'Listen.adapter_warn_behavior' do
|
|
90
|
-
subject { Listen.adapter_warn(message) }
|
|
91
|
-
|
|
92
|
-
after do
|
|
93
|
-
Listen.adapter_warn_behavior = :warn
|
|
94
|
-
end
|
|
95
|
-
let(:message) { "warning message" }
|
|
96
|
-
|
|
97
|
-
it 'defaults to :warn' do
|
|
98
|
-
expect(Listen.adapter_warn_behavior).to eq(:warn)
|
|
99
|
-
|
|
100
|
-
expect(Listen).to receive(:warn).with(message)
|
|
101
|
-
|
|
102
|
-
subject
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'allows the adapter_warn_behavior to be set to :log' do
|
|
106
|
-
Listen.adapter_warn_behavior = :log
|
|
107
|
-
|
|
108
|
-
expect(Listen.logger).to receive(:warn).with(message)
|
|
109
|
-
|
|
110
|
-
subject
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
[:silent, nil, false].each do |behavior|
|
|
114
|
-
it "allows the adapter_warn_behavior to be set to #{behavior} to silence the warnings" do
|
|
115
|
-
Listen.adapter_warn_behavior = behavior
|
|
116
|
-
|
|
117
|
-
expect(Listen.logger).not_to receive(:warn)
|
|
118
|
-
expect(Listen).not_to receive(:warn)
|
|
119
|
-
|
|
120
|
-
subject
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context "when LISTEN_GEM_ADAPTER_WARN_BEHAVIOR is set to 'log'" do
|
|
125
|
-
around do |spec|
|
|
126
|
-
orig_debugging_env_variable = ENV.fetch('LISTEN_GEM_ADAPTER_WARN_BEHAVIOR', :not_set)
|
|
127
|
-
|
|
128
|
-
ENV['LISTEN_GEM_ADAPTER_WARN_BEHAVIOR'] = 'log'
|
|
129
|
-
|
|
130
|
-
spec.run
|
|
131
|
-
|
|
132
|
-
if orig_debugging_env_variable == :not_set
|
|
133
|
-
ENV.delete('LISTEN_GEM_ADAPTER_WARN_BEHAVIOR')
|
|
134
|
-
else
|
|
135
|
-
ENV['ENV_VARIABLE_NAME'] = orig_debugging_env_variable
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
[:silent, nil, false, :warn].each do |behavior|
|
|
140
|
-
it "respects the environment variable over #{behavior.inspect}" do
|
|
141
|
-
Listen.adapter_warn_behavior = behavior
|
|
142
|
-
|
|
143
|
-
expect(Listen.logger).to receive(:warn).with(message)
|
|
144
|
-
|
|
145
|
-
subject
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it "respects the environment variable over a callable config" do
|
|
150
|
-
Listen.adapter_warn_behavior = ->(_message) { :warn }
|
|
151
|
-
|
|
152
|
-
expect(Listen.logger).to receive(:warn).with(message)
|
|
153
|
-
|
|
154
|
-
subject
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
context 'when adapter_warn_behavior is set to a callable object like a proc' do
|
|
159
|
-
before do
|
|
160
|
-
Listen.adapter_warn_behavior = ->(message) do
|
|
161
|
-
case message
|
|
162
|
-
when /USE warn/
|
|
163
|
-
:warn
|
|
164
|
-
when /USE log/
|
|
165
|
-
:log
|
|
166
|
-
when /USE silent/
|
|
167
|
-
:silent
|
|
168
|
-
when /USE false/
|
|
169
|
-
false
|
|
170
|
-
when /USE nil/
|
|
171
|
-
nil
|
|
172
|
-
else
|
|
173
|
-
true
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
[true, :warn].each do |behavior|
|
|
179
|
-
context "when the message matches a #{behavior.inspect} pattern" do
|
|
180
|
-
let(:message) { "USE #{behavior.inspect}" }
|
|
181
|
-
it 'respects :warn' do
|
|
182
|
-
expect(Listen).to receive(:warn).with(message)
|
|
183
|
-
|
|
184
|
-
subject
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
context 'when the message matches a :silent pattern' do
|
|
190
|
-
let(:message) { "USE silent" }
|
|
191
|
-
it 'respects :silent' do
|
|
192
|
-
expect(Listen).not_to receive(:warn).with(message)
|
|
193
|
-
expect(Listen).not_to receive(:warn)
|
|
194
|
-
|
|
195
|
-
subject
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
[false, nil].each do |behavior|
|
|
200
|
-
context "when the message matches a #{behavior} pattern" do
|
|
201
|
-
let(:message) { "USE #{behavior.inspect}" }
|
|
202
|
-
it 'respects :silent' do
|
|
203
|
-
expect(Listen).not_to receive(:warn).with(message)
|
|
204
|
-
expect(Listen).not_to receive(:warn)
|
|
205
|
-
|
|
206
|
-
subject
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'listen/monotonic_time'
|
|
4
|
-
|
|
5
|
-
RSpec.describe Listen::MonotonicTime do
|
|
6
|
-
after(:all) do
|
|
7
|
-
# load once more with constants unstubbed/unhidden
|
|
8
|
-
load './lib/listen/monotonic_time.rb'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
context 'module methods' do
|
|
12
|
-
describe '.now' do
|
|
13
|
-
subject { described_class.now }
|
|
14
|
-
let(:tick_count) { 0.123 }
|
|
15
|
-
|
|
16
|
-
context 'when CLOCK_MONOTONIC defined' do
|
|
17
|
-
before do
|
|
18
|
-
stub_const('Process::CLOCK_MONOTONIC', 10)
|
|
19
|
-
load './lib/listen/monotonic_time.rb'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it 'returns the CLOCK_MONOTONIC tick count' do
|
|
23
|
-
expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC).and_return(tick_count)
|
|
24
|
-
expect(subject).to eq(tick_count)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context 'when CLOCK_MONOTONIC not defined but CLOCK_MONOTONIC_RAW defined' do
|
|
29
|
-
before do
|
|
30
|
-
hide_const('Process::CLOCK_MONOTONIC')
|
|
31
|
-
stub_const('Process::CLOCK_MONOTONIC_RAW', 11)
|
|
32
|
-
load './lib/listen/monotonic_time.rb'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'returns the floating point Time.now' do
|
|
36
|
-
expect(Process).to receive(:clock_gettime).with(Process::CLOCK_MONOTONIC_RAW).and_return(tick_count)
|
|
37
|
-
expect(subject).to eq(tick_count)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context 'when neither CLOCK_MONOTONIC nor CLOCK_MONOTONIC_RAW defined' do
|
|
42
|
-
let(:now) { instance_double(Time, "time") }
|
|
43
|
-
|
|
44
|
-
before do
|
|
45
|
-
hide_const('Process::CLOCK_MONOTONIC')
|
|
46
|
-
hide_const('Process::CLOCK_MONOTONIC_RAW')
|
|
47
|
-
load './lib/listen/monotonic_time.rb'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'returns the floating point Time.now' do
|
|
51
|
-
expect(Time).to receive(:now).and_return(now)
|
|
52
|
-
expect(now).to receive(:to_f).and_return(tick_count)
|
|
53
|
-
expect(subject).to eq(tick_count)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Listen::QueueOptimizer do
|
|
4
|
-
let(:config) { instance_double(Listen::QueueOptimizer::Config) }
|
|
5
|
-
subject { described_class.new(config) }
|
|
6
|
-
|
|
7
|
-
# watched dir
|
|
8
|
-
let(:dir) { fake_path('dir') }
|
|
9
|
-
|
|
10
|
-
# files
|
|
11
|
-
let(:foo) { fake_path('foo') }
|
|
12
|
-
let(:bar) { fake_path('bar') }
|
|
13
|
-
let(:ignored) { fake_path('ignored') }
|
|
14
|
-
|
|
15
|
-
before do
|
|
16
|
-
allow(config).to receive(:debug)
|
|
17
|
-
|
|
18
|
-
allow(dir).to receive(:+).with('foo') { foo }
|
|
19
|
-
allow(dir).to receive(:+).with('bar') { bar }
|
|
20
|
-
allow(dir).to receive(:+).with('ignored') { ignored }
|
|
21
|
-
|
|
22
|
-
allow(config).to receive(:silenced?).
|
|
23
|
-
with(Pathname('ignored'), :file) { true }
|
|
24
|
-
|
|
25
|
-
allow(config).to receive(:silenced?).
|
|
26
|
-
with(Pathname('foo'), :file) { false }
|
|
27
|
-
|
|
28
|
-
allow(config).to receive(:silenced?).
|
|
29
|
-
with(Pathname('bar'), :file) { false }
|
|
30
|
-
|
|
31
|
-
allow(config).to receive(:exist?).with(foo).and_return(true)
|
|
32
|
-
allow(config).to receive(:exist?).with(bar).and_return(true)
|
|
33
|
-
allow(config).to receive(:exist?).with(ignored).and_return(true)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe 'smoosh_changes' do
|
|
37
|
-
subject { described_class.new(config).smoosh_changes(changes) }
|
|
38
|
-
|
|
39
|
-
context 'with rename from temp file' do
|
|
40
|
-
let(:changes) do
|
|
41
|
-
[
|
|
42
|
-
[:file, :modified, dir, 'foo'],
|
|
43
|
-
[:file, :removed, dir, 'foo'],
|
|
44
|
-
[:file, :added, dir, 'foo'],
|
|
45
|
-
[:file, :modified, dir, 'foo']
|
|
46
|
-
]
|
|
47
|
-
end
|
|
48
|
-
it { is_expected.to eq(modified: ['foo'], added: [], removed: []) }
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context 'with a detected temp file' do
|
|
52
|
-
before { allow(config).to receive(:exist?).with(foo).and_return(false) }
|
|
53
|
-
|
|
54
|
-
let(:changes) do
|
|
55
|
-
[
|
|
56
|
-
[:file, :added, dir, 'foo'],
|
|
57
|
-
[:file, :modified, dir, 'foo'],
|
|
58
|
-
[:file, :removed, dir, 'foo'],
|
|
59
|
-
[:file, :modified, dir, 'foo']
|
|
60
|
-
]
|
|
61
|
-
end
|
|
62
|
-
it { is_expected.to eq(modified: [], added: [], removed: []) }
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# e.g. "mv foo x && mv x foo" is like "touch foo"
|
|
66
|
-
context 'when double move' do
|
|
67
|
-
let(:changes) do
|
|
68
|
-
[
|
|
69
|
-
[:file, :removed, dir, 'foo'],
|
|
70
|
-
[:file, :added, dir, 'foo']
|
|
71
|
-
]
|
|
72
|
-
end
|
|
73
|
-
it { is_expected.to eq(modified: ['foo'], added: [], removed: []) }
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
context 'with cookie' do
|
|
77
|
-
context 'when single moved' do
|
|
78
|
-
let(:changes) { [[:file, :moved_to, dir, 'foo', { cookie: 4321 }]] }
|
|
79
|
-
it { is_expected.to eq(modified: [], added: ['foo'], removed: []) }
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context 'when related moved_to' do
|
|
83
|
-
let(:changes) do
|
|
84
|
-
[
|
|
85
|
-
[:file, :moved_from, dir, 'foo', { cookie: 4321 }],
|
|
86
|
-
[:file, :moved_to, dir, 'bar', { cookie: 4321 }]
|
|
87
|
-
]
|
|
88
|
-
end
|
|
89
|
-
it { is_expected.to eq(modified: [], added: ['bar'], removed: []) }
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Scenario with workaround for editors using rename()
|
|
93
|
-
context 'when related moved_to with ignored moved_from' do
|
|
94
|
-
let(:changes) do
|
|
95
|
-
[
|
|
96
|
-
[:file, :moved_from, dir, 'ignored', { cookie: 4321 }],
|
|
97
|
-
[:file, :moved_to, dir, 'foo', { cookie: 4321 }]
|
|
98
|
-
]
|
|
99
|
-
end
|
|
100
|
-
it { is_expected.to eq(modified: ['foo'], added: [], removed: []) }
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
context 'with no cookie' do
|
|
105
|
-
context 'with ignored file' do
|
|
106
|
-
let(:changes) { [[:file, :modified, dir, 'ignored']] }
|
|
107
|
-
it { is_expected.to eq(modified: [], added: [], removed: []) }
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|