Class Nanoc::DependencyTracker
In: lib/nanoc/base/compilation/dependency_tracker.rb
Parent: ::Nanoc::Store

Responsible for remembering dependencies between items and layouts. It is used to speed up compilation by only letting an item be recompiled when it is outdated or any of its dependencies (or dependencies’ dependencies, etc) is outdated.

The dependencies tracked by the dependency tracker are not dependencies based on an item’s or a layout’s content. When one object uses an attribute of another object, then this is also treated as a dependency. While dependencies based on an item’s or layout’s content (handled in {Nanoc::Compiler}) cannot be mutually recursive, the more general dependencies in Nanoc::DependencyTracker can (e.g. item A can use an attribute of item B and vice versa without problems).

The dependency tracker remembers the dependency information between runs. Dependency information is stored in the `tmp/dependencies` file.

@api private

Methods

Attributes

compiler  [RW]  @return [Nanoc::Compiler] The compiler that corresponds to this
  dependency tracker
objects  [R]  @return [Array<Nanoc::Item, Nanoc::Layout>] The list of items and
  layouts that are being tracked by the dependency tracker

Public Class methods

Creates a new dependency tracker for the given items and layouts.

@param [Array<Nanoc::Item, Nanoc::Layout>] objects The list of items

  and layouts whose dependencies should be managed

Public Instance methods

Empties the list of dependencies for the given object. This is necessary before recompiling the given object, because otherwise old dependencies will stick around and new dependencies will appear twice. This function removes all incoming edges for the given vertex.

@api private

@param [Nanoc::Item, Nanoc::Layout] object The object for which to

  forget all dependencies

@return [void]

@deprecated Use {load} instead

Returns the direct dependencies for the given object.

The direct dependencies of the given object include the items and layouts that, when outdated will cause the given object to be marked as outdated. Indirect dependencies will not be returned (e.g. if A depends on B which depends on C, then the direct dependencies of A do not include C).

The direct predecessors can include nil, which indicates an item that is no longer present in the site.

@param [Nanoc::Item, Nanoc::Layout] object The object for

  which to fetch the direct predecessors

@return [Array<Nanoc::Item, Nanoc::Layout, nil>] The direct predecessors of

  the given object

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::Item, Nanoc::Layout] object The object for which to

  fetch the direct successors

@return [Array<Nanoc::Item, Nanoc::Layout>] The direct successors of

  the given object

Records a dependency from `src` to `dst` in the dependency graph. When `dst` is oudated, `src` will also become outdated.

@param [Nanoc::Item, Nanoc::Layout] src The source of the dependency,

  i.e. the object that will become outdated if dst is outdated

@param [Nanoc::Item, Nanoc::Layout] dst The destination of the

  dependency, i.e. the object that will cause the source to become
  outdated if the destination is outdated

@return [void]

Starts listening for dependency messages (`:visit_started` and `:visit_ended`) and start recording dependencies.

@return [void]

Stop listening for dependency messages and stop recording dependencies.

@return [void]

@deprecated Use {store} instead

@return The topmost item on the stack, i.e. the one currently being

  compiled

@api private

Protected Instance methods

[Validate]