Class: Yarrow::Content::Expansion::DirectoryMerge

Inherits:
Aggregator
  • Object
show all
Defined in:
lib/yarrow/content/expansion/directory_merge.rb

Instance Attribute Summary

Attributes inherited from Aggregator

#graph

Instance Method Summary collapse

Methods inherited from Aggregator

#after_traversal, #initialize

Constructor Details

This class inherits a constructor from Yarrow::Content::Expansion::Aggregator

Instance Method Details

#before_traversal(policy) ⇒ Object



5
6
7
8
9
# File 'lib/yarrow/content/expansion/directory_merge.rb', line 5

def before_traversal(policy)
  @bundles = {}
  @current_collection = nil
  @current_entity = nil
end

#expand_directory(collection, policy) ⇒ Object



16
17
18
# File 'lib/yarrow/content/expansion/directory_merge.rb', line 16

def expand_directory(collection, policy)
  @current_entity = collection.props[:basename]
end

#expand_file(entity, policy) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/yarrow/content/expansion/directory_merge.rb', line 20

def expand_file(entity, policy)
  if entity.props[:basename] == @current_entity && entity.props[:ext] == ".md"
    create_entity(entity, @current_collection, policy.entity, policy.entity_const)
  else
    # TODO: attach static assets to the entity as well
    #puts "--> create_node label=:asset type=:asset name='#{entity.props[:basename]}' entity='#{@current_entity}'"
  end
end

#expand_source(container, policy) ⇒ Object



11
12
13
14
# File 'lib/yarrow/content/expansion/directory_merge.rb', line 11

def expand_source(container, policy)
  create_collection(container, policy.container, policy.container_const)
  @current_collection = container.props[:path]
end