Sha256: 811c4af5ee1575dac081a5fafcdedbc95ff8668793aba6f8d6f913514f9d3afe

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 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 = YAML.safe_load(File.open(file).read) || {}
      end

      user_config = user_config.deep_merge(options['override'] || {})
      user_config = (options['defaults'] || {}).deep_merge(user_config)

      @config = DEFAULTS.deep_merge(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 = configs.deep_merge YAML.safe_load(File.open(file)) 
        end
      end

      @jekyll_config = configs
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
octopress-3.0.0.rc.9 lib/octopress/configuration.rb
octopress-3.0.0.rc.8 lib/octopress/configuration.rb
octopress-3.0.0.rc.7 lib/octopress/configuration.rb
octopress-3.0.0.rc.6 lib/octopress/configuration.rb
octopress-3.0.0.rc.5 lib/octopress/configuration.rb
octopress-3.0.0.rc.4 lib/octopress/configuration.rb
octopress-3.0.0.rc.3 lib/octopress/configuration.rb
octopress-3.0.0.rc.2 lib/octopress/configuration.rb
octopress-3.0.0.rc.1 lib/octopress/configuration.rb