Module: FileDigests

Defined in:
lib/file-digests.rb

Defined Under Namespace

Classes: Checker, DigestDatabase

Class Method Summary collapse

Class Method Details

.ensure_dir_exists(path) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/file-digests.rb', line 11

def self.ensure_dir_exists path
  if File.exist?(path)
    unless File.directory?(path)
      raise "#{path} is not a directory"
    end
  else
    FileUtils.mkdir_p path
  end
end

.measure_timeObject



21
22
23
24
25
26
# File 'lib/file-digests.rb', line 21

def self.measure_time
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  yield
  elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start).to_i
  puts "Elapsed time: #{elapsed / 3600}h #{(elapsed % 3600) / 60}m #{elapsed % 60}s" unless QUIET
end

.patch_path_string(path) ⇒ Object



28
29
30
# File 'lib/file-digests.rb', line 28

def self.patch_path_string path
  Gem.win_platform? ? path.gsub(/\\/, '/') : path
end

.perform_checkObject



32
33
34
35
# File 'lib/file-digests.rb', line 32

def self.perform_check
  checker = Checker.new ARGV[0], ARGV[1]
  checker.perform_check
end