Class: MD5FindCommand

Inherits:
FindCommand show all
Defined in:
lib/justy/commands/md5_find_command.rb

Instance Attribute Summary

Attributes inherited from FindCommand

#files

Instance Method Summary collapse

Methods inherited from FindCommand

#initialize, #output

Constructor Details

This class inherits a constructor from FindCommand

Instance Method Details

#run(folder) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/justy/commands/md5_find_command.rb', line 9

def run(folder)
  Dir.glob(folder + '**/*', File::FNM_DOTMATCH).each do |filename|
    next if File.directory?(filename)
    key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
    if @files.has_key? key
      @files[key].push filename
    else
      @files[key] = [filename]
    end
  end
  output()
end