Class: FluxTuna::Witness::DirFileWitness

Inherits:
AbstractWitness show all
Defined in:
lib/witness/dir_file_witness.rb

Overview

Create a Witness object for the specified directory

Instance Method Summary collapse

Methods inherited from AbstractWitness

#bind, #mutate

Constructor Details

#initializeDirFileWitness

Default constructor



24
25
26
27
28
# File 'lib/witness/dir_file_witness.rb', line 24

def initialize
  super(:Dir, :Null, :Tree)
  
  @content = FluxTuna::Core::NameTrie.new
end

Instance Method Details

#shatter(path) ⇒ Object

Run the shatter function, taking path is the File.glob shell glob for the path and pattern to match when looking for files



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/witness/dir_file_witness.rb', line 33

def shatter(path)
  
  # Walk the path,
  Dir.glob(path){|file_name|
    
    # Ignore directories
    unless File.directory?(file_name) then
      
      # Ignore the special files as well
      unless file_name == "." or file_name == ".." then
        
        # Create a GUID, then add this filename as the descriptor
        @content[UUIDTools::UUID.random_create] = file_name
      end        
    end
    
  }
  
end