class Puppet::ModuleTool::Applications::Checksummer

Public Class Methods

new(path, options = {}) click to toggle source
   # File lib/puppet/module_tool/applications/checksummer.rb
 9 def initialize(path, options = {})
10   @path = Pathname.new(path)
11   super(options)
12 end

Public Instance Methods

run() click to toggle source
   # File lib/puppet/module_tool/applications/checksummer.rb
14 def run
15   changes = []
16   sums = Puppet::ModuleTool::Checksums.new(@path)
17   checksums.each do |child_path, canonical_checksum|
18 
19     # Avoid checksumming the checksums.json file
20     next if File.basename(child_path) == "checksums.json"
21 
22     path = @path + child_path
23     unless path.exist? && canonical_checksum == sums.checksum(path)
24       changes << child_path
25     end
26   end
27 
28   # Return an Array of strings representing file paths of files that have
29   # been modified since this module was installed. All paths are relative
30   # to the installed module directory. This return value is used by the
31   # module_tool face changes action, and displayed on the console.
32   #
33   # Example return value:
34   #
35   #   [ "REVISION", "manifests/init.pp"]
36   #
37   changes
38 end

Private Instance Methods

checksums() click to toggle source
   # File lib/puppet/module_tool/applications/checksummer.rb
42 def checksums
43   if checksums_file.exist?
44     Puppet::Util::Json.load(checksums_file.read)
45   elsif metadata_file.exist?
46     # Check metadata.json too; legacy modules store their checksums there.
47     Puppet::Util::Json.load(metadata_file.read)['checksums'] or
48     raise ArgumentError, _("No file containing checksums found.")
49   else
50     raise ArgumentError, _("No file containing checksums found.")
51   end
52 end
checksums_file() click to toggle source
   # File lib/puppet/module_tool/applications/checksummer.rb
58 def checksums_file
59   @path + 'checksums.json'
60 end
metadata_file() click to toggle source
   # File lib/puppet/module_tool/applications/checksummer.rb
54 def metadata_file
55   @path + 'metadata.json'
56 end