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.



12
13
14
15
# File 'lib/yarrow/content/graph.rb', line 12

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/yarrow/content/graph.rb', line 10

def config
  @config
end

#graphObject (readonly)

Returns the value of attribute graph.



10
11
12
# File 'lib/yarrow/content/graph.rb', line 10

def graph
  @graph
end

Class Method Details

.from_source(config) ⇒ Object

Construct a graph collected from source content files.



6
7
8
# File 'lib/yarrow/content/graph.rb', line 6

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

Instance Method Details

#directoriesObject

List of source directories.



28
29
30
# File 'lib/yarrow/content/graph.rb', line 28

def directories
  graph.nodes(:directory)
end

#expand_pagesObject



17
18
19
20
# File 'lib/yarrow/content/graph.rb', line 17

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

#filesObject

List of source files.



23
24
25
# File 'lib/yarrow/content/graph.rb', line 23

def files
  graph.nodes(:file)
end