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
-
#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 17 |
# File 'lib/dimples/configuration.rb', line 6 def initialize(config = {}) @settings = Dimples::Configuration.default_settings config.each_key do |key| case @settings[key] when Hash @settings[key].merge!(config[key]) else @settings[key] = config[key] end end end |
Class Method Details
.default_date_formats ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/dimples/configuration.rb', line 75 def self.default_date_formats { year: '%Y', month: '%Y-%m', day: '%Y-%m-%d' } end |
.default_generation ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dimples/configuration.rb', line 64 def self.default_generation { categories: true, year_archives: true, month_archives: true, day_archives: true, feeds: true, category_feeds: true } end |
.default_layouts ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dimples/configuration.rb', line 39 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
58 59 60 61 62 |
# File 'lib/dimples/configuration.rb', line 58 def self.default_pagination { per_page: 10 } end |
.default_paths ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/dimples/configuration.rb', line 50 def self.default_paths { archives: 'archives', posts: 'archives/%Y/%m/%d', categories: 'archives/categories' } end |
.default_settings ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dimples/configuration.rb', line 23 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
19 20 21 |
# File 'lib/dimples/configuration.rb', line 19 def [](key) @settings[key] end |