class Nanoc::Core::OutdatednessChecker::Basic

Constants

C_OBJ_MAYBE_REP
RULES_FOR_CONFIG
RULES_FOR_ITEM_COLLECTION
RULES_FOR_ITEM_REP
RULES_FOR_LAYOUT
RULES_FOR_LAYOUT_COLLECTION
Rules

Public Class Methods

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

Public Instance Methods

outdatedness_status_for(obj) click to toggle source
# File lib/nanoc/core/outdatedness_checker.rb, line 58
         def outdatedness_status_for(obj)
  case obj
  when Nanoc::Core::ItemRep
    apply_rules(RULES_FOR_ITEM_REP, obj)
  when Nanoc::Core::Item
    apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
  when Nanoc::Core::Layout
    apply_rules(RULES_FOR_LAYOUT, obj)
  when Nanoc::Core::Configuration
    apply_rules(RULES_FOR_CONFIG, obj)
  when Nanoc::Core::ItemCollection
    apply_rules(RULES_FOR_ITEM_COLLECTION, obj)
  when Nanoc::Core::LayoutCollection
    apply_rules(RULES_FOR_LAYOUT_COLLECTION, obj)
  else
    raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
  end
end

Private Instance Methods

apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new) click to toggle source
# File lib/nanoc/core/outdatedness_checker.rb, line 80
def apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new)
  rules.inject(status) do |acc, rule|
    if !acc.useful_to_apply?(rule)
      acc
    else
      reason = rule.instance.call(obj, @outdatedness_checker)
      if reason
        acc.update(reason)
      else
        acc
      end
    end
  end
end
apply_rules_multi(rules, objs) click to toggle source
# File lib/nanoc/core/outdatedness_checker.rb, line 96
def apply_rules_multi(rules, objs)
  objs.inject(Nanoc::Core::OutdatednessStatus.new) { |acc, elem| apply_rules(rules, elem, acc) }
end