Class: Dimples::Site
- Inherits:
-
Object
- Object
- Dimples::Site
- Defined in:
- lib/dimples/site.rb
Overview
A class that models a single site.
Instance Attribute Summary collapse
-
#archives ⇒ Object
Returns the value of attribute archives.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#config ⇒ Object
Returns the value of attribute config.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#latest_post ⇒ Object
Returns the value of attribute latest_post.
-
#output_paths ⇒ Object
Returns the value of attribute output_paths.
-
#page_class ⇒ Object
Returns the value of attribute page_class.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#post_class ⇒ Object
Returns the value of attribute post_class.
-
#posts ⇒ Object
Returns the value of attribute posts.
-
#source_paths ⇒ Object
Returns the value of attribute source_paths.
-
#templates ⇒ Object
Returns the value of attribute templates.
Instance Method Summary collapse
- #generate ⇒ Object
- #generated? ⇒ Boolean
-
#initialize(config) ⇒ Site
constructor
A new instance of Site.
- #set_output_paths ⇒ Object
- #set_source_paths ⇒ Object
Constructor Details
#initialize(config) ⇒ Site
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dimples/site.rb', line 19 def initialize(config) @config = config @templates = {} @categories = {} @pages = [] @posts = [] @errors = [] @archives = { year: {}, month: {}, day: {} } @latest_post = false @page_class = @config.class_override(:page) || Dimples::Page @post_class = @config.class_override(:post) || Dimples::Post set_source_paths set_output_paths end |
Instance Attribute Details
#archives ⇒ Object
Returns the value of attribute archives.
11 12 13 |
# File 'lib/dimples/site.rb', line 11 def archives @archives end |
#categories ⇒ Object
Returns the value of attribute categories.
10 11 12 |
# File 'lib/dimples/site.rb', line 10 def categories @categories end |
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/dimples/site.rb', line 8 def config @config end |
#errors ⇒ Object
Returns the value of attribute errors.
17 18 19 |
# File 'lib/dimples/site.rb', line 17 def errors @errors end |
#latest_post ⇒ Object
Returns the value of attribute latest_post.
14 15 16 |
# File 'lib/dimples/site.rb', line 14 def latest_post @latest_post end |
#output_paths ⇒ Object
Returns the value of attribute output_paths.
7 8 9 |
# File 'lib/dimples/site.rb', line 7 def output_paths @output_paths end |
#page_class ⇒ Object
Returns the value of attribute page_class.
15 16 17 |
# File 'lib/dimples/site.rb', line 15 def page_class @page_class end |
#pages ⇒ Object
Returns the value of attribute pages.
12 13 14 |
# File 'lib/dimples/site.rb', line 12 def pages @pages end |
#post_class ⇒ Object
Returns the value of attribute post_class.
16 17 18 |
# File 'lib/dimples/site.rb', line 16 def post_class @post_class end |
#posts ⇒ Object
Returns the value of attribute posts.
13 14 15 |
# File 'lib/dimples/site.rb', line 13 def posts @posts end |
#source_paths ⇒ Object
Returns the value of attribute source_paths.
6 7 8 |
# File 'lib/dimples/site.rb', line 6 def source_paths @source_paths end |
#templates ⇒ Object
Returns the value of attribute templates.
9 10 11 |
# File 'lib/dimples/site.rb', line 9 def templates @templates end |
Instance Method Details
#generate ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dimples/site.rb', line 59 def generate prepare_output_directory scan_files generate_files copy_assets rescue Errors::RenderingError, Errors::PublishingError, Errors::GenerationError => e @errors << e. end |
#generated? ⇒ Boolean
70 71 72 |
# File 'lib/dimples/site.rb', line 70 def generated? @errors.count.zero? end |
#set_output_paths ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dimples/site.rb', line 48 def set_output_paths @output_paths = { site: File.(@config['destination_path']) } %w[archives posts categories].each do |path| output_path = File.join(@output_paths[:site], @config['paths'][path]) @output_paths[path.to_sym] = output_path end end |
#set_source_paths ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/dimples/site.rb', line 38 def set_source_paths @source_paths = { root: File.(@config['source_path']) } %w[pages posts public templates].each do |path| @source_paths[path.to_sym] = File.join(@source_paths[:root], path) end end |