Class: Yarrow::Content::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/yarrow/content/graph.rb

Overview

A directed graph of every element of content in the project.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph, config) ⇒ Graph

Returns a new instance of Graph.



37
38
39
40
# File 'lib/yarrow/content/graph.rb', line 37

def initialize(graph, config)
  @graph = graph
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



35
36
37
# File 'lib/yarrow/content/graph.rb', line 35

def config
  @config
end

#graphObject (readonly)

Returns the value of attribute graph.



35
36
37
# File 'lib/yarrow/content/graph.rb', line 35

def graph
  @graph
end

Class Method Details

.from_source(config) ⇒ Object

Construct a graph collected from source content files.



31
32
33
# File 'lib/yarrow/content/graph.rb', line 31

def self.from_source(config)
  new(SourceCollector.collect(config.input_dir), config)
end

Instance Method Details

#directoriesObject

List of source directories.



53
54
55
# File 'lib/yarrow/content/graph.rb', line 53

def directories
  graph.nodes(:directory)
end

#expand_pagesObject



42
43
44
45
# File 'lib/yarrow/content/graph.rb', line 42

def expand_pages
  expander = Yarrow::Content::CollectionExpander.new(config.content_types)
  expander.expand(graph)
end

#filesObject

List of source files.



48
49
50
# File 'lib/yarrow/content/graph.rb', line 48

def files
  graph.nodes(:file)
end