From fc707d700c3e1eebc2a855ef3b01d9a363b98b70 Mon Sep 17 00:00:00 2001 From: yoshihara Date: Tue, 7 Apr 2015 18:06:01 +0900 Subject: [PATCH 1/3] Add clean task to remove all files/directories under tmp/ Please use this task carefully... --- lib/tasks/clean.rake | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/tasks/clean.rake diff --git a/lib/tasks/clean.rake b/lib/tasks/clean.rake new file mode 100644 index 0000000..def7ace --- /dev/null +++ b/lib/tasks/clean.rake @@ -0,0 +1,8 @@ +require 'fileutils' + +desc "clean all files/directories in tmp/ directory (use carefully)" +task :clean do + tmp_directory = File.join(Rails.root, "tmp") + system("rm -rf #{tmp_directory}") + system("mkdir #{tmp_directory}") +end From e47095e814180870ff29acb2f40340e6f1e890f1 Mon Sep 17 00:00:00 2001 From: yoshihara Date: Tue, 7 Apr 2015 18:15:56 +0900 Subject: [PATCH 2/3] Remove needless require --- lib/tasks/clean.rake | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/tasks/clean.rake b/lib/tasks/clean.rake index def7ace..2c3f417 100644 --- a/lib/tasks/clean.rake +++ b/lib/tasks/clean.rake @@ -1,5 +1,3 @@ -require 'fileutils' - desc "clean all files/directories in tmp/ directory (use carefully)" task :clean do tmp_directory = File.join(Rails.root, "tmp") From f5142c1c465d61877a0ee51b1c33a1bd1fc7ae4e Mon Sep 17 00:00:00 2001 From: yoshihara Date: Tue, 7 Apr 2015 18:45:30 +0900 Subject: [PATCH 3/3] Use Pathname methods instead of system method or File one --- lib/tasks/clean.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/clean.rake b/lib/tasks/clean.rake index 2c3f417..d446b61 100644 --- a/lib/tasks/clean.rake +++ b/lib/tasks/clean.rake @@ -1,6 +1,6 @@ desc "clean all files/directories in tmp/ directory (use carefully)" task :clean do - tmp_directory = File.join(Rails.root, "tmp") - system("rm -rf #{tmp_directory}") - system("mkdir #{tmp_directory}") + tmp_directory = Rails.root.join("tmp") + tmp_directory.rmtree + tmp_directory.mkdir end