Sha256: 1a228fc900a701aed5602a0004d35332c7608e0117aa5e5563dd00fb61ab271d

Contents?: true

Size: 789 Bytes

Versions: 13

Compression:

Stored size: 789 Bytes

Contents

module Nanoc::Extra::Checking::Checks
  # @api private
  class Stale < ::Nanoc::Extra::Checking::Check
    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, [])
      @pruner ||= Nanoc::Extra::Pruner.new(@site, exclude: exclude_config)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
nanoc-4.3.7 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.6 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.5 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.4 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.3 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.2 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.1 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.3.0 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.2.4 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.2.3 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.2.2 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.2.1 lib/nanoc/extra/checking/checks/stale.rb
nanoc-4.2.0 lib/nanoc/extra/checking/checks/stale.rb