lib/nanoc/base/compilation/dependency_tracker.rb in nanoc-3.7.3 vs lib/nanoc/base/compilation/dependency_tracker.rb in nanoc-3.7.4

- old
+ new

@@ -35,11 +35,11 @@ # and layouts whose dependencies should be managed def initialize(objects) super('tmp/dependencies', 4) @objects = objects - @graph = Nanoc::DirectedGraph.new([ nil ] + @objects) + @graph = Nanoc::DirectedGraph.new([nil] + @objects) @stack = [] end # Starts listening for dependency messages (`:visit_started` and # `:visit_ended`) and start recording dependencies. @@ -51,29 +51,29 @@ # on all objects pushed above it. @stack = [] # Register start of visits Nanoc::NotificationCenter.on(:visit_started, self) do |obj| - if !@stack.empty? + unless @stack.empty? Nanoc::NotificationCenter.post(:dependency_created, @stack.last, obj) record_dependency(@stack.last, obj) end @stack.push(obj) end # Register end of visits - Nanoc::NotificationCenter.on(:visit_ended, self) do |obj| + Nanoc::NotificationCenter.on(:visit_ended, self) do |_obj| @stack.pop end end # Stop listening for dependency messages and stop recording dependencies. # # @return [void] def stop # Sanity check - if !@stack.empty? + unless @stack.empty? raise 'Internal inconsistency: dependency tracker stack not empty at end of compilation' end # Unregister Nanoc::NotificationCenter.remove(:visit_started, self) @@ -167,24 +167,24 @@ load end # @see Nanoc::Store#unload def unload - @graph = Nanoc::DirectedGraph.new([ nil ] + @objects) + @graph = Nanoc::DirectedGraph.new([nil] + @objects) end - protected + protected def data { :edges => @graph.edges, :vertices => @graph.vertices.map { |obj| obj && obj.reference } } end def data=(new_data) # Create new graph - @graph = Nanoc::DirectedGraph.new([ nil ] + @objects) + @graph = Nanoc::DirectedGraph.new([nil] + @objects) # Load vertices previous_objects = new_data[:vertices].map do |reference| @objects.find { |obj| reference == obj.reference } end