Class: Puppet::ModuleTool::Applications::Checksummer

Inherits:
Application show all
Defined in:
lib/vendor/puppet/module_tool/applications/checksummer.rb

Constant Summary

Constants included from Util::Colors

Util::Colors::BG_BLUE, Util::Colors::BG_CYAN, Util::Colors::BG_GREEN, Util::Colors::BG_HBLUE, Util::Colors::BG_HCYAN, Util::Colors::BG_HGREEN, Util::Colors::BG_HMAGENTA, Util::Colors::BG_HRED, Util::Colors::BG_HWHITE, Util::Colors::BG_HYELLOW, Util::Colors::BG_MAGENTA, Util::Colors::BG_RED, Util::Colors::BG_WHITE, Util::Colors::BG_YELLOW, Util::Colors::BLACK, Util::Colors::BLUE, Util::Colors::CYAN, Util::Colors::Colormap, Util::Colors::GREEN, Util::Colors::HBLACK, Util::Colors::HBLUE, Util::Colors::HCYAN, Util::Colors::HGREEN, Util::Colors::HMAGENTA, Util::Colors::HRED, Util::Colors::HWHITE, Util::Colors::HYELLOW, Util::Colors::MAGENTA, Util::Colors::RED, Util::Colors::RESET, Util::Colors::WHITE, Util::Colors::YELLOW

Instance Attribute Summary

Attributes inherited from Application

#options

Instance Method Summary collapse

Methods inherited from Application

#discuss, #load_modulefile!, #parse_filename, run

Methods included from Util::Colors

#colorize, #console_color, #console_has_color?, #html_color

Constructor Details

#initialize(path, options = {}) ⇒ Checksummer

Returns a new instance of Checksummer.



7
8
9
10
# File 'lib/vendor/puppet/module_tool/applications/checksummer.rb', line 7

def initialize(path, options = {})
  @path = Pathname.new(path)
  super(options)
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/vendor/puppet/module_tool/applications/checksummer.rb', line 12

def run
  changes = []
  if .exist?
    sums = Puppet::ModuleTool::Checksums.new(@path)
    (['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