lib/file/find.rb in file-find-0.2.2 vs lib/file/find.rb in file-find-0.2.3

- old
+ new

@@ -4,20 +4,21 @@ include Config include Sys class File::Find # The version of this library - VERSION = '0.2.2' + VERSION = '0.2.3' # :stopdoc: VALID_OPTIONS = %w/ atime ctime follow ftype inum group + mtime name pattern path perm prune @@ -36,12 +37,11 @@ # attr_accessor :options # Limits searches by file access time, where the value you supply is the # number of days back from the time that the File::Find#find method was - # called. Note that the File::Find#find method itself alters the access - # times. + # called. # attr_accessor :atime # Limits searches by file change time, where the value you supply is the # number of days back from the time that the File::Find#find method was @@ -54,12 +54,13 @@ # # Not currently supported on MS Windows. # attr_accessor :group - # Controls the behavior of how symlinks are followed. If set to true, then - # follows the file pointed to. If false, it considers the symlink itself. + # Controls the behavior of how symlinks are followed. If set to true (the + # default), then follows the file pointed to. If false, it considers the + # symlink itself. # attr_accessor :follow # Limits searches to specific types of files. The possible values here are # those returned by the File.ftype method. @@ -69,10 +70,16 @@ # Limits search to a file with a specific inode number. Ignored on MS # Windows. # attr_accessor :inum + # Limits searches by file modification time, where the value you supply is + # the number of days back from the time that the File::Find#find method was + # called. + # + attr_accessor :mtime + # The name pattern used to limit file searches. The patterns that are legal # for Dir.glob are legal here. The default is '*', i.e. everything. # attr_accessor :name @@ -129,10 +136,11 @@ @ctime = nil @ftype = nil @group = nil @follow = true @inum = nil + @mtime = nil @perm = nil @prune = nil @size = nil @user = nil @@ -224,9 +232,15 @@ if @ctime date1 = Date.parse(Time.now.to_s) date2 = Date.parse(stat_info.ctime.to_s) next unless (date1 - date2).numerator == @ctime + end + + if @mtime + date1 = Date.parse(Time.now.to_s) + date2 = Date.parse(stat_info.mtime.to_s) + next unless (date1 - date2).numerator == @mtime end if @ftype next unless File.ftype(file) == @ftype end