Skip to content

Commit 0365933

Browse files
committed
(PUP-11974) Use Ruby warn for deprecation
1341b92 added monkey patches for File.exists? and Dir.exists? and used Puppet's warning method to indicated that the methods are deprecated. This commit updates those monkey patches to instead use the less verbose Kernel#warn.
1 parent 33cd733 commit 0365933

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/puppet/util/monkey_patches.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def daemonize
3333
unless Dir.singleton_methods.include?(:exists?)
3434
class Dir
3535
def self.exists?(file_name)
36-
Puppet.warning('exists? is a deprecated name, use exist? instead')
36+
warn('exists? is a deprecated name, use exist? instead')
3737
Dir.exist?(file_name)
3838
end
3939
end
@@ -42,7 +42,7 @@ def self.exists?(file_name)
4242
unless File.singleton_methods.include?(:exists?)
4343
class File
4444
def self.exists?(file_name)
45-
Puppet.warning('exists? is a deprecated name, use exist? instead')
45+
warn('exists? is a deprecated name, use exist? instead')
4646
File.exist?(file_name)
4747
end
4848
end

spec/unit/util/monkey_patches_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
if RUBY_VERSION >= '3.2'
1616
it 'logs a warning message' do
17-
expect(Puppet).to receive(:warning).with('exists? is a deprecated name, use exist? instead')
17+
expect(Dir).to receive(:warn).with('exists? is a deprecated name, use exist? instead')
1818
Dir.exists?(__dir__)
1919
end
2020
end
@@ -33,7 +33,7 @@
3333

3434
if RUBY_VERSION >= '3.2'
3535
it 'logs a warning message' do
36-
expect(Puppet).to receive(:warning).with('exists? is a deprecated name, use exist? instead')
36+
expect(File).to receive(:warn).with('exists? is a deprecated name, use exist? instead')
3737
File.exists?(__FILE__)
3838
end
3939
end

0 commit comments

Comments
 (0)