@@ -187,7 +187,9 @@ def dependency_causes_outdatedness?(dependency)
187187 true
188188 when Nanoc ::Core ::ItemCollection , Nanoc ::Core ::LayoutCollection
189189 all_objects = dependency . from
190- raw_content_prop_causes_outdatedness? ( all_objects , dependency . props . raw_content )
190+
191+ raw_content_prop_causes_outdatedness? ( all_objects , dependency . props . raw_content ) ||
192+ attributes_prop_causes_outdatedness? ( all_objects , dependency . props . attributes )
191193 else
192194 status = basic . outdatedness_status_for ( dependency . from )
193195
@@ -200,10 +202,12 @@ def dependency_causes_outdatedness?(dependency)
200202
201203 def attributes_unaffected? ( status , dependency )
202204 reason = status . reasons . find { |r | r . is_a? ( Nanoc ::Core ::OutdatednessReasons ::AttributesModified ) }
203- reason && dependency . props . attributes . is_a? ( Enumerable ) && ( dependency . props . attributes & reason . attributes ) . empty?
205+ reason && dependency . props . attribute_keys . any? && ( dependency . props . attribute_keys & reason . attributes ) . empty?
204206 end
205207
206208 def raw_content_prop_causes_outdatedness? ( objects , raw_content_prop )
209+ return false unless raw_content_prop
210+
207211 matching_objects =
208212 case raw_content_prop
209213 when true
@@ -236,6 +240,49 @@ def raw_content_prop_causes_outdatedness?(objects, raw_content_prop)
236240 status . reasons . any? { |r | Nanoc ::Core ::OutdatednessReasons ::DocumentAdded == r }
237241 end
238242 end
243+
244+ def attributes_prop_causes_outdatedness? ( objects , attributes_prop )
245+ return false unless attributes_prop
246+
247+ unless attributes_prop . is_a? ( Set )
248+ raise 'not expected'
249+ end
250+
251+ pairs = attributes_prop . select { |a | a . is_a? ( Array ) } . to_h
252+
253+ unless pairs . any?
254+ raise 'not expected'
255+ end
256+
257+ dep_checksums = pairs . transform_values { |value | Nanoc ::Core ::Checksummer . calc ( value ) }
258+
259+ objects . any? do |object |
260+ # Find old and new attribute checksums for the object
261+ old_object_checksums = checksum_store . attributes_checksum_for ( object )
262+ next false unless old_object_checksums
263+
264+ new_object_checksums = checksums . attributes_checksum_for ( object )
265+
266+ # Ignore any attribute not mentioned in the dependency
267+ old_object_checksums = old_object_checksums . select { |k , _v | dep_checksums . key? ( k ) }
268+ new_object_checksums = new_object_checksums . select { |k , _v | dep_checksums . key? ( k ) }
269+
270+ dep_checksums . any? do |key , dep_value |
271+ # Get old and new checksum for this particular attribute
272+ old_value = old_object_checksums [ key ]
273+ new_value = new_object_checksums [ key ]
274+
275+ # If either the old or new vale match the value in the dependency,
276+ # then a potential change is relevant to us, and can cause
277+ # outdatedness.
278+ is_match = [ old_value , new_value ] . include? ( dep_value )
279+
280+ is_changed = old_value != new_value
281+
282+ is_match && is_changed
283+ end
284+ end
285+ end
239286 end
240287 end
241288end
0 commit comments