Class: Dimples::Site
- Inherits:
-
Object
- Object
- Dimples::Site
- Defined in:
- lib/dimples/site.rb
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.
-
#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
-
#initialize(config) ⇒ Site
constructor
A new instance of Site.
Constructor Details
#initialize(config) ⇒ Site
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dimples/site.rb', line 15 def initialize(config) @source_paths = {} @output_paths = {} @templates = {} @categories = {} @archives = { year: {}, month: {}, day: {} } @pages = [] @posts = [] @latest_post = false @config = config @page_class = @config.class_override(:page) || Dimples::Page @post_class = @config.class_override(:post) || Dimples::Post @source_paths[:root] = File.(@config['source_path']) @output_paths[:site] = File.(@config['destination_path']) %w(pages posts public templates).each do |path| @source_paths[path.to_sym] = File.join(@source_paths[:root], path) end %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 |
Instance Attribute Details
#archives ⇒ Object
Returns the value of attribute archives.
8 9 10 |
# File 'lib/dimples/site.rb', line 8 def archives @archives end |
#categories ⇒ Object
Returns the value of attribute categories.
7 8 9 |
# File 'lib/dimples/site.rb', line 7 def categories @categories end |
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/dimples/site.rb', line 5 def config @config end |
#latest_post ⇒ Object
Returns the value of attribute latest_post.
11 12 13 |
# File 'lib/dimples/site.rb', line 11 def latest_post @latest_post end |
#output_paths ⇒ Object
Returns the value of attribute output_paths.
4 5 6 |
# File 'lib/dimples/site.rb', line 4 def output_paths @output_paths end |
#page_class ⇒ Object
Returns the value of attribute page_class.
12 13 14 |
# File 'lib/dimples/site.rb', line 12 def page_class @page_class end |
#pages ⇒ Object
Returns the value of attribute pages.
9 10 11 |
# File 'lib/dimples/site.rb', line 9 def pages @pages end |
#post_class ⇒ Object
Returns the value of attribute post_class.
13 14 15 |
# File 'lib/dimples/site.rb', line 13 def post_class @post_class end |
#posts ⇒ Object
Returns the value of attribute posts.
10 11 12 |
# File 'lib/dimples/site.rb', line 10 def posts @posts end |
#source_paths ⇒ Object
Returns the value of attribute source_paths.
3 4 5 |
# File 'lib/dimples/site.rb', line 3 def source_paths @source_paths end |
#templates ⇒ Object
Returns the value of attribute templates.
6 7 8 |
# File 'lib/dimples/site.rb', line 6 def templates @templates end |
Instance Method Details
#generate ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dimples/site.rb', line 45 def generate Dimples.logger.info("Building site at #{@output_paths[:site]}...") result = Benchmark.measure do prepare_output_directory scan_files generate_files copy_assets end generation_time = result.real.round(2) = "Done! Site built in #{generation_time} second" += 's' if generation_time != 1 += '.' Dimples.logger.info() rescue Errors::RenderingError => e Dimples.logger.error("Failed to render #{e.file}: #{e.message}") rescue Errors::PublishingError => e Dimples.logger.error("Failed to publish #{e.file}: #{e.message}") end |