Class: Dimples::Site
- Inherits:
-
Object
- Object
- Dimples::Site
- Defined in:
- lib/dimples/site.rb
Overview
A class representing a single generated website.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #categories ⇒ Object
- #generate ⇒ Object
-
#initialize(config = {}) ⇒ Site
constructor
A new instance of Site.
- #layouts ⇒ Object
- #metadata ⇒ Object
- #pages ⇒ Object
- #posts ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/dimples/site.rb', line 11 def config @config end |
Class Method Details
.generate(config = {}) ⇒ Object
13 14 15 |
# File 'lib/dimples/site.rb', line 13 def self.generate(config = {}) new(config).generate end |
Instance Method Details
#categories ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dimples/site.rb', line 49 def categories @categories ||= {}.tap do |categories| posts.each do |post| post.categories.each do |category| categories[category] ||= [] categories[category].append(post) end end end end |
#generate ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/dimples/site.rb', line 21 def generate prepare_output_directory generate_posts generate_categories generate_pages copy_assets end |
#layouts ⇒ Object
43 44 45 46 47 |
# File 'lib/dimples/site.rb', line 43 def layouts @layouts ||= Dir.glob(File.join(@config.source_paths[:layouts], '**', '*.erb')).to_h do |path| [File.basename(path, '.erb'), Dimples::Sources::Layout.new(self, path)] end end |
#metadata ⇒ Object
60 61 62 |
# File 'lib/dimples/site.rb', line 60 def @metadata ||= Metadata.new(posts: posts, categories: categories) end |