Sha256: 6959aa5b3fc20f7225ddabe4f9a25cf6af61e290fa9682d828eb03f12125b2cf

Contents?: true

Size: 851 Bytes

Versions: 13

Compression:

Stored size: 851 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)
            .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

13 entries across 13 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.8 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.7 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.6 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.5 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.4 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.3 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.2 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.1 lib/nanoc/checking/checks/stale.rb
nanoc-4.7.0 lib/nanoc/checking/checks/stale.rb
nanoc-4.6.4 lib/nanoc/checking/checks/stale.rb
nanoc-4.6.3 lib/nanoc/checking/checks/stale.rb
nanoc-4.6.2 lib/nanoc/checking/checks/stale.rb