class EacRubyUtils::Yaml

A safe YAML loader/dumper with common types included.

def dump(object)

def dump(object)
  ::YAML.dump(sanitize(object))
end

def dump_file(path, object)

def dump_file(path, object)
  ::File.write(path.to_s, dump(object))
end

def load(string)

def load(string)
  ::YAML.safe_load(string, permitted_classes)
end

def load_file(path)

def load_file(path)
  load(::File.read(path.to_s))
end

def permitted_classes

def permitted_classes
  DEFAULT_PERMITTED_CLASSES
end

def sanitize(object)

def sanitize(object)
  Sanitizer.new(object).result
end

def yaml?(object)

def yaml?(object)
  return false unless object.is_a?(::String)
  return false unless object.start_with?('---')
  load(object)
  true
rescue ::Psych::SyntaxError
  false
end