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
-
#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
- #generate ⇒ Object
-
#initialize(config = {}) ⇒ Site
constructor
A new instance of Site.
- #inspect ⇒ Object
- #publish_files ⇒ Object
- #scan_sources ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Site
Returns a new instance of Site.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dimples/site.rb', line 15 def initialize(config = {}) @config = Hashie::Mash.new(Configuration.defaults).deep_merge(config) @paths = {}.tap do |paths| paths[:base] = Dir.pwd paths[:output] = File.(@config.paths.output) paths[:sources] = {}.tap do |sources| %w[pages posts static templates].each do |type| sources[type.to_sym] = File.join(paths[:base], type) end end end prepare end |
Instance Attribute Details
#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.
13 14 15 |
# File 'lib/dimples/site.rb', line 13 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.
12 13 14 |
# File 'lib/dimples/site.rb', line 12 def templates @templates end |
Instance Method Details
#generate ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/dimples/site.rb', line 32 def generate prepare scan_sources create_output_directory copy_static_assets publish_files rescue PublishingError, RenderingError, GenerationError => error @errors << error end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/dimples/site.rb', line 63 def inspect "#<#{self.class} @paths=#{paths}>" end |
#publish_files ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dimples/site.rb', line 52 def publish_files trigger_event(:before_publishing) publish_posts publish_pages publish_archives publish_categories if @config.generation.categories trigger_event(:after_publishing) end |
#scan_sources ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/dimples/site.rb', line 42 def scan_sources trigger_event(:before_file_scanning) read_templates read_posts read_pages trigger_event(:after_file_scanning) end |