Module: Gibbler::File

Includes:
Object
Included in:
File, TempFile
Defined in:
lib/gibbler.rb

Overview

Creates a digest based on: CLASS:PATHLENGTH:PATH where PATHLENGTH is the length of the PATH string. PATH is not modified in any way (it is not converted to an absolute path).

NOTE: You may expect this method to include other information like the file contents and modified date (etc…). The reason we do not is because Gibbler is concerned only about Ruby and not the outside world. There are many complexities in parsing file data and attributes which would make it difficult to run across platforms and Ruby versions / engines. If you want to

e.g.

File.new('.')        # => c8bc8b3a
File.new('/tmp')     # => 3af85a19
File.new('/tmp/')    # => 92cbcb7d

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Object

#digest_cache, #freeze, #gibbled?, #gibbler, #gibbler_debug, #gibbler_fields, gibbler_fields

Class Method Details

.included(obj) ⇒ Object



554
555
556
557
# File 'lib/gibbler.rb', line 554

def self.included(obj)
  obj.extend Attic
  obj.attic :gibbler_cache
end

Instance Method Details

#__gibbler(h = self) ⇒ Object

Creates a digest for the current state of self.



560
561
562
563
564
565
566
# File 'lib/gibbler.rb', line 560

def __gibbler(h=self)
  klass = h.class
  value = h.nil? ? "\0" : h.path
  a = Gibbler.digest "%s:%d:%s" % [klass, value.size, value]
  gibbler_debug klass, a, [klass, value.size, value]
  a
end