class Nanoc::Core::CompilationStages::DetermineOutdatedness

Public Class Methods

new(reps:, outdatedness_checker:, outdatedness_store:) click to toggle source
# File lib/nanoc/core/compilation_stages/determine_outdatedness.rb, line 9
def initialize(reps:, outdatedness_checker:, outdatedness_store:)
  @reps = reps
  @outdatedness_checker = outdatedness_checker
  @outdatedness_store = outdatedness_store
end

Public Instance Methods

run() click to toggle source
# File lib/nanoc/core/compilation_stages/determine_outdatedness.rb, line 16
def run
  outdated_items = select_outdated_items
  outdated_reps = reps_of_items(outdated_items)

  store_outdated_reps(outdated_reps)

  outdated_items
end

Private Instance Methods

outdated?(rep) click to toggle source
# File lib/nanoc/core/compilation_stages/determine_outdatedness.rb, line 43
def outdated?(rep)
  @outdatedness_store.include?(rep) || @outdatedness_checker.outdated?(rep)
end
reps_of_items(items) click to toggle source
# File lib/nanoc/core/compilation_stages/determine_outdatedness.rb, line 39
def reps_of_items(items)
  Set.new(items.flat_map { |i| @reps[i] })
end
select_outdated_items() click to toggle source
# File lib/nanoc/core/compilation_stages/determine_outdatedness.rb, line 32
def select_outdated_items
  @reps
    .select { |r| outdated?(r) }
    .map(&:item)
    .uniq
end
store_outdated_reps(reps) click to toggle source
# File lib/nanoc/core/compilation_stages/determine_outdatedness.rb, line 27
def store_outdated_reps(reps)
  @outdatedness_store.clear
  reps.each { |r| @outdatedness_store.add(r) }
end