fluid_cli 0.1.4 → 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
- data/packaging/homebrew/fluid_cli.base.rb +5 -9
- metadata +30 -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,199 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Listen::Adapter::Linux do
|
|
4
|
-
describe 'class methods' do
|
|
5
|
-
subject { described_class }
|
|
6
|
-
|
|
7
|
-
if linux?
|
|
8
|
-
it { should be_usable }
|
|
9
|
-
else
|
|
10
|
-
it { should_not be_usable }
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
if linux?
|
|
15
|
-
describe 'instance methods' do
|
|
16
|
-
before(:all) do
|
|
17
|
-
require 'rb-inotify'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
let(:dir1) { Pathname.new("/foo/dir1") }
|
|
21
|
-
|
|
22
|
-
let(:queue) { instance_double(Queue, "queue", close: nil) }
|
|
23
|
-
let(:config) { instance_double(Listen::Adapter::Config, "config", queue: queue) }
|
|
24
|
-
let(:silencer) { instance_double(Listen::Silencer, "silencer") }
|
|
25
|
-
let(:snapshot) { instance_double(Listen::Change, "snapshot") }
|
|
26
|
-
let(:record) { instance_double(Listen::Record, "record") }
|
|
27
|
-
|
|
28
|
-
# TODO: fix other adapters too!
|
|
29
|
-
subject { described_class.new(config) }
|
|
30
|
-
|
|
31
|
-
after do
|
|
32
|
-
subject.stop
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe 'watch events' do
|
|
36
|
-
let(:directories) { [Pathname.pwd] }
|
|
37
|
-
let(:adapter_options) { {} }
|
|
38
|
-
let(:default_events) { [:recursive, :attrib, :create, :modify, :delete, :move, :close_write] }
|
|
39
|
-
let(:fake_worker) { double(:fake_worker_for_watch_events) }
|
|
40
|
-
let(:fake_notifier) { double(:fake_notifier, new: fake_worker) }
|
|
41
|
-
|
|
42
|
-
before do
|
|
43
|
-
stub_const('INotify::Notifier', fake_notifier)
|
|
44
|
-
|
|
45
|
-
allow(config).to receive(:directories).and_return(directories)
|
|
46
|
-
allow(config).to receive(:adapter_options).and_return(adapter_options)
|
|
47
|
-
allow(config).to receive(:silencer).and_return(silencer)
|
|
48
|
-
allow(fake_worker).to receive(:close)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
after do
|
|
52
|
-
subject.stop
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'starts by calling watch with default events' do
|
|
56
|
-
expect(fake_worker).to receive(:watch).with(*directories.map(&:to_s), *default_events)
|
|
57
|
-
subject.start
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe 'inotify max watches exceeded' do
|
|
62
|
-
let(:directories) { [Pathname.pwd] }
|
|
63
|
-
let(:adapter_options) { {} }
|
|
64
|
-
|
|
65
|
-
before do
|
|
66
|
-
fake_worker = double(:fake_worker_for_inotify_limit_message)
|
|
67
|
-
allow(fake_worker).to receive(:watch).and_raise(Errno::ENOSPC)
|
|
68
|
-
allow(fake_worker).to receive(:close)
|
|
69
|
-
|
|
70
|
-
fake_notifier = double(:fake_notifier, new: fake_worker)
|
|
71
|
-
stub_const('INotify::Notifier', fake_notifier)
|
|
72
|
-
|
|
73
|
-
allow(config).to receive(:directories).and_return(directories)
|
|
74
|
-
allow(config).to receive(:adapter_options).and_return(adapter_options)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'raises exception' do
|
|
78
|
-
expect { subject.start }.to raise_exception(Listen::Error::INotifyMaxWatchesExceeded, /inotify max watches exceeded/i)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# TODO: should probably be adapted to be more like adapter/base_spec.rb
|
|
83
|
-
describe '_callback' do
|
|
84
|
-
let(:directories) { [dir1] }
|
|
85
|
-
let(:adapter_options) { { events: [:recursive, :close_write] } }
|
|
86
|
-
|
|
87
|
-
before do
|
|
88
|
-
fake_worker = double(:fake_worker_for_callback)
|
|
89
|
-
events = [:recursive, :close_write]
|
|
90
|
-
allow(fake_worker).to receive(:watch).with('/foo/dir1', *events)
|
|
91
|
-
allow(fake_worker).to receive(:close)
|
|
92
|
-
|
|
93
|
-
fake_notifier = double(:fake_notifier, new: fake_worker)
|
|
94
|
-
stub_const('INotify::Notifier', fake_notifier)
|
|
95
|
-
|
|
96
|
-
allow(config).to receive(:directories).and_return(directories)
|
|
97
|
-
allow(config).to receive(:adapter_options).and_return(adapter_options)
|
|
98
|
-
allow(config).to receive(:silencer).and_return(silencer)
|
|
99
|
-
|
|
100
|
-
allow(Listen::Record).to receive(:new).with(dir1, silencer).and_return(record)
|
|
101
|
-
allow(Listen::Change::Config).to receive(:new).with(queue, silencer).
|
|
102
|
-
and_return(config)
|
|
103
|
-
allow(Listen::Change).to receive(:new).with(config, record).
|
|
104
|
-
and_return(snapshot)
|
|
105
|
-
|
|
106
|
-
allow(subject).to receive(:require).with('rb-inotify')
|
|
107
|
-
subject.configure
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
let(:expect_change) do
|
|
111
|
-
lambda do |change|
|
|
112
|
-
expect(snapshot).to receive(:invalidate).with(
|
|
113
|
-
:file,
|
|
114
|
-
'path/foo.txt',
|
|
115
|
-
{
|
|
116
|
-
cookie: 123,
|
|
117
|
-
change: change
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
let(:event_callback) do
|
|
124
|
-
lambda do |flags|
|
|
125
|
-
callbacks = subject.instance_variable_get(:'@callbacks')
|
|
126
|
-
callbacks.values.flatten.each do |callback|
|
|
127
|
-
callback.call double(
|
|
128
|
-
:inotify_event,
|
|
129
|
-
name: 'foo.txt',
|
|
130
|
-
watcher: double(:watcher, path: '/foo/dir1/path'),
|
|
131
|
-
flags: flags,
|
|
132
|
-
cookie: 123)
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
# TODO: get fsevent adapter working like INotify
|
|
138
|
-
unless /1|true/ =~ ENV['LISTEN_GEM_SIMULATE_FSEVENT']
|
|
139
|
-
it 'recognizes close_write as modify' do
|
|
140
|
-
expect_change.call(:modified)
|
|
141
|
-
event_callback.call([:close_write])
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it 'recognizes moved_to as moved_to' do
|
|
145
|
-
expect_change.call(:moved_to)
|
|
146
|
-
event_callback.call([:moved_to])
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it 'recognizes moved_from as moved_from' do
|
|
150
|
-
expect_change.call(:moved_from)
|
|
151
|
-
event_callback.call([:moved_from])
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
describe '#stop' do
|
|
157
|
-
let(:fake_worker) { double(:fake_worker_for_stop, close: true) }
|
|
158
|
-
let(:directories) { [dir1] }
|
|
159
|
-
let(:adapter_options) { { events: [:recursive, :close_write] } }
|
|
160
|
-
|
|
161
|
-
before do
|
|
162
|
-
allow(config).to receive(:directories).and_return(directories)
|
|
163
|
-
allow(config).to receive(:adapter_options).and_return(adapter_options)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
context 'when configured' do
|
|
167
|
-
before do
|
|
168
|
-
events = [:recursive, :close_write]
|
|
169
|
-
allow(fake_worker).to receive(:watch).with('/foo/dir1', *events)
|
|
170
|
-
|
|
171
|
-
fake_notifier = double(:fake_notifier, new: fake_worker)
|
|
172
|
-
stub_const('INotify::Notifier', fake_notifier)
|
|
173
|
-
|
|
174
|
-
allow(config).to receive(:silencer).and_return(silencer)
|
|
175
|
-
|
|
176
|
-
allow(subject).to receive(:require).with('rb-inotify')
|
|
177
|
-
subject.configure
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
it 'stops the worker' do
|
|
181
|
-
subject.stop
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
context 'when not even initialized' do
|
|
186
|
-
before do
|
|
187
|
-
allow(queue).to receive(:close)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
it 'does not crash' do
|
|
191
|
-
expect do
|
|
192
|
-
subject.stop
|
|
193
|
-
end.to_not raise_error
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
include Listen
|
|
4
|
-
|
|
5
|
-
RSpec.describe Adapter::Polling do
|
|
6
|
-
describe 'class' do
|
|
7
|
-
subject { described_class }
|
|
8
|
-
it { should be_usable }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
subject do
|
|
12
|
-
described_class.new(config)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
let(:dir1) do
|
|
16
|
-
instance_double(Pathname, 'dir1', to_s: '/foo/dir1', cleanpath: real_dir1)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# just so cleanpath works in above double
|
|
20
|
-
let(:real_dir1) { instance_double(Pathname, 'dir1', to_s: '/foo/dir1') }
|
|
21
|
-
|
|
22
|
-
let(:config) { instance_double(Listen::Adapter::Config, "config") }
|
|
23
|
-
let(:directories) { [dir1] }
|
|
24
|
-
let(:options) { {} }
|
|
25
|
-
let(:queue) { instance_double(Queue, "queue") }
|
|
26
|
-
let(:silencer) { instance_double(Listen::Silencer, "silencer") }
|
|
27
|
-
let(:snapshot) { instance_double(Listen::Change, "snapshot") }
|
|
28
|
-
|
|
29
|
-
let(:record) { instance_double(Listen::Record) }
|
|
30
|
-
|
|
31
|
-
context 'with a valid configuration' do
|
|
32
|
-
before do
|
|
33
|
-
allow(config).to receive(:directories).and_return(directories)
|
|
34
|
-
allow(config).to receive(:adapter_options).and_return(options)
|
|
35
|
-
allow(config).to receive(:queue).and_return(queue)
|
|
36
|
-
allow(config).to receive(:silencer).and_return(silencer)
|
|
37
|
-
|
|
38
|
-
allow(Listen::Record).to receive(:new).with(dir1, silencer).and_return(record)
|
|
39
|
-
|
|
40
|
-
allow(Listen::Change).to receive(:new).with(config, record).
|
|
41
|
-
and_return(snapshot)
|
|
42
|
-
allow(Listen::Change::Config).to receive(:new).with(queue, silencer).
|
|
43
|
-
and_return(config)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe '#start' do
|
|
47
|
-
before do
|
|
48
|
-
allow(snapshot).to receive(:record).and_return(record)
|
|
49
|
-
allow(record).to receive(:build)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
after do
|
|
53
|
-
allow(queue).to receive(:close)
|
|
54
|
-
subject.stop
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'notifies change on every listener directories path' do
|
|
58
|
-
expect(snapshot).to receive(:invalidate).
|
|
59
|
-
with(:dir, '.', { recursive: true })
|
|
60
|
-
|
|
61
|
-
t = Thread.new { subject.start }
|
|
62
|
-
sleep 0.25
|
|
63
|
-
t.kill
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe '#_latency' do
|
|
68
|
-
subject do
|
|
69
|
-
adapter = described_class.new(config)
|
|
70
|
-
adapter.options.latency
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
context 'with no overriding option' do
|
|
74
|
-
it { should eq 1.0 }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context 'with custom latency overriding' do
|
|
78
|
-
let(:options) { { latency: 1234 } }
|
|
79
|
-
it { should eq 1234 }
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Listen::Adapter do
|
|
4
|
-
let(:listener) { instance_double(Listen::Listener, options: {}) }
|
|
5
|
-
before do
|
|
6
|
-
allow(Listen::Adapter::BSD).to receive(:usable?) { false }
|
|
7
|
-
allow(Listen::Adapter::Darwin).to receive(:usable?) { false }
|
|
8
|
-
allow(Listen::Adapter::Linux).to receive(:usable?) { false }
|
|
9
|
-
allow(Listen::Adapter::Windows).to receive(:usable?) { false }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe '.select' do
|
|
13
|
-
it 'returns Polling adapter if forced' do
|
|
14
|
-
klass = Listen::Adapter.select(force_polling: true)
|
|
15
|
-
expect(klass).to eq Listen::Adapter::Polling
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'returns BSD adapter when usable' do
|
|
19
|
-
allow(Listen::Adapter::BSD).to receive(:usable?) { true }
|
|
20
|
-
klass = Listen::Adapter.select
|
|
21
|
-
expect(klass).to eq Listen::Adapter::BSD
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'returns Darwin adapter when usable' do
|
|
25
|
-
allow(Listen::Adapter::Darwin).to receive(:usable?) { true }
|
|
26
|
-
klass = Listen::Adapter.select
|
|
27
|
-
expect(klass).to eq Listen::Adapter::Darwin
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'returns Linux adapter when usable' do
|
|
31
|
-
allow(Listen::Adapter::Linux).to receive(:usable?) { true }
|
|
32
|
-
klass = Listen::Adapter.select
|
|
33
|
-
expect(klass).to eq Listen::Adapter::Linux
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'returns Windows adapter when usable' do
|
|
37
|
-
allow(Listen::Adapter::Windows).to receive(:usable?) { true }
|
|
38
|
-
klass = Listen::Adapter.select
|
|
39
|
-
expect(klass).to eq Listen::Adapter::Windows
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'no usable adapters' do
|
|
43
|
-
before { allow(Kernel).to receive(:warn) }
|
|
44
|
-
|
|
45
|
-
it 'returns Polling adapter' do
|
|
46
|
-
klass = Listen::Adapter.select(force_polling: true)
|
|
47
|
-
expect(klass).to eq Listen::Adapter::Polling
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'warns polling fallback with default message' do
|
|
51
|
-
msg = described_class::POLLING_FALLBACK_MESSAGE
|
|
52
|
-
expect(Listen).to receive(:adapter_warn).with("[Listen warning]:\n #{msg}")
|
|
53
|
-
Listen::Adapter.select
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "doesn't warn if polling_fallback_message is false" do
|
|
57
|
-
expect(Kernel).to_not receive(:warn)
|
|
58
|
-
Listen::Adapter.select(polling_fallback_message: false)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'warns polling fallback with custom message if set' do
|
|
62
|
-
expected_msg = "[Listen warning]:\n custom fallback message"
|
|
63
|
-
expect(Listen).to receive(:adapter_warn).with(expected_msg)
|
|
64
|
-
msg = 'custom fallback message'
|
|
65
|
-
Listen::Adapter.select(polling_fallback_message: msg)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'listen/backend'
|
|
4
|
-
|
|
5
|
-
RSpec.describe Listen::Backend do
|
|
6
|
-
let(:dir1) { instance_double(Pathname, 'dir1', to_s: '/foo/dir1') }
|
|
7
|
-
|
|
8
|
-
let(:silencer) { instance_double(Listen::Silencer) }
|
|
9
|
-
let(:queue) { instance_double(Queue) }
|
|
10
|
-
|
|
11
|
-
let(:select_options) do
|
|
12
|
-
{ force_polling: false, polling_fallback_message: 'foo' }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
let(:adapter_options) { { latency: 1234 } }
|
|
16
|
-
let(:options) { select_options.merge(adapter_options) }
|
|
17
|
-
|
|
18
|
-
let(:adapter_config_class) { class_double('Listen::Adapter::Config') }
|
|
19
|
-
let(:adapter_config) { instance_double('Listen::Adapter::Config') }
|
|
20
|
-
|
|
21
|
-
let(:config) { instance_double(Listen::Listener::Config) }
|
|
22
|
-
|
|
23
|
-
subject { described_class.new([dir1], queue, silencer, config) }
|
|
24
|
-
|
|
25
|
-
# Use Polling since it has a valid :latency option
|
|
26
|
-
let(:adapter_defaults) { { latency: 5.4321 } }
|
|
27
|
-
let(:adapter_class) { Listen::Adapter::Polling }
|
|
28
|
-
let(:adapter) { instance_double('Listen::Adapter::Polling') }
|
|
29
|
-
|
|
30
|
-
let(:config_min_delay_between_events) { 0.1234 }
|
|
31
|
-
|
|
32
|
-
before do
|
|
33
|
-
stub_const('Listen::Adapter::Config', adapter_config_class)
|
|
34
|
-
|
|
35
|
-
allow(adapter_config_class).to receive(:new).
|
|
36
|
-
with([dir1], queue, silencer, adapter_options).
|
|
37
|
-
and_return(adapter_config)
|
|
38
|
-
|
|
39
|
-
allow(Listen::Adapter).to receive(:select).
|
|
40
|
-
with(select_options).and_return(adapter_class)
|
|
41
|
-
|
|
42
|
-
allow(adapter_class).to receive(:new).
|
|
43
|
-
with(adapter_config).and_return(adapter)
|
|
44
|
-
|
|
45
|
-
allow(Listen::Adapter::Polling).to receive(:new).with(adapter_config).
|
|
46
|
-
and_return(adapter)
|
|
47
|
-
|
|
48
|
-
allow(config).to receive(:adapter_select_options).
|
|
49
|
-
and_return(select_options)
|
|
50
|
-
|
|
51
|
-
allow(config).to receive(:adapter_instance_options).
|
|
52
|
-
and_return(adapter_options)
|
|
53
|
-
|
|
54
|
-
allow(config).to receive(:min_delay_between_events).
|
|
55
|
-
and_return(config_min_delay_between_events)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
describe '#initialize' do
|
|
59
|
-
context 'with config' do
|
|
60
|
-
it 'sets up an adapter class' do
|
|
61
|
-
expect(adapter_class).to receive(:new).
|
|
62
|
-
with(adapter_config).and_return(adapter)
|
|
63
|
-
|
|
64
|
-
subject
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe '#start' do
|
|
70
|
-
it 'starts the adapter' do
|
|
71
|
-
expect(adapter).to receive(:start)
|
|
72
|
-
subject.start
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe '#stop' do
|
|
77
|
-
it 'stops the adapter' do
|
|
78
|
-
expect(adapter).to receive(:stop)
|
|
79
|
-
subject.stop
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Listen::Change do
|
|
4
|
-
let(:config) { instance_double(Listen::Change::Config) }
|
|
5
|
-
let(:dir) { instance_double(Pathname) }
|
|
6
|
-
let(:record) { instance_double(Listen::Record, root: '/dir') }
|
|
7
|
-
subject { Listen::Change.new(config, record) }
|
|
8
|
-
|
|
9
|
-
let(:full_file_path) { instance_double(Pathname, to_s: '/dir/file.rb') }
|
|
10
|
-
let(:full_dir_path) { instance_double(Pathname, to_s: '/dir') }
|
|
11
|
-
|
|
12
|
-
before do
|
|
13
|
-
allow(dir).to receive(:+).with('file.rb') { full_file_path }
|
|
14
|
-
allow(dir).to receive(:+).with('dir1') { full_dir_path }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe '#change' do
|
|
18
|
-
before do
|
|
19
|
-
allow(config).to receive(:silenced?).and_return(false)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context 'with build options' do
|
|
23
|
-
it 'calls still_building! on record' do
|
|
24
|
-
allow(config).to receive(:queue)
|
|
25
|
-
allow(Listen::File).to receive(:change)
|
|
26
|
-
subject.invalidate(:file, 'file.rb', build: true)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context 'file' do
|
|
31
|
-
context 'with known change' do
|
|
32
|
-
it 'notifies change directly to listener' do
|
|
33
|
-
expect(config).to receive(:queue).
|
|
34
|
-
with(:file, :modified, Pathname.new('/dir'), 'file.rb', {})
|
|
35
|
-
|
|
36
|
-
subject.invalidate(:file, 'file.rb', change: :modified)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "doesn't notify to listener if path is silenced" do
|
|
40
|
-
expect(config).to receive(:silenced?).and_return(true)
|
|
41
|
-
expect(config).to_not receive(:queue)
|
|
42
|
-
subject.invalidate(:file, 'file.rb', change: :modified)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'with unknown change' do
|
|
47
|
-
it 'calls Listen::File#change' do
|
|
48
|
-
expect(Listen::File).to receive(:change).with(record, 'file.rb')
|
|
49
|
-
subject.invalidate(:file, 'file.rb', {})
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "doesn't call Listen::File#change if path is silenced" do
|
|
53
|
-
expect(config).to receive(:silenced?).
|
|
54
|
-
with('file.rb', :file).and_return(true)
|
|
55
|
-
|
|
56
|
-
expect(Listen::File).to_not receive(:change)
|
|
57
|
-
subject.invalidate(:file, 'file.rb', {})
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'that returns a change' do
|
|
61
|
-
before { allow(Listen::File).to receive(:change) { :modified } }
|
|
62
|
-
|
|
63
|
-
context 'listener listen' do
|
|
64
|
-
it 'notifies change to listener' do
|
|
65
|
-
expect(config).to receive(:queue).
|
|
66
|
-
with(:file, :modified, Pathname.new('/dir'), 'file.rb')
|
|
67
|
-
|
|
68
|
-
subject.invalidate(:file, 'file.rb', {})
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
context 'silence option' do
|
|
72
|
-
it 'notifies change to listener' do
|
|
73
|
-
expect(config).to_not receive(:queue)
|
|
74
|
-
subject.invalidate(:file, 'file.rb', silence: true)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context 'that returns no change' do
|
|
81
|
-
before { allow(Listen::File).to receive(:change) { nil } }
|
|
82
|
-
|
|
83
|
-
it "doesn't notifies no change" do
|
|
84
|
-
expect(config).to_not receive(:queue)
|
|
85
|
-
subject.invalidate(:file, 'file.rb', {})
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context 'directory' do
|
|
92
|
-
let(:dir_options) { { recursive: true } }
|
|
93
|
-
|
|
94
|
-
it 'calls Listen::Directory#new' do
|
|
95
|
-
expect(Listen::Directory).to receive(:scan).
|
|
96
|
-
with(subject, 'dir1', dir_options)
|
|
97
|
-
|
|
98
|
-
subject.invalidate(:dir, 'dir1', dir_options)
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'listen/cli'
|
|
4
|
-
|
|
5
|
-
RSpec.describe Listen::CLI do
|
|
6
|
-
let(:options) { {} }
|
|
7
|
-
let(:forwarder) { instance_double(Listen::Forwarder) }
|
|
8
|
-
|
|
9
|
-
before do
|
|
10
|
-
allow(forwarder).to receive(:start)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe 'directories option' do
|
|
14
|
-
context 'not specified' do
|
|
15
|
-
let(:options) { %w[] }
|
|
16
|
-
it 'is set to local directory' do
|
|
17
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
18
|
-
expect(options[:directory]).to eq(['.'])
|
|
19
|
-
forwarder
|
|
20
|
-
end
|
|
21
|
-
described_class.start(options)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'with a single directory' do
|
|
26
|
-
let(:options) { %w[-d app] }
|
|
27
|
-
it 'is set to app' do
|
|
28
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
29
|
-
expect(options[:directory]).to eq(['app'])
|
|
30
|
-
forwarder
|
|
31
|
-
end
|
|
32
|
-
described_class.start(options)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context 'with a multiple directories' do
|
|
37
|
-
let(:options) { %w[-d app spec] }
|
|
38
|
-
it 'is set to an array of the directories' do
|
|
39
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
40
|
-
expect(options[:directory]).to eq(%w[app spec])
|
|
41
|
-
forwarder
|
|
42
|
-
end
|
|
43
|
-
described_class.start(options)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe 'relative option' do
|
|
49
|
-
context 'without relative option' do
|
|
50
|
-
let(:options) { %w[] }
|
|
51
|
-
it 'is set to false' do
|
|
52
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
53
|
-
expect(options[:relative]).to be(false)
|
|
54
|
-
forwarder
|
|
55
|
-
end
|
|
56
|
-
described_class.start(options)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'when -r' do
|
|
61
|
-
let(:options) { %w[-r] }
|
|
62
|
-
|
|
63
|
-
it 'is set to true' do
|
|
64
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
65
|
-
expect(options[:relative]).to be(true)
|
|
66
|
-
forwarder
|
|
67
|
-
end
|
|
68
|
-
described_class.start(options)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
context 'when --relative' do
|
|
73
|
-
let(:options) { %w[--relative] }
|
|
74
|
-
|
|
75
|
-
it 'supports -r option' do
|
|
76
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
77
|
-
expect(options[:relative]).to be(true)
|
|
78
|
-
forwarder
|
|
79
|
-
end
|
|
80
|
-
described_class.start(options)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'supports --relative option' do
|
|
84
|
-
expect(Listen::Forwarder).to receive(:new) do |options|
|
|
85
|
-
expect(options[:relative]).to be(true)
|
|
86
|
-
forwarder
|
|
87
|
-
end
|
|
88
|
-
described_class.start(options)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
RSpec.describe Listen::Forwarder do
|
|
95
|
-
let(:logger) { instance_double(Logger) }
|
|
96
|
-
let(:listener) { instance_double(Listen::Listener) }
|
|
97
|
-
|
|
98
|
-
before do
|
|
99
|
-
allow(Logger).to receive(:new).and_return(logger)
|
|
100
|
-
allow(logger).to receive(:level=)
|
|
101
|
-
allow(logger).to receive(:formatter=)
|
|
102
|
-
allow(logger).to receive(:info)
|
|
103
|
-
|
|
104
|
-
allow(listener).to receive(:start)
|
|
105
|
-
allow(listener).to receive(:processing?).and_return false
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it 'passes relative option to Listen' do
|
|
109
|
-
value = double('value')
|
|
110
|
-
expect(Listen).to receive(:to).
|
|
111
|
-
with(hash_including(relative: value)).
|
|
112
|
-
and_return(listener)
|
|
113
|
-
|
|
114
|
-
described_class.new(relative: value).start
|
|
115
|
-
end
|
|
116
|
-
end
|