Class: FileTreeProfiler::DataFile

Inherits:
File
  • Object
show all
Defined in:
lib/file_tree_profiler/data_file.rb

Constant Summary collapse

EMPTY_CHECKSUM =
::Digest::MD5.hexdigest('/no-data/').freeze

Instance Attribute Summary

Attributes inherited from File

#name, #parent

Instance Method Summary collapse

Methods inherited from File

#initialize, #inspect, #path, #relative_path

Constructor Details

This class inherits a constructor from FileTreeProfiler::File

Instance Method Details

#checksumObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/file_tree_profiler/data_file.rb', line 9

def checksum
  @checksum ||= begin
    empty? ? EMPTY_CHECKSUM : ::Digest::MD5.file(path)
  end.to_s
rescue Errno::ELOOP => e
  puts "path=#{path} is a circular ref"
rescue Errno::ENOENT => e
  puts "got deleted while profiling!!!"
  @checksum = EMPTY_CHECKSUM
end

#empty?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/file_tree_profiler/data_file.rb', line 5

def empty?
  ::File.zero?(path)
end

#sizeObject



20
21
22
# File 'lib/file_tree_profiler/data_file.rb', line 20

def size
  1
end