Sha256: eaa1da32cd6eff061a1d36396dab22037de238f800f3d5ffd893e7ade404a5ac

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

module Octopress
  module Configuration

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

    # Read _octopress.yml and merge with defaults
    #
    def self.config(options={})

      # Cache loading the config file
      unless @user_config
        file = options['octopress-config'] || '_octopress.yml'

        if File.exist? file
          config = SafeYAML.load_file(file) || {}
        else
          config = {}
        end
        
        # Allow cli extensioins to override default user configuration
        if options['override']
          config = Jekyll::Utils.deep_merge_hashes(config, options['override'])
        end

        # Merge Octopress defaults
        @user_config = Jekyll::Utils.deep_merge_hashes(DEFAULTS, config)
      end

      @user_config
    end

    # Read Jekyll's _config.yml merged with Jekyll's defaults
    #
    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

5 entries across 5 versions & 1 rubygems

Version Path
octopress-3.0.0.rc.18 lib/octopress/configuration.rb
octopress-3.0.0.rc.17 lib/octopress/configuration.rb
octopress-3.0.0.rc.16 lib/octopress/configuration.rb
octopress-3.0.0.rc.15 lib/octopress/configuration.rb
octopress-3.0.0.rc.14 lib/octopress/configuration.rb