Sha256: f0b2e28a8c176f424a2974394cba3f7deb9500ce88e42ccd215687d49f4a2fbd
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Nanoc module Int class Compiler module Stages class DetermineOutdatedness < Nanoc::Int::Compiler::Stage include Nanoc::Core::ContractsSupport def initialize(reps:, outdatedness_checker:, outdatedness_store:) @reps = reps @outdatedness_checker = outdatedness_checker @outdatedness_store = outdatedness_store end contract C::None => C::Any def run outdated_items = select_outdated_items outdated_reps = reps_of_items(outdated_items) store_outdated_reps(outdated_reps) outdated_items end private def store_outdated_reps(reps) @outdatedness_store.clear reps.each { |r| @outdatedness_store.add(r) } end def select_outdated_items @reps .select { |r| outdated?(r) } .map(&:item) .uniq end def reps_of_items(items) Set.new(items.flat_map { |i| @reps[i] }) end def outdated?(rep) @outdatedness_store.include?(rep) || @outdatedness_checker.outdated?(rep) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems