Class: Mascot::Site
- Inherits:
-
Object
- Object
- Mascot::Site
- Extended by:
- Forwardable
- Defined in:
- lib/mascot/site.rb
Overview
A collection of pages from a directory.
Constant Summary collapse
- DEFAULT_GLOB =
Default file pattern to pick up in site
"**/**".freeze
- DEFAULT_ROOT_PATH =
Default root_path for site.
Pathname.new(".").freeze
Instance Attribute Summary collapse
-
#cache_resources ⇒ Object
(also: #cache_resources?)
Cache resources for production runs of Mascot.
-
#resources_pipeline ⇒ Object
readonly
Returns the value of attribute resources_pipeline.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
Instance Method Summary collapse
-
#initialize(root_path: DEFAULT_ROOT_PATH, cache_resources: false) ⇒ Site
constructor
A new instance of Site.
-
#manipulate(&block) ⇒ Object
Quick and dirty way to manipulate resources in the site without creating classes that implement the #process_resources method.
-
#resources ⇒ Object
Returns a list of all the resources within #root.
-
#root ⇒ Object
A tree representation of the resourecs wthin the site.
Constructor Details
#initialize(root_path: DEFAULT_ROOT_PATH, cache_resources: false) ⇒ Site
Returns a new instance of Site.
24 25 26 27 |
# File 'lib/mascot/site.rb', line 24 def initialize(root_path: DEFAULT_ROOT_PATH, cache_resources: false) self.root_path = root_path self.cache_resources = cache_resources end |
Instance Attribute Details
#cache_resources ⇒ Object Also known as: cache_resources?
Cache resources for production runs of Mascot. Development modes don’t cache to optimize for files reloading.
17 18 19 |
# File 'lib/mascot/site.rb', line 17 def cache_resources @cache_resources end |
#resources_pipeline ⇒ Object (readonly)
Returns the value of attribute resources_pipeline.
13 14 15 |
# File 'lib/mascot/site.rb', line 13 def resources_pipeline @resources_pipeline end |
#root_path ⇒ Object
Returns the value of attribute root_path.
13 14 15 |
# File 'lib/mascot/site.rb', line 13 def root_path @root_path end |
Instance Method Details
#manipulate(&block) ⇒ Object
Quick and dirty way to manipulate resources in the site without creating classes that implement the #process_resources method
49 50 51 |
# File 'lib/mascot/site.rb', line 49 def manipulate(&block) resources_pipeline << Extensions::ProcManipulator.new(block) end |
#resources ⇒ Object
Returns a list of all the resources within #root.
38 39 40 41 |
# File 'lib/mascot/site.rb', line 38 def resources @resources = nil unless cache_resources @resources ||= ResourceCollection.new(node: root, root_path: root_path) end |
#root ⇒ Object
A tree representation of the resourecs wthin the site.
30 31 32 33 34 35 |
# File 'lib/mascot/site.rb', line 30 def root ResourcesNode.new.tap do |node| DirectoryCollection.new(assets: assets, path: root_path).mount(node) resources_pipeline.process node end end |