Sha256: a255f383da9d7ccd07b92dbc5c6464b03d0ab0830240858fae032508b746c5eb

Contents?: true

Size: 1.6 KB

Versions: 32

Compression:

Stored size: 1.6 KB

Contents

require 'puppet/module_tool/checksums'

module Puppet::ModuleTool
  module Applications
    class Checksummer < Application

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

      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
            unless path.exist? && 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

      private

      def metadata
        PSON.parse(metadata_file.read)
      end

      def metadata_file
        (@path + 'metadata.json')
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
puppet-3.3.1.rc1 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.3.0 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.3.0.rc3 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.3.0.rc2 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.4 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.3 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.3.rc1 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.2 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.1 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.1.rc1 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.0.rc2 lib/puppet/module_tool/applications/checksummer.rb
puppet-3.2.0.rc1 lib/puppet/module_tool/applications/checksummer.rb