Class: Dimples::Configuration
- Inherits:
-
Object
- Object
- Dimples::Configuration
- Defined in:
- lib/dimples/configuration.rb
Class Method Summary collapse
- .default_date_formats ⇒ Object
- .default_feed_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.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/dimples/configuration.rb', line 3 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
83 84 85 86 87 88 89 |
# File 'lib/dimples/configuration.rb', line 83 def self.default_date_formats { 'year' => '%Y', 'month' => '%Y-%m', 'day' => '%Y-%m-%d' } end |
.default_feed_formats ⇒ Object
79 80 81 |
# File 'lib/dimples/configuration.rb', line 79 def self.default_feed_formats ['atom'] 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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dimples/configuration.rb', line 24 def self.default_settings current_path = Dir.pwd { 'source_path' => current_path, 'destination_path' => File.join(current_path, 'site'), 'verbose_logging' => false, 'class_overrides' => { site: nil, post: nil, page: nil }, 'rendering' => {}, 'category_names' => {}, 'paths' => default_paths, 'layouts' => default_layouts, 'pagination' => default_pagination, 'generation' => default_generation, 'feed_formats' => default_feed_formats, 'date_formats' => default_date_formats } end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 |
# File 'lib/dimples/configuration.rb', line 15 def [](key) @settings[key] end |
#class_override(type) ⇒ Object
19 20 21 22 |
# File 'lib/dimples/configuration.rb', line 19 def class_override(type) klass = @settings['class_overrides']["#{type}"] Object.const_get(klass) unless klass.nil? end |