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
#initialize(config = {}) ⇒ Site
Returns a new instance of Site.
16 17 18 |
# File 'lib/dimples/site.rb', line 16 def initialize(config = {}) @config = Config.new(config) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/dimples/site.rb', line 10 def config @config end |
Class Method Details
.generate(config = {}) ⇒ Object
12 13 14 |
# File 'lib/dimples/site.rb', line 12 def self.generate(config = {}) new(config).generate end |
Instance Method Details
#categories ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dimples/site.rb', line 48 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
20 21 22 23 24 25 26 27 28 |
# File 'lib/dimples/site.rb', line 20 def generate prepare_output_directory generate_posts generate_categories generate_pages copy_assets end |
#layouts ⇒ Object
42 43 44 45 46 |
# File 'lib/dimples/site.rb', line 42 def layouts @layouts ||= Dir.glob(File.join(@config[:sources][:layouts], '**', '*.erb')).to_h do |path| [File.basename(path, '.erb'), Dimples::Sources::Layout.new(self, path)] end end |
#metadata ⇒ Object
59 60 61 |
# File 'lib/dimples/site.rb', line 59 def ||= { posts: posts, categories: categories } end |
#pages ⇒ Object
36 37 38 39 40 |
# File 'lib/dimples/site.rb', line 36 def pages @pages ||= Dir.glob(File.join(@config[:sources][:pages], '**', '*.erb')).map do |path| Dimples::Sources::Page.new(self, path) end end |
#posts ⇒ Object
30 31 32 33 34 |
# File 'lib/dimples/site.rb', line 30 def posts @posts ||= Dir.glob(File.join(@config[:sources][:posts], '**', '*.markdown')).map do |path| Dimples::Sources::Post.new(self, path) end.sort_by!(&:date).reverse! end |