Class: Puppet::Module::Tool::Checksums
- Inherits:
-
Object
- Object
- Puppet::Module::Tool::Checksums
- Includes:
- Enumerable
- Defined in:
- lib/puppet/module/tool/checksums.rb
Overview
Checksums
This class proides methods for generating checksums for data and adding them to Metadata
.
Instance Method Summary collapse
-
#annotate(metadata) ⇒ Object
Update
Metadata
‘s checksums with this object’s. -
#checksum(pathname) ⇒ Object
Return checksum for the
Pathname
. -
#data ⇒ Object
Return checksums for object’s
Pathname
, generate if it’s needed. -
#each(&block) ⇒ Object
TODO: Why?.
-
#initialize(path) ⇒ Checksums
constructor
Instantiate object with string
path
to create checksums from.
Constructor Details
#initialize(path) ⇒ Checksums
Instantiate object with string path
to create checksums from.
13 14 15 |
# File 'lib/puppet/module/tool/checksums.rb', line 13 def initialize(path) @path = Pathname.new(path) end |
Instance Method Details
#annotate(metadata) ⇒ Object
Update Metadata
‘s checksums with this object’s.
45 46 47 |
# File 'lib/puppet/module/tool/checksums.rb', line 45 def annotate() .checksums.replace(data) end |
#checksum(pathname) ⇒ Object
Return checksum for the Pathname
.
18 19 20 |
# File 'lib/puppet/module/tool/checksums.rb', line 18 def checksum(pathname) return Digest::MD5.hexdigest(pathname.read) end |
#data ⇒ Object
Return checksums for object’s Pathname
, generate if it’s needed. Result is a hash of path strings to checksum strings.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/module/tool/checksums.rb', line 24 def data unless @data @data = {} @path.find do |descendant| if Puppet::Module::Tool.artifact?(descendant) Find.prune elsif descendant.file? path = descendant.relative_path_from(@path) @data[path.to_s] = checksum(descendant) end end end return @data end |
#each(&block) ⇒ Object
TODO: Why?
40 41 42 |
# File 'lib/puppet/module/tool/checksums.rb', line 40 def each(&block) data.each(&block) end |