Class | Nanoc3::DependencyTracker |
In: |
lib/nanoc3/base/dependency_tracker.rb
|
Parent: | Object |
Responsible for remembering dependencies between items. 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 content. When one item uses an attribute of another item, then this is also treated as a dependency. While dependencies based on an item’s content (handled in {Nanoc3::Compiler}) cannot be mutually recursive, the more general dependencies in Nanoc3::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. This file also contains a version number; when a dependencies file with an incompatible version is found, it is ignored.
STORE_VERSION | = | 2 | The version of the file format used to store dependencies. |
filename | [RW] | @return [String] The name of the file in which dependency information is stored |
items | [R] | @return [Array<Nanoc3::Item>] The list of items that is being tracked by the dependency tracker |
Creates a new dependency tracker for the given items.
@param [Array<Nanoc3::Item>] item The list of items whose dependencies should be managed
Returns the direct dependencies for `item`.
The direct dependencies of `item` include the items that, when outdated will cause `item` 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).
@param [Nanoc3::Item] item The item for which to fetch the direct predecessors
@return [Array<Nanoc3::Item>] The direct predecessors of the given item
Returns the direct inverse dependencies for `item`.
The direct inverse dependencies of `item` include the items that will be marked as outdated when`+item` 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 [Nanoc3::Item] item The item for which to fetch the direct successors
@return [Array<Nanoc3::Item>] The direct successors of the given item
Empties the list of dependencies for the given item. This is necessary before recompiling the given item, because otherwise old dependencies will stick around and new dependencies will appear twice. This function removes all incoming edges for the given vertex.
@param [Nanoc3::Item] item The item for which to forget all dependencies
@return [void]
Loads the dependency graph from the file specified by the {filename} attribute. This method will overwrite an existing dependency graph.
@return [void]
Returns all dependencies (direct and indirect) for `item`.
The dependencies of `item` include the items that, when outdated, will cause `item` to be marked as outdated.
@param [Nanoc3::Item] item The item for which to fetch all direct and indirect predecessors
@return [Array<Nanoc3::Item>] The predecessors of the given item
Traverses the dependency graph and marks all items that (directly or indirectly) depend on an outdated item as outdated.
@return [void]
Records a dependency from `src` to `dst` in the dependency graph. When `dst` is oudated, `src` will also become outdated.
@param [Nanoc3::Item] src The source of the dependency, i.e. the item that will become outdated if dst is outdated
@param [Nanoc3::Item] dst The destination of the dependency, i.e. the item 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]
Returns all inverse dependencies (direct and indirect) for `item`.
The inverse dependencies of `item` include the items that will be marked as outdated when `item` is outdated.
@param [Nanoc3::Item] item The item for which to fetch all direct and indirect successors
@return [Array<Nanoc3::Item>] The successors of the given item