Sha256: 550b73d64625a3e287f33bd2336886d091911d0e990944a806b7cee2fa8e7f72

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Octopress
  module Configuration

    DEFAULTS = {
      'post_ext' => 'markdown',
      'page_ext' => 'html',
      'post_layout' => 'post',
      'page_layout' => 'page',
      'titlecase' => true
    }

    def self.config(options={})
      return @config if @config

      file = options['octopress-config'] || '_octopress.yml'
      user_config = {}

      if File.exist? file
        user_config = SafeYAML.load_file(file) || {}
      end

      user_config = Jekyll::Utils.deep_merge_hashes(user_config, options['override'] || {})
      user_config = Jekyll::Utils.deep_merge_hashes(options['defaults'] || {}, user_config)

      @config = Jekyll::Utils.deep_merge_hashes(DEFAULTS, user_config)
    end

    def self.jekyll_config(options={})
      return @jekyll_config if @jekyll_config

      configs = Jekyll::Configuration::DEFAULTS

      (options['config'] || ['_config.yml']).each do |file|
        if File.exist? file
          configs = Jekyll::Utils.deep_merge_hashes(configs, SafeYAML.load_file(file) || {})
        end
      end

      @jekyll_config = configs
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octopress-3.0.0.rc.13 lib/octopress/configuration.rb
octopress-3.0.0.rc.12 lib/octopress/configuration.rb
octopress-3.0.0.rc.11 lib/octopress/configuration.rb