class Nanoc::Int::ConfigLoader
@api private
Public Class Methods
config_filename_for_cwd()
click to toggle source
@return [String]
# File lib/nanoc/base/repos/config_loader.rb, line 28 def self.config_filename_for_cwd filenames = %w( nanoc.yaml config.yaml ) candidate = filenames.find { |f| File.file?(f) } candidate && File.expand_path(candidate) end
cwd_is_nanoc_site?()
click to toggle source
@return [Boolean]
# File lib/nanoc/base/repos/config_loader.rb, line 23 def self.cwd_is_nanoc_site? !config_filename_for_cwd.nil? end
Public Instance Methods
apply_parent_config(config, processed_paths = [])
click to toggle source
@api private
# File lib/nanoc/base/repos/config_loader.rb, line 46 def apply_parent_config(config, processed_paths = []) parent_path = config[:parent_config_file] return config if parent_path.nil? # Get absolute path parent_path = File.absolute_path(parent_path, File.dirname(processed_paths.last)) unless File.file?(parent_path) raise NoParentConfigFileFoundError.new(parent_path) end # Check recursion if processed_paths.include?(parent_path) raise CyclicalConfigFileError.new(parent_path) end # Load parent_config = Nanoc::Int::Configuration.new(YAML.load_file(parent_path)) full_parent_config = apply_parent_config(parent_config, processed_paths + [parent_path]) full_parent_config.merge(config.without(:parent_config_file)) end
new_from_cwd()
click to toggle source
# File lib/nanoc/base/repos/config_loader.rb, line 34 def new_from_cwd # Determine path filename = self.class.config_filename_for_cwd raise NoConfigFileFoundError if filename.nil? # Read apply_parent_config( Nanoc::Int::Configuration.new(YAML.load_file(filename)), [filename]).with_defaults end