Class: Yuzu::Generators::CategoryFoldersGenerator
- Includes:
- Helpers
- Defined in:
- lib/yuzu/generators/category_folders.rb
Instance Attribute Summary
Attributes inherited from Generator
Instance Method Summary collapse
- #folder_for_category(category, blog_folder) ⇒ Object
- #generate!(website_folder) ⇒ Object
- #generate_folder_for_category!(category, blog_folder) ⇒ Object
- #index_for_category(category, parent_folder, blog_folder) ⇒ Object
-
#initialize ⇒ CategoryFoldersGenerator
constructor
A new instance of CategoryFoldersGenerator.
- #should_generate?(website_folder) ⇒ Boolean
- #visitor_filter ⇒ Object
Methods inherited from Generator
Constructor Details
#initialize ⇒ CategoryFoldersGenerator
Returns a new instance of CategoryFoldersGenerator.
9 10 11 12 |
# File 'lib/yuzu/generators/category_folders.rb', line 9 def initialize @name = :category_folders @directive = "CATEGORYFOLDERS" end |
Instance Method Details
#folder_for_category(category, blog_folder) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/yuzu/generators/category_folders.rb', line 37 def folder_for_category(category, blog_folder) category_folder = GeneratedFolder.new(category.path, blog_folder) index_child = index_for_category(category, category_folder, blog_folder) category_folder.append_child(index_child) category_folder end |
#generate!(website_folder) ⇒ Object
27 28 29 30 31 |
# File 'lib/yuzu/generators/category_folders.rb', line 27 def generate!(website_folder) @all_categories.each do |category| generate_folder_for_category!(category, website_folder.blog_folder) end end |
#generate_folder_for_category!(category, blog_folder) ⇒ Object
33 34 35 |
# File 'lib/yuzu/generators/category_folders.rb', line 33 def generate_folder_for_category!(category, blog_folder) blog_folder.append_child(folder_for_category(category, blog_folder)) end |
#index_for_category(category, parent_folder, blog_folder) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/yuzu/generators/category_folders.rb', line 44 def index_for_category(category, parent_folder, blog_folder) GeneratedIndex.new( parent_folder, Yuzu::Generators.category_index_template(blog_folder.path.relative, category.name) ) end |
#should_generate?(website_folder) ⇒ Boolean
14 15 16 |
# File 'lib/yuzu/generators/category_folders.rb', line 14 def should_generate?(website_folder) website_folder.is_blog? end |
#visitor_filter ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/yuzu/generators/category_folders.rb', line 18 def visitor_filter proc do |c| if c.file? @all_categories = c.all_categories end c.folder? end end |