Sha256: ec0266bf8548eef336873ecac663fd622ed92bd39f40de4bb317426cc17ee221

Contents?: true

Size: 929 Bytes

Versions: 3

Compression:

Stored size: 929 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: specifying reps this way is icky
      reps = Nanoc::Core::ItemRepRepo.new
      @pruner ||= Nanoc::Pruner.new(@config._unwrap, reps, exclude: exclude_config)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nanoc-4.11.12 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.11 lib/nanoc/checking/checks/stale.rb
nanoc-4.11.10 lib/nanoc/checking/checks/stale.rb