In Files

YAML

Public Class Methods

disable_arbitrary_object_deserialization!() click to toggle source
# File lib/safe_yaml.rb, line 107
def disable_arbitrary_object_deserialization!
  SafeYAML::OPTIONS[:enable_arbitrary_object_deserialization] = false
end
disable_symbol_parsing!() click to toggle source
# File lib/safe_yaml.rb, line 95
def disable_symbol_parsing!
  SafeYAML::OPTIONS[:enable_symbol_parsing] = false
end
enable_arbitrary_object_deserialization!() click to toggle source
# File lib/safe_yaml.rb, line 103
def enable_arbitrary_object_deserialization!
  SafeYAML::OPTIONS[:enable_arbitrary_object_deserialization] = true
end
enable_arbitrary_object_deserialization?() click to toggle source
# File lib/safe_yaml.rb, line 99
def enable_arbitrary_object_deserialization?
  SafeYAML::OPTIONS[:enable_arbitrary_object_deserialization]
end
enable_symbol_parsing!() click to toggle source
# File lib/safe_yaml.rb, line 91
def enable_symbol_parsing!
  SafeYAML::OPTIONS[:enable_symbol_parsing] = true
end
enable_symbol_parsing?() click to toggle source
# File lib/safe_yaml.rb, line 87
def enable_symbol_parsing?
  SafeYAML::OPTIONS[:enable_symbol_parsing]
end
load(yaml, *filename_and_options) click to toggle source
Also aliased as: unsafe_load
Alias for: load_with_options
load_file(file, options={}) click to toggle source
load_file_with_options(file, options={}) click to toggle source
# File lib/safe_yaml.rb, line 32
def self.load_file_with_options(file, options={})
  safe_mode = safe_mode_from_options("load_file", options)
  safe_mode ? safe_load_file(file) : unsafe_load_file(file)
end
Also aliased as: load_file
load_with_options(yaml, *filename_and_options) click to toggle source
# File lib/safe_yaml.rb, line 24
def self.load_with_options(yaml, *filename_and_options)
  options   = filename_and_options.last || {}
  safe_mode = safe_mode_from_options("load", options)
  arguments = [yaml]
  arguments << filename_and_options.first if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
  safe_mode ? safe_load(*arguments) : unsafe_load(*arguments)
end
Also aliased as: load
safe_load(yaml, filename=nil) click to toggle source
# File lib/safe_yaml.rb, line 39
def self.safe_load(yaml, filename=nil)
  safe_handler = SafeYAML::PsychHandler.new
  parser = Psych::Parser.new(safe_handler)
  if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
    parser.parse(yaml, filename)
  else
    parser.parse(yaml)
  end
  return safe_handler.result
end
safe_load_file(filename) click to toggle source
# File lib/safe_yaml.rb, line 50
def self.safe_load_file(filename)
  File.open(filename, 'r:bom|utf-8') { |f| self.safe_load f, filename }
end
unsafe_load(yaml, *filename_and_options) click to toggle source
Alias for: load
unsafe_load_file(filename) click to toggle source
# File lib/safe_yaml.rb, line 54
def self.unsafe_load_file(filename)
  if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
    # https://github.com/tenderlove/psych/blob/v1.3.2/lib/psych.rb#L296-298
    File.open(filename, 'r:bom|utf-8') { |f| self.unsafe_load f, filename }
  else
    # https://github.com/tenderlove/psych/blob/v1.2.2/lib/psych.rb#L231-233
    self.unsafe_load File.open(filename)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.