Skip to content

Commit

Permalink
issue #572: switch Kernel.warn and warn to adapter_warn
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDKelley committed Feb 23, 2024
1 parent cb8c9c5 commit 6197c92
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/listen/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/bsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/darwin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lib/listen/record/symlink_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/listen/adapter/darwin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/listen/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 6197c92

Please sign in to comment.