Sha256: abcf68259860e300ca03d970e3edb4b7b5866820f7546cca60326660609bed8d
Contents?: true
Size: 803 Bytes
Versions: 4
Compression:
Stored size: 803 Bytes
Contents
module Hike class DirectoryIndex def initialize expire end def expire expire_mtimes expire_files end def expire_mtimes @mtimes = {} true end def expire_files @files = {} true end def mtime(dirname) @mtimes[dirname] ||= File.directory?(dirname) && File.mtime(dirname) end def files(dirname) if current_mtime = mtime(dirname) cached_mtime, files = @files[dirname] if current_mtime == cached_mtime return files else files = Dir.entries(dirname).select do |entry| File.file?(File.join(dirname, entry)) end end else files = [] end @files[dirname] = [current_mtime, files] files end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hike-0.1.4 | lib/hike/directory_index.rb |
hike-0.1.3 | lib/hike/directory_index.rb |
hike-0.1.2 | lib/hike/directory_index.rb |
hike-0.1.1 | lib/hike/directory_index.rb |