lib/nanoc/base/repos/dependency_store.rb in nanoc-4.4.4 vs lib/nanoc/base/repos/dependency_store.rb in nanoc-4.4.5

- old
+ new

@@ -9,11 +9,12 @@ # @param [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] objects def initialize(objects, env_name: nil) super(Nanoc::Int::Store.tmp_path_for(env_name: env_name, store_name: 'dependencies'), 4) @objects = objects - @graph = Nanoc::Int::DirectedGraph.new([nil] + @objects) + @new_objects = [] + @graph = Nanoc::Int::DirectedGraph.new([nil] + @objects) end contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::ArrayOf[Nanoc::Int::Dependency] def dependencies_causing_outdatedness_of(object) objects_causing_outdatedness_of(object).map do |other_object| @@ -48,30 +49,17 @@ # # @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout, nil>] The direct # predecessors of # the given object def objects_causing_outdatedness_of(object) - @graph.direct_predecessors_of(object) + if @new_objects.any? + [@new_objects.first] + else + @graph.direct_predecessors_of(object) + end end - # Returns the direct inverse dependencies for the given object. - # - # The direct inverse dependencies of the given object include the objects - # that will be marked as outdated when the given object is outdated. - # Indirect dependencies will not be returned (e.g. if A depends on B which - # depends on C, then the direct inverse dependencies of C do not include - # A). - # - # @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for which to - # fetch the direct successors - # - # @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] The direct successors of - # the given object - def objects_outdated_due_to(object) - @graph.direct_successors_of(object).compact - end - contract C::Maybe[C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]], C::Maybe[C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C::Bool], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any # Records a dependency from `src` to `dst` in the dependency graph. When # `dst` is oudated, `src` will also become outdated. # # @param [Nanoc::Int::Item, Nanoc::Int::Layout] src The source of the dependency, @@ -139,16 +127,9 @@ to = to_index && previous_objects[to_index] @graph.add_edge(from, to, props: props) end # Record dependency from all items on new items - new_objects = (@objects - previous_objects) - new_props = { raw_content: true, attributes: true, compiled_content: true, path: true } - new_objects.each do |new_obj| - @objects.each do |obj| - next unless obj.is_a?(Nanoc::Int::Item) - @graph.add_edge(new_obj, obj, props: new_props) - end - end + @new_objects = @objects - previous_objects end end end