Sha256: ac1ba4f7c0ea3b1dd5d0c8a5d79555972edaa5d9aae06f18c0324ddf021a4976
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
module Idonethis::Adapters module IO module DirectoryInfo class << self def modified(opts) since,dir,log = defaults.merge(opts).values_at(:since, :dir, :log) return [] unless File.exists?(dir) _in(dir).select{|it| any_file_inside_changed?(it, since, log) } end private def any_file_inside_changed?(dir, since, log) Dir["#{dir}/**/**"].each do |file| modified_time = File.mtime(file) modified = modified_time >= since.to_time log.call("[DirectoryInfo] Checking files inside <#{dir}>. <#{file}> has changed since <#{since}>. Its ctime is <#{modified_time}>") if modified return true if modified end return false end def same_day?(a, b) a.year == b.year && a.month == b.month && a.day == b.day end def _in(dir) Dir.entries(dir). reject{|it| ["..", "."].include?(it) }. select{|it| File.directory?(File.join(dir, it))}. map{ |it| File.expand_path(File.join(dir, it))} end private def defaults { log: ->(msg) {}} end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
idonethis-cli-0.20.0 | lib/adapters/io/directory_info.rb |