Sha256: 07a85f40a7d4f12a4febc52cf0df12d731603011a86eb53c95f5856815ca9df0

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Nanoc
  module Int
    class Compiler
      module Stages
        class CalculateChecksums < Nanoc::Int::Compiler::Stage
          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

7 entries across 7 versions & 1 rubygems

Version Path
nanoc-4.11.9 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.8 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.7 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.6 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.5 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.4 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
nanoc-4.11.3 lib/nanoc/base/services/compiler/stages/calculate_checksums.rb