Sha256: d3e3dbb4fe67a78ce42c94e5de60e2e4d4bd81113366d56b90fe788021c4b7b3
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'pathname' class Cache_Helper def cache_exists? File.directory?(dir + '/.onceover') end def self.digest(path, opts = { exceptions: ['.','..','.onceover'] }) if File.directory?(path) # Get the list of files children = Cache_Helper.get_children(path, opts[:exceptions]) else children = [File.expand_path(path)] end # Calculate hashes hashes = children.map do |child_path| if File.directory? child_path :directory else Digest::MD5.file(child_path) end end root = Pathname.new(File.expand_path(path)) # Move pathnames back to relative children.map! do |child_path| Pathname.new(child_path).relative_path_from root end Hash[children.zip(hashes)] end def self.get_children(dir, exclusions) root_files = [] files = [] Dir.chdir(dir) do # Get all root files root_files = Dir.glob('*',File::FNM_DOTMATCH) root_files = root_files - exclusions root_files.each do |file| files << file files << Dir.glob("#{file}/**/*",File::FNM_DOTMATCH) end files.flatten! # Calculate absolue paths files.map! do |file| File.expand_path(file) end end files end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onceover-4.0.0 | features/support/cache_helper.rb |