Module: Treedisha::Filesystem

Defined in:
lib/treedisha/filesystem.rb

Class Method Summary collapse

Class Method Details

.all_files(root_path) ⇒ Object



4
5
6
7
8
# File 'lib/treedisha/filesystem.rb', line 4

def self.all_files(root_path)
  Dir.glob("#{root_path}/**/*").find_all do |f|
    !File.directory? f
  end
end

.all_files_with_sha1(root_path) ⇒ Object



10
11
12
13
14
# File 'lib/treedisha/filesystem.rb', line 10

def self.all_files_with_sha1(root_path)
  all_files(root_path).map do |f|
    [sha1_for_file(f), f]
  end
end

.sha1_for_file(file) ⇒ Object



16
17
18
# File 'lib/treedisha/filesystem.rb', line 16

def self.sha1_for_file(file)
  Digest::SHA1.file(file).to_s
end