lib/file_extensions.rb in royw-roys_extensions-0.0.2 vs lib/file_extensions.rb in royw-roys_extensions-0.0.3
- old
+ new
@@ -5,18 +5,29 @@
# Note, uses the Module.my_extension method to only add the method if
# it doesn't already exist.
class File
class << self
my_extension("mkdirs") do
- ##
+ # == Synopsis
# make directories including any missing in the path
#
# @param [String] dirspec the path to make sure exists
def File.mkdirs(dirspec)
unless File.exists?(dirspec)
mkdirs(File.dirname(dirspec))
Dir.mkdir(dirspec)
end
+ end
+ end
+
+ my_extension("touch") do
+ # == Synopsis
+ # Sets the last modification time of the given filespec
+ # to the current time. Create the given file if it doesn't
+ # exist
+ require 'fileutils'
+ def File.touch(filespec)
+ FileUtils.touch(filespec)
end
end
end
end