From fec6b59950a4951538c1be6f4bd6e619ae97f972 Mon Sep 17 00:00:00 2001 From: Marcus Stollsteimer Date: Sun, 6 Apr 2014 13:31:34 +0200 Subject: [PATCH] Use File.exist? instead of deprecated File.exists? --- features/step_definitions/jekyll_steps.rb | 8 ++++---- lib/jekyll/commands/serve.rb | 2 +- lib/jekyll/layout_reader.rb | 2 +- lib/jekyll/site.rb | 2 +- test/test_coffeescript.rb | 2 +- test/test_generated_site.rb | 6 +++--- test/test_new_command.rb | 8 ++++---- test/test_page.rb | 18 +++++++++--------- test/test_post.rb | 8 ++++---- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index db93010e..00264fb6 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -18,19 +18,19 @@ end Before do - FileUtils.mkdir_p(TEST_DIR) unless File.exists?(TEST_DIR) + FileUtils.mkdir_p(TEST_DIR) unless File.exist?(TEST_DIR) Dir.chdir(TEST_DIR) end After do - FileUtils.rm_rf(TEST_DIR) if File.exists?(TEST_DIR) + FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR) FileUtils.rm(JEKYLL_COMMAND_OUTPUT_FILE) end World(Test::Unit::Assertions) Given /^I have a blank site in "(.*)"$/ do |path| - FileUtils.mkdir_p(path) unless File.exists?(path) + FileUtils.mkdir_p(path) unless File.exist?(path) end Given /^I do not have a "(.*)" directory$/ do |path| @@ -190,7 +190,7 @@ Then /^the "(.*)" file should +exist$/ do |file| end Then /^the "(.*)" file should not exist$/ do |file| - assert !File.exists?(file), "The file \"#{file}\" exists" + assert !File.exist?(file), "The file \"#{file}\" exists" end Then /^I should see today's time in "(.*)"$/ do |file| diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index f884a08a..6a86aafe 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -37,7 +37,7 @@ module Jekyll FileUtils.mkdir_p(destination) # monkey patch WEBrick using custom 404 page (/404.html) - if File.exists?(File.join(destination, '404.html')) + if File.exist?(File.join(destination, '404.html')) WEBrick::HTTPResponse.class_eval do def create_error_page @body = IO.read(File.join(@config[:DocumentRoot], '404.html')) diff --git a/lib/jekyll/layout_reader.rb b/lib/jekyll/layout_reader.rb index 3aebf760..a9172c06 100644 --- a/lib/jekyll/layout_reader.rb +++ b/lib/jekyll/layout_reader.rb @@ -33,7 +33,7 @@ module Jekyll end def within(directory) - return unless File.exists?(directory) + return unless File.exist?(directory) Dir.chdir(directory) { yield } end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 0e7ddac3..8497dd10 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -333,7 +333,7 @@ module Jekyll # Returns the list of entries to process def get_entries(dir, subfolder) base = File.join(source, dir, subfolder) - return [] unless File.exists?(base) + return [] unless File.exist?(base) entries = Dir.chdir(base) { filter_entries(Dir['**/*'], base) } entries.delete_if { |e| File.directory?(File.join(base, e)) } end diff --git a/test/test_coffeescript.rb b/test/test_coffeescript.rb index cd052c05..91fd6237 100644 --- a/test/test_coffeescript.rb +++ b/test/test_coffeescript.rb @@ -39,7 +39,7 @@ JS end should "write a JS file in place" do - assert File.exists?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir." + assert File.exist?(@test_coffeescript_file), "Can't find the converted CoffeeScript file in the dest_dir." end should "produce JS" do diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 86b5f0c2..5419f2b9 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -33,7 +33,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "hide unpublished page" do - assert !File.exists?(dest_dir('/unpublished.html')) + assert !File.exist?(dest_dir('/unpublished.html')) end should "not copy _posts directory" do @@ -41,8 +41,8 @@ class TestGeneratedSite < Test::Unit::TestCase end should "process other static files and generate correct permalinks" do - assert File.exists?(dest_dir('/about/index.html')) - assert File.exists?(dest_dir('/contacts.html')) + assert File.exist?(dest_dir('/about/index.html')) + assert File.exist?(dest_dir('/contacts.html')) end should "print a nice list of static files" do diff --git a/test/test_new_command.rb b/test/test_new_command.rb index bc9e6585..135cfa6e 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -24,9 +24,9 @@ class TestNewCommand < Test::Unit::TestCase end should 'create a new directory' do - assert !File.exists?(@full_path) + assert !File.exist?(@full_path) capture_stdout { Jekyll::Commands::New.process(@args) } - assert File.exists?(@full_path) + assert File.exist?(@full_path) end should 'display a success message' do @@ -83,9 +83,9 @@ class TestNewCommand < Test::Unit::TestCase end should 'create a new directory' do - assert !File.exists?(@site_name_with_spaces) + assert !File.exist?(@site_name_with_spaces) capture_stdout { Jekyll::Commands::New.process(@multiple_args) } - assert File.exists?(@site_name_with_spaces) + assert File.exist?(@site_name_with_spaces) end end diff --git a/test/test_page.rb b/test/test_page.rb index 90f68c96..b34b511c 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -167,7 +167,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'contacts.html')) + assert File.exist?(File.join(dest_dir, 'contacts.html')) end should "write even when the folder name is plus and permalink has +" do @@ -176,7 +176,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '+', 'plus+in+url')) + assert File.exist?(File.join(dest_dir, '+', 'plus+in+url')) end should "write even when permalink has '%# +'" do @@ -185,7 +185,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '+', '%# +.html')) + assert File.exist?(File.join(dest_dir, '+', '%# +.html')) end should "write properly without html extension" do @@ -195,7 +195,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'contacts', 'index.html')) + assert File.exist?(File.join(dest_dir, 'contacts', 'index.html')) end should "write properly with extension different from html" do @@ -207,7 +207,7 @@ class TestPage < Test::Unit::TestCase assert_equal("/sitemap.xml", page.url) assert_nil(page.url[/\.html$/]) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir,'sitemap.xml')) + assert File.exist?(File.join(dest_dir,'sitemap.xml')) end should "write dotfiles properly" do @@ -216,7 +216,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '.htaccess')) + assert File.exist?(File.join(dest_dir, '.htaccess')) end context "in a directory hierarchy" do @@ -226,7 +226,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'contacts', 'index.html')) + assert File.exist?(File.join(dest_dir, 'contacts', 'index.html')) end should "write properly" do @@ -235,7 +235,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'contacts', 'bar.html')) + assert File.exist?(File.join(dest_dir, 'contacts', 'bar.html')) end should "write properly without html extension" do @@ -245,7 +245,7 @@ class TestPage < Test::Unit::TestCase page.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'contacts', 'bar', 'index.html')) + assert File.exist?(File.join(dest_dir, 'contacts', 'bar', 'index.html')) end end end diff --git a/test/test_post.rb b/test/test_post.rb index 26875115..d7a57510 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -537,7 +537,7 @@ class TestPost < Test::Unit::TestCase post.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html')) + assert File.exist?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html')) end should "write properly when url has hash" do @@ -546,7 +546,7 @@ class TestPost < Test::Unit::TestCase post.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '2009', '03', '12', + assert File.exist?(File.join(dest_dir, '2009', '03', '12', 'hash-#1.html')) end @@ -556,7 +556,7 @@ class TestPost < Test::Unit::TestCase post.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, '2014', '03', '22', + assert File.exist?(File.join(dest_dir, '2014', '03', '22', 'escape-+ %20[].html')) end @@ -567,7 +567,7 @@ class TestPost < Test::Unit::TestCase post.write(dest_dir) assert File.directory?(dest_dir) - assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html')) + assert File.exist?(File.join(dest_dir, 'foo-bar', 'index.html')) end should "insert data" do