class Yarrow::Content::Expansion::Traversal
Attributes
aggregator[R]
graph[R]
policy[R]
Public Class Methods
new(graph, policy)
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 7 def initialize(graph, policy) @graph = graph @policy = policy @aggregator = policy.aggregator_const.new(graph) end
Public Instance Methods
complete_traversal()
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 43 def complete_traversal aggregator.after_traversal(policy) end
expand()
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 47 def expand start_traversal traversal = source_node.depth_first.each visit_source(traversal.next) loop do node = traversal.next case node.label when :directory then visit_directory(node) when :file then visit_file(node) end end complete_traversal end
source_node()
click to toggle source
If source path represents entire content dir, then include the entire content dir instead of scanning from a subfolder matching the name of the collection.
# File lib/yarrow/content/expansion/traversal.rb, line 16 def source_node if policy.source_path == "." graph.n(:root).out(:directory) else graph.n(name: policy.source_path) end end
start_traversal()
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 39 def start_traversal aggregator.before_traversal(policy) end
visit_directory(dir_node)
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 28 def visit_directory(dir_node) # TODO: match on potential directory extension/filter aggregator.expand_directory(dir_node, policy) end
visit_file(file_node)
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 33 def visit_file(file_node) # TODO: dispatch underscore prefix or index files separately # TODO: match on file extension aggregator.expand_file(file_node, policy) end
visit_source(root_node)
click to toggle source
# File lib/yarrow/content/expansion/traversal.rb, line 24 def visit_source(root_node) aggregator.expand_source(root_node, policy) end