Class: Sitepress::AssetNodeMapper
- Inherits:
-
Object
- Object
- Sitepress::AssetNodeMapper
- Defined in:
- lib/sitepress/asset_node_mapper.rb
Overview
Maps a tree of Directory and Asset objects in a a tree of nodes that format the navigational structure of a website. You can override this this in a site to deal with different file systems. For example, Notion has a completely different file structure for its content than Rails, so we could extend this class to properly map those differences into a tree of nodes.
Instance Attribute Summary collapse
-
#asset_paths ⇒ Object
readonly
Returns the value of attribute asset_paths.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(path:, node:) ⇒ AssetNodeMapper
constructor
A new instance of AssetNodeMapper.
-
#map ⇒ Object
Mounts the source files from the path to the given node.
Constructor Details
#initialize(path:, node:) ⇒ AssetNodeMapper
Returns a new instance of AssetNodeMapper.
11 12 13 14 |
# File 'lib/sitepress/asset_node_mapper.rb', line 11 def initialize(path:, node:) @asset_paths = AssetPaths.new(path: path) @node = node end |
Instance Attribute Details
#asset_paths ⇒ Object (readonly)
Returns the value of attribute asset_paths.
9 10 11 |
# File 'lib/sitepress/asset_node_mapper.rb', line 9 def asset_paths @asset_paths end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
9 10 11 |
# File 'lib/sitepress/asset_node_mapper.rb', line 9 def node @node end |
Instance Method Details
#map ⇒ Object
Mounts the source files from the path to the given node.
17 18 19 20 21 22 23 24 25 |
# File 'lib/sitepress/asset_node_mapper.rb', line 17 def map asset_paths.each do |path| if path.directory? process_directory path else process_asset path end end end |