class Puppet::ModuleTool::Applications::Checksummer

Public Class Methods

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

Public Instance Methods

run() click to toggle source
# File lib/puppet/module_tool/applications/checksummer.rb, line 12
def run
  changes = []
  if metadata_file.exist?
    sums = Puppet::ModuleTool::Checksums.new(@path)
    (metadata['checksums'] || {}).each do |child_path, canonical_checksum|

      # Work around an issue where modules built with an older version
      # of PMT would include the metadata.json file in the list of files
      # checksummed. This causes metadata.json to always report local
      # changes.
      next if File.basename(child_path) == "metadata.json"

      path = @path + child_path
      if canonical_checksum != sums.checksum(path)
        changes << child_path
      end
    end
  else
    raise ArgumentError, "No metadata.json found."
  end

  # Return an Array of strings representing file paths of files that have
  # been modified since this module was installed. All paths are relative
  # to the installed module directory. This return value is used by the
  # module_tool face changes action, and displayed on the console.
  #
  # Example return value:
  #
  #   [ "REVISION", "manifests/init.pp"]
  #
  changes
end