Parent

Files

Jekyll::Configuration

Constants

DEFAULTS

Default options. Overridden by values in _config.yml. Strings rather than symbols are used for compatibility with YAML.

Public Instance Methods

backwards_compatibilize() click to toggle source

Public: Ensure the proper options are set in the configuration to allow for backwards-compatibility with Jekyll pre-1.0

Returns the backwards-compatible configuration

# File lib/jekyll/configuration.rb, line 160
def backwards_compatibilize
  config = clone
  # Provide backwards-compatibility
  if config.has_key?('auto') || config.has_key?('watch')
    Jekyll.logger.warn "Deprecation:", "Auto-regeneration can no longer" +
                        " be set from your configuration file(s). Use the"+
                        " --watch/-w command-line option instead."
    config.delete('auto')
    config.delete('watch')
  end

  if config.has_key? 'server'
    Jekyll.logger.warn "Deprecation:", "The 'server' configuration option" +
                        " is no longer accepted. Use the 'jekyll serve'" +
                        " subcommand to serve your site with WEBrick."
    config.delete('server')
  end

  if config.has_key? 'server_port'
    Jekyll.logger.warn "Deprecation:", "The 'server_port' configuration option" +
                        " has been renamed to 'port'. Please update your config" +
                        " file accordingly."
    # copy but don't overwrite:
    config['port'] = config['server_port'] unless config.has_key?('port')
    config.delete('server_port')
  end

  if config.has_key?('exclude') && config['exclude'].is_a?(String)
    Jekyll.logger.warn "Deprecation:", "The 'exclude' configuration option" +
                           " must now be specified as an array, but you specified" +
                           " a string. For now, we've treated the string you provided" +
                           " as a list of comma-separated values."
    config['exclude'] = csv_to_array(config['exclude'])
  end

  if config.has_key?('include') && config['include'].is_a?(String)
    Jekyll.logger.warn "Deprecation:", "The 'include' configuration option" +
                           " must now be specified as an array, but you specified" +
                           " a string. For now, we've treated the string you provided" +
                           " as a list of comma-separated values."
    config['include'] = csv_to_array(config['include'])
  end

  config
end
config_files(override) click to toggle source

Public: Generate list of configuration files from the override

override - the command-line options hash

Returns an Array of config files

# File lib/jekyll/configuration.rb, line 101
def config_files(override)
  # Get configuration from <source>/_config.yml or <source>/<config_file>
  config_files = override.delete('config')
  config_files = File.join(source(override), "_config.yml") if config_files.to_s.empty?
  config_files = [config_files] unless config_files.is_a? Array
  config_files
end
csv_to_array(csv) click to toggle source

Public: Split a CSV string into an array containing its values

csv - the string of comma-separated values

Returns an array of the values contained in the CSV

# File lib/jekyll/configuration.rb, line 152
def csv_to_array(csv)
  csv.split(",").map(&:strip)
end
read_config_file(file) click to toggle source

Public: Read configuration and return merged Hash

file - the path to the YAML file to be read in

Returns this configuration, overridden by the values in the file

# File lib/jekyll/configuration.rb, line 114
def read_config_file(file)
  next_config = YAML.safe_load_file(file)
  raise "Configuration file: (INVALID) #{file}".yellow if !next_config.is_a?(Hash)
  Jekyll.logger.info "Configuration file:", file
  next_config
end
read_config_files(files) click to toggle source

Public: Read in a list of configuration files and merge with this hash

files - the list of configuration file paths

Returns the full configuration, with the defaults overridden by the values in the configuration files

# File lib/jekyll/configuration.rb, line 127
def read_config_files(files)
  configuration = clone

  begin
    files.each do |config_file|
      new_config = read_config_file(config_file)
      configuration = configuration.deep_merge(new_config)
    end
  rescue SystemCallError
    # Errno:ENOENT = file not found
    Jekyll.logger.warn "Configuration file:", "none"
  rescue => err
    Jekyll.logger.warn "WARNING:", "Error reading configuration. " +
                 "Using defaults (and options)."
    $stderr.puts "#{err}"
  end

  configuration.backwards_compatibilize
end
source(override) click to toggle source

Public: Directory of the Jekyll source folder

override - the command-line options hash

Returns the path to the Jekyll source directory

# File lib/jekyll/configuration.rb, line 92
def source(override)
  override['source'] || self['source'] || DEFAULTS['source']
end
stringify_keys() click to toggle source

Public: Turn all keys into string

Return a copy of the hash where all its keys are strings

# File lib/jekyll/configuration.rb, line 83
def stringify_keys
  reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.