Module: Leftovers::Precompilers::YAML

Includes:
Autoloader
Defined in:
lib/leftovers/precompilers/yaml.rb,
lib/leftovers/precompilers/yaml/builder.rb

Defined Under Namespace

Classes: Builder

Constant Summary

Constants included from Autoloader

Autoloader::ALL_CAPS_NAMES

Class Method Summary collapse

Methods included from Autoloader

class_from_path, dir_path_from_class, glob_children, included, root

Class Method Details

.precompile(yaml) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/leftovers/precompilers/yaml.rb', line 10

def self.precompile(yaml)
  builder = Builder.new
  parser = ::Psych::Parser.new(builder)
  parser.parse(yaml)

  builder.to_ruby_file
rescue ::Psych::SyntaxError => e
  message = [e.problem, e.context].compact.join(' ')
  raise PrecompileError.new(message, line: e.line, column: e.column)
end