Class: Yuzu::Core::SiteRoot

Inherits:
WebsiteFolder show all
Includes:
Generators
Defined in:
lib/yuzu/core/siteroot.rb

Constant Summary

Constants included from Yuzu::Core

BOLD, ENDC, WHITE

Instance Attribute Summary collapse

Attributes inherited from WebsiteBase

#kind, #parent, #path

Instance Method Summary collapse

Methods included from Generators

category_index_template, default_blog_index_template, default_index_template

Methods included from Filters

catalog_for, get_kwds

Methods included from Yuzu::Core

get_paginated_path

Methods inherited from WebsiteFolder

#all_files, #all_processable_children, #append_child, #breadcrumb, #children, #currentpath, #files, #folder_contents, #folders, #get_all_files, #get_child_by_basename, #get_child_by_filename, #get_child_by_path, #get_child_by_rootname, #get_children, #get_has_index, #get_object_for_path, #has_index?, #is_child?, #is_immediate_child?, #processable_children, #to_s

Methods inherited from WebsiteBase

#==, #asset?, #blog_folder, #children, #default_stash, #file?, #folder?, #generated?, #get_link_url, #get_remote_path, #hidden?, #image?, #in_blog?, #index?, #is_blog?, #is_processable?, #link_to_self, #link_url, #processable?, #remote_path, #resource?, #root, #root?, #stash

Constructor Details

#initialize(yuzu_config) ⇒ SiteRoot

Returns a new instance of SiteRoot.



10
11
12
13
14
15
16
17
# File 'lib/yuzu/core/siteroot.rb', line 10

def initialize(yuzu_config)
  @config = yuzu_config
  @path = @config.pwd
  @parent = nil
  @kind = :folder

  generate!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/yuzu/core/siteroot.rb', line 9

def config
  @config
end

Instance Method Details

#find_file_by_path(path) ⇒ Object

Given a Path, return the WebsiteFile or WebsiteFolder corresponding to the Path.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/yuzu/core/siteroot.rb', line 24

def find_file_by_path(path)
  path_elements = path.relative.split(File::SEPARATOR)

  parent = self
  path_elements.each do |element|
    child = parent.get_child_by_rootname(element)
    return nil if child.nil?
    parent = child
  end

  return parent
end

#generate!Object

Process all the generators to make all the new files required from things like pagination of catalogs and new index files.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/yuzu/core/siteroot.rb', line 43

def generate!
  generators.each_pair do |name, generator|
    v = Visitor.new(generator.visitor_filter)

    v.traverse(self) do |node|
      if generator.should_generate?(node)
        generator.generate!(node)
      end
    end
  end
end

#generatorsObject



37
38
39
# File 'lib/yuzu/core/siteroot.rb', line 37

def generators
  Generator.generators
end

#nameObject



19
20
21
# File 'lib/yuzu/core/siteroot.rb', line 19

def name
  @config.site_name
end