class Object
Constants
- VERSION
Public Instance Methods
collectFileMtime(dir, option)
click to toggle source
# File bin/timestamp, line 11 def collectFileMtime dir, option exclude_ext = option[:exclude_ext] exclude_dir = option[:exclude_dir] include_ext = option[:include_ext] md5 = option[:md5] formatter = option[:time_format] # debugger map = {} full_dir = File.expand_path dir Dir.chdir full_dir is_empty = true Dir.foreach "." do |file| if File.directory? file unless exclude_dir.to_s.include? file pwd = Dir.pwd submap = collectFileMtime file, option is_empty = false unless submap.nil? or submap.empty? unless submap.nil? map[file] = submap end Dir.chdir pwd end else ext = File.extname file if include_ext.length == 0 or include_ext.to_s.include?(ext) unless exclude_ext.to_s.include? ext mtime = File.mtime file if md5 > 0 map[file] = Digest::MD5.hexdigest(mtime.to_s)[0...md5]; else map[file] = mtime.strftime formatter end is_empty = false end end end end return is_empty ? nil : map end