Class: Dimples::Site
- Inherits:
-
Object
- Object
- Dimples::Site
- Defined in:
- lib/dimples/site.rb
Overview
A collection of pages, posts and templates that can generate a website.
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
Returns the value of attribute archive.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#latest_post ⇒ Object
readonly
Returns the value of attribute latest_post.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
- #data ⇒ Object
- #generate ⇒ Object
-
#initialize(config = {}) ⇒ Site
constructor
A new instance of Site.
- #inspect ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Site
Returns a new instance of Site.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dimples/site.rb', line 16 def initialize(config = {}) @config = Configuration.prepare(config) @paths = {}.tap do |paths| paths[:source] = File.(@config.source) paths[:destination] = File.(@config.destination) %w[pages posts static templates].each do |type| paths[type.to_sym] = File.join(paths[:source], type) end end prepare end |
Instance Attribute Details
#archive ⇒ Object (readonly)
Returns the value of attribute archive.
12 13 14 |
# File 'lib/dimples/site.rb', line 12 def archive @archive end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
7 8 9 |
# File 'lib/dimples/site.rb', line 7 def categories @categories end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/dimples/site.rb', line 6 def config @config end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/dimples/site.rb', line 8 def errors @errors end |
#latest_post ⇒ Object (readonly)
Returns the value of attribute latest_post.
14 15 16 |
# File 'lib/dimples/site.rb', line 14 def latest_post @latest_post end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
11 12 13 |
# File 'lib/dimples/site.rb', line 11 def pages @pages end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
9 10 11 |
# File 'lib/dimples/site.rb', line 9 def paths @paths end |
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
10 11 12 |
# File 'lib/dimples/site.rb', line 10 def posts @posts end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
13 14 15 |
# File 'lib/dimples/site.rb', line 13 def templates @templates end |
Instance Method Details
#data ⇒ Object
49 50 51 |
# File 'lib/dimples/site.rb', line 49 def data @config.data || {} end |
#generate ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dimples/site.rb', line 31 def generate prepare read_templates read_posts read_pages create_output_directory copy_static_assets publish_posts publish_pages publish_archives if @config.generation.year_archives publish_categories if @config.generation.categories rescue PublishingError, RenderingError, GenerationError => e @errors << e end |
#inspect ⇒ Object
53 54 55 |
# File 'lib/dimples/site.rb', line 53 def inspect "#<#{self.class} @paths=#{paths}>" end |