instead of refactoring duplicate code you just ignore it.
#region simianignore - logic same among all screensyou hear:
"I don't like to check in often, the tests take too long to run"
#region simianignore - logic same among all screensrequire 'find'
require 'date'
require 'fileutils'
root_dir = "C:/Dist"
two_weeks_ago = Date.today - 14
puts "deleting files last modified before #{two_weeks_ago}"
Find.find(root_dir) do |path|
if File.dirname(path) == root_dir
file_modify_date = Date.parse(File.mtime(path).strftime("%m/%d/%Y"))
puts "#{path} last modified on #{file_modify_date}"
if file_modify_date < two_weeks_ago
puts "#{path} removed"
FileUtils.rm_rf(path)
end
end
end
I prefer escape characters (\") and Q delimiters (%Q) to entity codes (").*option 2 provided by Martin
For example, executing an external program where the 1st parameter needs to be in quotes but not the second.
Rake (option 1):exec "foo.exe \"some text\" bar"
Rake (option 2)*:exec %Q[foo.exe "some text" bar]
NAnt:<exec program="foo.exe" commandline=""some text" bar"/>
<exec program="ruby" commandline='parse_text.rb "some text file.txt"'/><exec program="ruby" commandline="parse_text.rb "some text file.txt""/>