Sha256: cf972748a62f48681c69d1e1b3d621f6a5a5342c48faf00684a0f96f8a2edc4a

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Nanoc
  module Int
    class Compiler
      module Stages
        class CalculateChecksums < Nanoc::Core::CompilationStage
          def initialize(items:, layouts:, code_snippets:, config:)
            @items = items
            @layouts = layouts
            @code_snippets = code_snippets
            @config = config
          end

          def run
            checksums = {}

            [@items, @layouts].each do |documents|
              documents.each do |document|
                checksums[[document.reference, :content]] =
                  Nanoc::Core::Checksummer.calc_for_content_of(document)
                checksums[[document.reference, :each_attribute]] =
                  Nanoc::Core::Checksummer.calc_for_each_attribute_of(document)
              end
            end

            [@items, @layouts, @code_snippets].each do |objs|
              objs.each do |obj|
                checksums[obj.reference] = Nanoc::Core::Checksummer.calc(obj)
              end
            end

            checksums[@config.reference] =
              Nanoc::Core::Checksummer.calc(@config)
            checksums[[@config.reference, :each_attribute]] =
              Nanoc::Core::Checksummer.calc_for_each_attribute_of(@config)

            Nanoc::Core::ChecksumCollection.new(checksums)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc-4.11.12 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.11 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.10 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb