Module: Dapp::Helper::Sha256

Included in:
Build::Stage::Base, Dimg, Project
Defined in:
lib/dapp/helper/sha256.rb

Overview

Sha256

Instance Method Summary collapse

Instance Method Details

#hashsum(arg) ⇒ Object



5
6
7
# File 'lib/dapp/helper/sha256.rb', line 5

def hashsum(arg)
  sha256(arg)
end

#paths_content_hashsum(paths) ⇒ Object



9
10
11
12
13
14
# File 'lib/dapp/helper/sha256.rb', line 9

def paths_content_hashsum(paths)
  paths.map(&:to_s)
       .reject { |path| File.directory?(path) }
       .sort
       .reduce(nil) { |hash, path| hashsum [hash, File.read(path)].compact }
end

#sha256(arg) ⇒ Object



16
17
18
# File 'lib/dapp/helper/sha256.rb', line 16

def sha256(arg)
  Digest::SHA256.hexdigest Array(arg).compact.map(&:to_s).join(':::')
end