Sha256: 8788d2a8f78428ffc02944f205ebf094f4c2f076c76b6ae167631f5948118719

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

module Nanoc::Int::OutdatednessRules
  class CodeSnippetsModified < Nanoc::Int::OutdatednessRule
    DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)

    include Nanoc::Int::ContractsSupport

    affects_props :raw_content, :attributes, :compiled_content, :path

    def apply(_obj, outdatedness_checker)
      if any_snippets_modified?(outdatedness_checker)
        Nanoc::Int::OutdatednessReasons::CodeSnippetsModified
      end
    end

    private

    memoized def any_snippets_modified?(outdatedness_checker)
      outdatedness_checker.site.code_snippets.any? do |cs|
        ch_old = outdatedness_checker.checksum_store[cs]
        ch_new = outdatedness_checker.checksums.checksum_for(cs)
        ch_old != ch_new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-4.8.17 lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb