Class: Nanoc::Int::DependencyStore Private

Inherits:
Store
  • Object
show all
Defined in:
lib/nanoc/base/repos/dependency_store.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Attributes inherited from Store

#filename, #version

Instance Method Summary collapse

Methods inherited from Store

#load, #no_data_found, #store, #version_mismatch_detected

Constructor Details

#initialize(objects) ⇒ DependencyStore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DependencyStore.

Parameters:



8
9
10
11
12
13
# File 'lib/nanoc/base/repos/dependency_store.rb', line 8

def initialize(objects)
  super('tmp/dependencies', 4)

  @objects = objects
  @graph   = Nanoc::Int::DirectedGraph.new([nil] + @objects)
end

Instance Attribute Details

#objectsArray<Nanoc::Int::Item, Nanoc::Int::Layout>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
# File 'lib/nanoc/base/repos/dependency_store.rb', line 5

def objects
  @objects
end

Instance Method Details

#forget_dependencies_for(object) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

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.

Parameters:



78
79
80
# File 'lib/nanoc/base/repos/dependency_store.rb', line 78

def forget_dependencies_for(object)
  @graph.delete_edges_to(object)
end

#objects_causing_outdatedness_of(object) ⇒ Array<Nanoc::Int::Item, Nanoc::Int::Layout, nil>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

predecessors of

the given object

Parameters:

Returns:



32
33
34
# File 'lib/nanoc/base/repos/dependency_store.rb', line 32

def objects_causing_outdatedness_of(object)
  @graph.direct_predecessors_of(object)
end

#objects_outdated_due_to(object) ⇒ Array<Nanoc::Int::Item, Nanoc::Int::Layout>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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).

Parameters:

Returns:



49
50
51
# File 'lib/nanoc/base/repos/dependency_store.rb', line 49

def objects_outdated_due_to(object)
  @graph.direct_successors_of(object).compact
end

#record_dependency(src, dst) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

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

Parameters:



64
65
66
67
# File 'lib/nanoc/base/repos/dependency_store.rb', line 64

def record_dependency(src, dst)
  # Warning! dst and src are *reversed* here!
  @graph.add_edge(dst, src) unless src == dst
end