Sha256: f0fea2be1c1fe1100f4a31740d3a36529a2075e1755d4619f8132dfce6a7540a

Contents?: true

Size: 862 Bytes

Versions: 24

Compression:

Stored size: 862 Bytes

Contents

# frozen_string_literal: true

module Nanoc::Checking::Checks
  # @api private
  class Stale < ::Nanoc::Checking::Check
    identifier :stale

    def run
      output_filenames.each do |f|
        next if pruner.filename_excluded?(f)
        next if item_rep_paths.include?(f)

        add_issue(
          'file without matching item',
          subject: f,
        )
      end
    end

    protected

    def item_rep_paths
      @item_rep_paths ||=
        Set.new(
          @items
            .flat_map(&:reps)
            .map(&:_unwrap)
            .flat_map(&:raw_paths)
            .flat_map(&:values)
            .flatten,
        )
    end

    def pruner
      exclude_config = @config.fetch(:prune, {}).fetch(:exclude, [])
      # FIXME: reps=nil is icky
      @pruner ||= Nanoc::Pruner.new(@config, nil, exclude: exclude_config)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
nanoc-4.11.9 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.8 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.7 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.6 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.5 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.4 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.3 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.2 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.1 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.0 lib/nanoc/checking/checks/stale.rb
nanoc-4.10.4 lib/nanoc/checking/checks/stale.rb
nanoc-4.10.3 lib/nanoc/checking/checks/stale.rb
nanoc-4.10.2 lib/nanoc/checking/checks/stale.rb
nanoc-4.10.1 lib/nanoc/checking/checks/stale.rb
nanoc-4.10.0 lib/nanoc/checking/checks/stale.rb
nanoc-4.9.9 lib/nanoc/checking/checks/stale.rb
nanoc-4.9.8 lib/nanoc/checking/checks/stale.rb
nanoc-4.9.7 lib/nanoc/checking/checks/stale.rb
nanoc-4.9.6 lib/nanoc/checking/checks/stale.rb
nanoc-4.9.5 lib/nanoc/checking/checks/stale.rb