lib/nanoc/base/services/outdatedness_checker.rb in nanoc-4.7.12 vs lib/nanoc/base/services/outdatedness_checker.rb in nanoc-4.7.13
- old
+ new
@@ -33,12 +33,22 @@
RULES_FOR_CONFIG =
[
Rules::AttributesModified,
].freeze
- C_OBJ_MAYBE_REP = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Configuration, Nanoc::Int::Layout]
+ RULES_FOR_ITEM_COLLECTION =
+ [
+ Rules::ItemCollectionExtended,
+ ].freeze
+ RULES_FOR_LAYOUT_COLLECTION =
+ [
+ Rules::LayoutCollectionExtended,
+ ].freeze
+
+ C_OBJ_MAYBE_REP = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Configuration, Nanoc::Int::Layout, Nanoc::Int::ItemCollection, Nanoc::Int::LayoutCollection]
+
contract C::KeywordArgs[outdatedness_checker: OutdatednessChecker, reps: Nanoc::Int::ItemRepRepo] => C::Any
def initialize(outdatedness_checker:, reps:)
@outdatedness_checker = outdatedness_checker
@reps = reps
end
@@ -52,10 +62,14 @@
apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
when Nanoc::Int::Layout
apply_rules(RULES_FOR_LAYOUT, obj)
when Nanoc::Int::Configuration
apply_rules(RULES_FOR_CONFIG, obj)
+ when Nanoc::Int::ItemCollection
+ apply_rules(RULES_FOR_ITEM_COLLECTION, obj)
+ when Nanoc::Int::LayoutCollection
+ apply_rules(RULES_FOR_LAYOUT_COLLECTION, obj)
else
raise Nanoc::Int::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
end
end
@@ -94,11 +108,12 @@
attr_reader :action_sequences
attr_reader :site
Reasons = Nanoc::Int::OutdatednessReasons
- C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Configuration, Nanoc::Int::Layout]
+ C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Configuration, Nanoc::Int::Layout, Nanoc::Int::ItemCollection]
+ C_ITEM_OR_REP = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep]
C_ACTION_SEQUENCES = C::HashOf[C_OBJ => Nanoc::Int::ActionSequence]
contract C::KeywordArgs[site: Nanoc::Int::Site, checksum_store: Nanoc::Int::ChecksumStore, checksums: Nanoc::Int::ChecksumCollection, dependency_store: Nanoc::Int::DependencyStore, action_sequence_store: Nanoc::Int::ActionSequenceStore, action_sequences: C_ACTION_SEQUENCES, reps: Nanoc::Int::ItemRepRepo] => C::Any
def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
@site = site
@@ -138,11 +153,11 @@
contract C::None => Basic
def basic
@_basic ||= Basic.new(outdatedness_checker: self, reps: @reps)
end
- contract C_OBJ, Hamster::Set => C::Bool
+ contract C_ITEM_OR_REP, Hamster::Set => C::Bool
def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
# Convert from rep to item if necessary
obj = obj.item if obj.is_a?(Nanoc::Int::ItemRep)
# Get from cache
@@ -174,21 +189,29 @@
return true if dependency.from.nil?
status = basic.outdatedness_status_for(dependency.from)
active = status.props.active & dependency.props.active
- if attributes_unaffected?(status, dependency)
- active.delete(:attributes)
- end
+ active.delete(:attributes) if attributes_unaffected?(status, dependency)
+ active.delete(:raw_content) if raw_content_unaffected?(status, dependency)
active.any?
end
def attributes_unaffected?(status, dependency)
- attr_reason = status.reasons.find do |r|
- r.is_a?(Nanoc::Int::OutdatednessReasons::AttributesModified)
- end
+ reason = status.reasons.find { |r| r.is_a?(Nanoc::Int::OutdatednessReasons::AttributesModified) }
+ reason && dependency.props.attributes.is_a?(Enumerable) && (dependency.props.attributes & reason.attributes).empty?
+ end
- attr_reason && dependency.props.attributes.is_a?(Enumerable) && (dependency.props.attributes & attr_reason.attributes).empty?
+ def raw_content_unaffected?(status, dependency)
+ reason = status.reasons.find { |r| r.is_a?(Nanoc::Int::OutdatednessReasons::DocumentCollectionExtended) }
+ if reason.nil?
+ false
+ elsif !dependency.props.raw_content.is_a?(Enumerable)
+ false
+ else
+ patterns = dependency.props.raw_content.map { |r| Nanoc::Int::Pattern.from(r) }
+ patterns.none? { |pat| reason.objects.any? { |obj| pat.match?(obj.identifier) } }
+ end
end
end
end