Class: Jets::Builders::Md5
- Inherits:
-
Object
- Object
- Jets::Builders::Md5
- Defined in:
- lib/jets/builders/md5.rb
Constant Summary collapse
- @@checksums =
{}
Class Method Summary collapse
Class Method Details
.checksums ⇒ Object
14 15 16 |
# File 'lib/jets/builders/md5.rb', line 14 def checksums @@checksums end |
.compute! ⇒ Object
28 29 30 31 32 33 |
# File 'lib/jets/builders/md5.rb', line 28 def compute! stage_folders.each do |path| @@checksums[path] = dir(path) end @@checksums end |
.dir(short_path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jets/builders/md5.rb', line 35 def dir(short_path) path = "#{Jets.build_root}/#{short_path}" files = Dir["#{path}/**/*"] files.reject! { |f| File.directory?(f) } .reject! { |f| File.symlink?(f) } content = files.map do |f| Digest::MD5.file(f).to_s[0..7] end.join # The stage/code md5 sha depends on the other 'symlinked' folders. if short_path == "stage/code" content += @@checksums.values.join end md5 = Digest::MD5.new md5.update(content) md5.hexdigest.to_s[0..7] end |
.stage_folders ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/jets/builders/md5.rb', line 18 def stage_folders paths = [] paths << "stage/bundled" if Jets.lazy_load? paths << "stage/rack" if Jets.rack? # Important to have stage/code at the end, since it will use the other # 'symlinked' folders to adjust the md5 hash. paths << "stage/code" paths end |