diff --git a/lib/listen/adapter.rb b/lib/listen/adapter.rb index f3083810..dce86236 100644 --- a/lib/listen/adapter.rb +++ b/lib/listen/adapter.rb @@ -36,7 +36,7 @@ def _usable_adapter_class def _warn_polling_fallback(options) msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE) - Kernel.warn "[Listen warning]:\n #{msg}" if msg + Listen.adapter_warn("[Listen warning]:\n #{msg}") if msg end end end diff --git a/lib/listen/adapter/bsd.rb b/lib/listen/adapter/bsd.rb index 04a6958d..aafa2ceb 100644 --- a/lib/listen/adapter/bsd.rb +++ b/lib/listen/adapter/bsd.rb @@ -34,7 +34,7 @@ def self.usable? require 'find' true rescue LoadError - Kernel.warn BUNDLER_DECLARE_GEM + Listen.adapter_warn(BUNDLER_DECLARE_GEM) false end diff --git a/lib/listen/adapter/darwin.rb b/lib/listen/adapter/darwin.rb index 6106a145..3a610c5d 100644 --- a/lib/listen/adapter/darwin.rb +++ b/lib/listen/adapter/darwin.rb @@ -30,7 +30,7 @@ def self.usable? require 'rb-fsevent' fsevent_version = Gem::Version.new(FSEvent::VERSION) return true if fsevent_version <= Gem::Version.new('0.9.4') - Kernel.warn INCOMPATIBLE_GEM_VERSION + Listen.adapter_warn(INCOMPATIBLE_GEM_VERSION) false end diff --git a/lib/listen/adapter/windows.rb b/lib/listen/adapter/windows.rb index 252cb798..26a64005 100644 --- a/lib/listen/adapter/windows.rb +++ b/lib/listen/adapter/windows.rb @@ -20,7 +20,7 @@ def self.usable? Listen.logger.debug format('wdm - load failed: %s:%s', $ERROR_INFO, $ERROR_POSITION * "\n") - Kernel.warn BUNDLER_DECLARE_GEM + Listen.adapter_warn(BUNDLER_DECLARE_GEM) false end diff --git a/lib/listen/record/symlink_detector.rb b/lib/listen/record/symlink_detector.rb index cce87739..f193043c 100644 --- a/lib/listen/record/symlink_detector.rb +++ b/lib/listen/record/symlink_detector.rb @@ -30,6 +30,12 @@ def verify_unwatched!(entry) @real_dirs.add?(real_path) or _fail(entry.sys_path, real_path) end + # Leaving this stub here since some warning work-arounds were referring to it. + # Deprecated. Will be removed in Listen v4.0. + def warn(message) + Listen.adapter_warn(message) + end + private def _fail(symlinked, real_path) diff --git a/spec/lib/listen/adapter/darwin_spec.rb b/spec/lib/listen/adapter/darwin_spec.rb index 4c53e436..d9ff0cc8 100644 --- a/spec/lib/listen/adapter/darwin_spec.rb +++ b/spec/lib/listen/adapter/darwin_spec.rb @@ -35,7 +35,7 @@ context 'with rb-fsevent > 0.9.4' do before { stub_const('FSEvent::VERSION', '0.9.6') } it 'shows a warning and should not be usable' do - expect(Kernel).to receive(:warn) + expect(Listen).to receive(:adapter_warn) expect(subject).to_not be_usable end end diff --git a/spec/lib/listen/adapter_spec.rb b/spec/lib/listen/adapter_spec.rb index be19765b..b92c6bd4 100644 --- a/spec/lib/listen/adapter_spec.rb +++ b/spec/lib/listen/adapter_spec.rb @@ -49,7 +49,7 @@ it 'warns polling fallback with default message' do msg = described_class::POLLING_FALLBACK_MESSAGE - expect(Kernel).to receive(:warn).with("[Listen warning]:\n #{msg}") + expect(Listen).to receive(:adapter_warn).with("[Listen warning]:\n #{msg}") Listen::Adapter.select end @@ -60,7 +60,7 @@ it 'warns polling fallback with custom message if set' do expected_msg = "[Listen warning]:\n custom fallback message" - expect(Kernel).to receive(:warn).with(expected_msg) + expect(Listen).to receive(:adapter_warn).with(expected_msg) msg = 'custom fallback message' Listen::Adapter.select(polling_fallback_message: msg) end