Sha256: 797a0b9e6087ce7c640e2a8cf9c83b15b6c1f5ae54721b3f39f25df27e5aed89

Contents?: true

Size: 830 Bytes

Versions: 7

Compression:

Stored size: 830 Bytes

Contents

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

    def run
      require 'set'

      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),
        )
    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

7 entries across 7 versions & 1 rubygems

Version Path
nanoc-4.6.1 lib/nanoc/checking/checks/stale.rb
nanoc-4.6.0 lib/nanoc/checking/checks/stale.rb
nanoc-4.5.4 lib/nanoc/checking/checks/stale.rb
nanoc-4.5.3 lib/nanoc/checking/checks/stale.rb
nanoc-4.5.2 lib/nanoc/checking/checks/stale.rb
nanoc-4.5.1 lib/nanoc/checking/checks/stale.rb
nanoc-4.5.0 lib/nanoc/checking/checks/stale.rb