Class: Dimples::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/dimples/config.rb

Overview

Configuration settings for a site.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dimples/config.rb', line 13

def initialize(options = {})
  @options = Config.defaults

  options&.each do |key, value|
    @options[key]&.merge!(value)
  end

  %i[sources output].each do |type|
    @options[type].each { |key, value| @options[type][key] = File.expand_path(value) }
  end
end

Class Method Details

.defaultsObject



6
7
8
9
10
11
# File 'lib/dimples/config.rb', line 6

def self.defaults
  {
    sources: { root: '.', posts: './posts', pages: './pages', layouts: './layouts', static: './static' },
    output: { root: './site', posts: './site/posts', categories: './site/categories' }
  }
end

Instance Method Details

#[](key) ⇒ Object



29
30
31
# File 'lib/dimples/config.rb', line 29

def [](key)
  @options[key]
end

#dig(*args) ⇒ Object



25
26
27
# File 'lib/dimples/config.rb', line 25

def dig(*args)
  @options.dig(*args)
end