Sha256: f20ea037c9f7a0a438b1e36d1f18f51751f35e77cd12a2723ccc4163d1745b67

Contents?: true

Size: 983 Bytes

Versions: 9

Compression:

Stored size: 983 Bytes

Contents

module BabyBro
  module Files

    def file_timestamp( filename )
      file = File.new(filename)
      mtime = file.mtime
      file.close
      mtime
    end
    
    def touch_file( filename, time )
      `touch -t #{time.strftime("%Y%m%d%H%M.%S")} #{filename}`
    end
    
    # returns files in the specified directory
    def find_files( directory, pattern='*')
     `find #{directory} -name "#{pattern}"`.split("\n").reject{|f| f==directory}
    end

    # returns files in the specified directory that are newer than the specified file
    def find_files_newer_than_file( directory, filename )
     `find #{directory} -newer #{filename}`.split("\n")
    end

    # returns files in the specified directory that are newer than the time expression
    # time_interval_expression is in english, eg.  "15 minutes"
    def find_recent_files( directory, time_interval_expression )
     `find '#{directory}' -newermt "#{time_interval_expression} ago"`.split("\n")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
baby-bro-0.0.9 lib/baby-bro/files.rb
baby-bro-0.0.8 lib/baby-bro/files.rb
baby-bro-0.0.7 lib/baby-bro/files.rb
baby-bro-0.0.6 lib/baby-bro/files.rb
baby-bro-0.0.5 lib/baby-bro/files.rb
baby-bro-0.0.4 lib/baby-bro/files.rb
baby-bro-0.0.3 lib/baby-bro/files.rb
baby-bro-0.0.2 lib/baby-bro/files.rb
baby-bro-0.0.1 lib/baby-bro/files.rb