class ComfyConf::Parser

Attributes

definition[R]
pathname[R]

Public Class Methods

new(pathname, &block) click to toggle source
# File lib/comfy_conf/parser.rb, line 8
def initialize(pathname, &block)
  @pathname = Pathname.new(pathname)
  @definition = Definition.new('root', &block)
end

Public Instance Methods

data() click to toggle source
# File lib/comfy_conf/parser.rb, line 14
def data
  @data ||= Data.new(nil, definition, type_checked_config_data)
end

Private Instance Methods

config_data() click to toggle source
# File lib/comfy_conf/parser.rb, line 27
def config_data
  @config_data ||= YAML.load(pathname.read)
rescue Psych::SyntaxError => e
  raise ParseError,
    "YAML parse error in config file #{pathname}: #{e.message}"
end
type_checked_config_data() click to toggle source
# File lib/comfy_conf/parser.rb, line 20
def type_checked_config_data
  unless config_data.kind_of?(Hash)
    raise ParseError, "YAML config data must be a hash.  File: #{pathname}"
  end
  config_data
end