Sha256: ed84e6c84b64b6eaa0f973e20c3ce0a2dc774460bb40a8f544a91f50e1416b87
Contents?: true
Size: 928 Bytes
Versions: 2
Compression:
Stored size: 928 Bytes
Contents
require_relative 'time_difference' module Autowow class Fs using RefinedTimeDifference def self.ls_dirs Dir.glob(File.expand_path('./*/')).select {|f| File.directory? f} end def self.latest(files) files.sort_by{ |f| File.mtime(f) }.reverse!.first end def self.older_than(files, quantity, unit) files.select do |dir| TimeDifference.between(File.mtime(dir), Time.now).public_send("in_#{unit}") > quantity end end def self.for_dirs(dirs) dirs.each do |working_dir| # TODO: add handling of directories via extra param to popen3 # https://stackoverflow.com/a/10148084/2771889 Dir.chdir(working_dir) do yield working_dir end end end def self.in_place_or_subdirs(in_place) if in_place yield else for_dirs(ls_dirs) do yield end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
autowow-0.3.0 | lib/autowow/fs.rb |
autowow-0.2.0 | lib/autowow/fs.rb |