Class: Dimples::Configuration
- Inherits:
-
Object
- Object
- Dimples::Configuration
- Defined in:
- lib/dimples/configuration.rb
Overview
A class that models a site’s configuration.
Class Method Summary collapse
- .default_date_formats ⇒ Object
- .default_generation ⇒ Object
- .default_layouts ⇒ Object
- .default_pagination ⇒ Object
- .default_paths ⇒ Object
- .default_settings ⇒ Object
Instance Method Summary collapse
- #[](key) ⇒ Object
- #class_override(type) ⇒ Object
-
#initialize(config = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(config = {}) ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dimples/configuration.rb', line 6 def initialize(config = {}) @settings = Dimples::Configuration.default_settings config.each_key do |key| if @settings[key].is_a?(Hash) @settings[key].merge!(config[key]) else @settings[key] = config[key] end end end |
Class Method Details
.default_date_formats ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/dimples/configuration.rb', line 79 def self.default_date_formats { 'year' => '%Y', 'month' => '%Y-%m', 'day' => '%Y-%m-%d' } end |
.default_generation ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dimples/configuration.rb', line 68 def self.default_generation { 'categories' => true, 'year_archives' => true, 'month_archives' => true, 'day_archives' => true, 'feeds' => true, 'category_feeds' => true } end |
.default_layouts ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dimples/configuration.rb', line 43 def self.default_layouts { 'posts' => 'posts', 'post' => 'post', 'category' => 'category', 'year_archives' => 'year_archives', 'month_archives' => 'month_archives', 'day_archives' => 'day_archives' } end |
.default_pagination ⇒ Object
62 63 64 65 66 |
# File 'lib/dimples/configuration.rb', line 62 def self.default_pagination { 'per_page' => 10 } end |
.default_paths ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/dimples/configuration.rb', line 54 def self.default_paths { 'archives' => 'archives', 'posts' => 'archives/%Y/%m/%d', 'categories' => 'archives/categories' } end |
.default_settings ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dimples/configuration.rb', line 27 def self.default_settings { 'source_path' => Dir.pwd, 'destination_path' => File.join(Dir.pwd, 'site'), 'verbose_logging' => false, 'class_overrides' => { site: nil, post: nil }, 'rendering' => {}, 'category_names' => {}, 'paths' => default_paths, 'layouts' => default_layouts, 'pagination' => default_pagination, 'generation' => default_generation, 'date_formats' => default_date_formats } end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/dimples/configuration.rb', line 18 def [](key) @settings[key] end |
#class_override(type) ⇒ Object
22 23 24 25 |
# File 'lib/dimples/configuration.rb', line 22 def class_override(type) klass = @settings['class_overrides'][type.to_s] Object.const_get(klass) unless klass.nil? end |