Skip to content

Commit

Permalink
Rename usage of Dir/File.exists to exist
Browse files Browse the repository at this point in the history
The singular methods were deprecated long ago and finally removed in Ruby 3.2.0.
  • Loading branch information
ecnelises authored and ddollar committed Apr 12, 2024
1 parent a5f9b78 commit 0fe6bc9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/foreman/export/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def self.warn_deprecation!
def chown user, dir
FileUtils.chown user, nil, dir
rescue
error("Could not chown #{dir} to #{user}") unless File.writable?(dir) || ! File.exists?(dir)
error("Could not chown #{dir} to #{user}") unless File.writable?(dir) || ! File.exist?(dir)
end

def error(message)
Expand All @@ -95,13 +95,13 @@ def say(message)
end

def clean(filename)
return unless File.exists?(filename)
return unless File.exist?(filename)
say "cleaning up: #{filename}"
FileUtils.rm(filename)
end

def clean_dir(dirname)
return unless File.exists?(dirname)
return unless File.exist?(dirname)
say "cleaning up directory: #{dirname}"
FileUtils.rm_r(dirname)
end
Expand Down Expand Up @@ -130,7 +130,7 @@ def export_template(name, file=nil, template_root=nil)
matchers << File.join(options[:template], name_without_first) if options[:template]
matchers << File.expand_path("~/.foreman/templates/#{name}")
matchers << File.expand_path("../../../../data/export/#{name}", __FILE__)
File.read(matchers.detect { |m| File.exists?(m) })
File.read(matchers.detect { |m| File.exist?(m) })
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/foreman/export/daemon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
expect(File.read("/tmp/init/app-alpha.conf")).to eq(example_export_file("daemon/app-alpha.conf"))
expect(File.read("/tmp/init/app-alpha-1.conf")).to eq(example_export_file("daemon/app-alpha-1.conf"))
expect(File.read("/tmp/init/app-alpha-2.conf")).to eq(example_export_file("daemon/app-alpha-2.conf"))
expect(File.exists?("/tmp/init/app-bravo-1.conf")).to eq(false)
expect(File.exist?("/tmp/init/app-bravo-1.conf")).to eq(false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/foreman/export/upstart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
expect(File.read("/tmp/init/app-alpha.conf")).to eq(example_export_file("upstart/app-alpha.conf"))
expect(File.read("/tmp/init/app-alpha-1.conf")).to eq(example_export_file("upstart/app-alpha-1.conf"))
expect(File.read("/tmp/init/app-alpha-2.conf")).to eq(example_export_file("upstart/app-alpha-2.conf"))
expect(File.exists?("/tmp/init/app-bravo-1.conf")).to eq(false)
expect(File.exist?("/tmp/init/app-bravo-1.conf")).to eq(false)
end
end

Expand Down
2 changes: 1 addition & 1 deletion tasks/dist.rake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def beta?
end

def clean(file)
rm file if File.exists?(file)
rm file if File.exist?(file)
end

def distribution_files(type=nil)
Expand Down

0 comments on commit 0fe6bc9

Please sign in to comment.