lib/nanoc/base/services/outdatedness_checker.rb in nanoc-4.7.3 vs lib/nanoc/base/services/outdatedness_checker.rb in nanoc-4.7.4
- old
+ new
@@ -79,38 +79,47 @@
include Nanoc::Int::ContractsSupport
attr_reader :checksum_store
attr_reader :dependency_store
- attr_reader :rule_memory_store
+ attr_reader :action_sequence_store
attr_reader :action_provider
attr_reader :site
Reasons = Nanoc::Int::OutdatednessReasons
+ C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout]
+
# FIXME: Replace C::Any with proper types
- contract C::KeywordArgs[site: Nanoc::Int::Site, checksum_store: Nanoc::Int::ChecksumStore, dependency_store: Nanoc::Int::DependencyStore, rule_memory_store: Nanoc::Int::RuleMemoryStore, action_provider: C::Any, reps: Nanoc::Int::ItemRepRepo] => C::Any
- def initialize(site:, checksum_store:, dependency_store:, rule_memory_store:, action_provider:, reps:)
+ contract C::KeywordArgs[site: Nanoc::Int::Site, checksum_store: Nanoc::Int::ChecksumStore, dependency_store: Nanoc::Int::DependencyStore, action_sequence_store: Nanoc::Int::ActionSequenceStore, action_provider: C::Any, reps: Nanoc::Int::ItemRepRepo] => C::Any
+ def initialize(site:, checksum_store:, dependency_store:, action_sequence_store:, action_provider:, reps:)
@site = site
@checksum_store = checksum_store
@dependency_store = dependency_store
- @rule_memory_store = rule_memory_store
+ @action_sequence_store = action_sequence_store
@action_provider = action_provider
@reps = reps
@objects_outdated_due_to_dependencies = {}
end
- contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Bool
+ def action_sequence_for(rep)
+ # TODO: Pass in action_sequences instead
+ @action_provider.action_sequence_for(rep)
+ end
+ memoize :action_sequence_for
+
+ contract C_OBJ, C::Maybe[C::HashOf[C_OBJ => Nanoc::Int::ActionSequence]] => C::Bool
# Checks whether the given object is outdated and therefore needs to be
# recompiled.
#
# @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
# whose outdatedness should be checked.
#
# @return [Boolean] true if the object is outdated, false otherwise
- def outdated?(obj)
+ def outdated?(obj, _action_sequences = nil)
+ # TODO: use action_sequences
!outdatedness_reason_for(obj).nil?
end
contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Maybe[Reasons::Generic]
# Calculates the reason why the given object is outdated.
@@ -174,9 +183,23 @@
contract Nanoc::Int::Dependency => C::Bool
def dependency_causes_outdatedness?(dependency)
return true if dependency.from.nil?
status = basic.outdatedness_status_for(dependency.from)
- (status.props.active & dependency.props.active).any?
+
+ active = status.props.active & dependency.props.active
+ if attributes_unaffected?(status, dependency)
+ active.delete(:attributes)
+ end
+
+ active.any?
+ end
+
+ def attributes_unaffected?(status, dependency)
+ attr_reason = status.reasons.find do |r|
+ r.is_a?(Nanoc::Int::OutdatednessReasons::AttributesModified)
+ end
+
+ attr_reason && dependency.props.attributes.is_a?(Enumerable) && (dependency.props.attributes & attr_reason.attributes).empty?
end
end
end