Class: CheckSumCalculator

Inherits:
Object show all
Defined in:
lib/build/CheckSumCalculator.rb

Instance Method Summary collapse

Instance Method Details

#calc(src_dir, files_hash = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/build/CheckSumCalculator.rb', line 59

def calc(src_dir, files_hash = nil)   
  if files_hash.nil?
    files_hash = Array.new 
  end
 
  Dir.foreach(src_dir) do |filename|
    next if filename.eql?('.') || filename.eql?('..')
        
    filepath = File.join(src_dir, filename)

    if File.directory?(filepath)
      calc(filepath, files_hash)
    else
      next if File.extname(filename) != ".obj"

      file = Hash.new
      file["name"] = filepath.to_s
      file["md5"]  = Digest::MD5.hexdigest(File.read(filepath.to_s)).to_s

      files_hash << file
    end
  end  
  
  files_hash
end