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.



15
16
17
18
# File 'lib/yarrow/content/graph.rb', line 15

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#graphObject (readonly)

Returns the value of attribute graph.



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

def graph
  @graph
end

Class Method Details

.from_source(config) ⇒ Yarrow::Content::Graph

Construct a graph collected from files and directories in the configured content directory.



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

def self.from_source(config)
  new(Source.collect(config.source_dir), config)
end

Instance Method Details

#collectionsObject

List of mapped content object collections



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

def collections
  graph.nodes(:collection)
end

#directoriesObject

List of source directories.



26
27
28
# File 'lib/yarrow/content/graph.rb', line 26

def directories
  graph.nodes(:directory)
end

#filesObject

List of source files.



21
22
23
# File 'lib/yarrow/content/graph.rb', line 21

def files
  graph.nodes(:file)
end

#itemsObject

List of mapped content object items



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

def items
  graph.nodes(:item)
end