Class: Dimples::Configuration

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Configuration

Returns a new instance of Configuration.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dimples/configuration.rb', line 3

def initialize(config = {})
  @settings = Dimples::Configuration.default_settings

  if config
    @settings.each_key do |key|
      if config.key?(key)
        if @settings[key].is_a?(Hash)
          @settings[key].merge!(config[key])
        else
          @settings[key] = config[key]
        end
      end
    end
  end
end

Class Method Details

.default_settingsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dimples/configuration.rb', line 23

def self.default_settings
  current_path = Dir.pwd

  {
    'source_path' => current_path,
    'destination_path' => File.join(current_path, 'site'),

    'paths' => {
      'posts' => 'archives',
      'post' => '%Y/%m/%d',
    },

    'layouts' => {
      'posts' => 'posts',
      'post' => 'post',
      'category' => 'category',
    },

    'rendering' => {
    },

    'pagination' => {
      'enabled' => true,
      'per_page' => 10,
    },

    'generation' => {
      'paginated_posts' => false,
      'categories' => true,
      'year_archives' => true,
      'month_archives' => true,
      'day_archives' => true,
      'feed' => true,
      'category_feeds' => true,
    },

    'file_extensions' => {
      'pages' => 'html',
      'posts' => 'html',
    },

    'date_formats' => {
      'year' => '%Y',
      'month' => '%Y-%m',
      'day' => '%Y-%m-%d',
    },

    'categories' => [
    ]
  }
end

Instance Method Details

#[](key) ⇒ Object



19
20
21
# File 'lib/dimples/configuration.rb', line 19

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