Class: Nanoc::Int::Compiler::Stages::DetermineOutdatedness

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb

Instance Method Summary collapse

Constructor Details

#initialize(reps:, outdatedness_checker:, outdatedness_store:) ⇒ DetermineOutdatedness

Returns a new instance of DetermineOutdatedness



7
8
9
10
11
# File 'lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb', line 7

def initialize(reps:, outdatedness_checker:, outdatedness_store:)
  @reps = reps
  @outdatedness_checker = outdatedness_checker
  @outdatedness_store = outdatedness_store
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb', line 14

def run
  outdated_reps_tmp = @reps.select do |r|
    @outdatedness_store.include?(r) || @outdatedness_checker.outdated?(r)
  end

  outdated_items = outdated_reps_tmp.map(&:item).uniq
  outdated_reps = Set.new(outdated_items.flat_map { |i| @reps[i] })

  outdated_reps.each { |r| @outdatedness_store.add(r) }

  outdated_items
end