Module: YAML

### Home Classes Methods

### In Files

- lib/safe_yaml.rb
- lib/safe_yaml/syck_hack.rb

### Methods

- ::load
- ::load_file
- ::load_file_with_options
- ::load_with_options
- ::safe_load
- ::safe_load_file
- ::unsafe_load
- ::unsafe_load_file

### Class/Module Index

Quicksearch

- SafeYAML
- SafeYAML::Deep
- SafeYAML::Parse
- SafeYAML::Parse::Date
- SafeYAML::Parse::Hexadecimal
- SafeYAML::Parse::Sexagesimal
- SafeYAML::PsychHandler
- SafeYAML::PsychResolver
- SafeYAML::Resolver
- SafeYAML::SafeToRubyVisitor
- SafeYAML::SyckResolver
- SafeYAML::Transform
- SafeYAML::Transform::ToBoolean
- SafeYAML::Transform::ToDate
- SafeYAML::Transform::ToFloat
- SafeYAML::Transform::ToInteger
- SafeYAML::Transform::ToNil
- SafeYAML::Transform::ToSymbol
- SafeYAML::Transform::TransformationMap
- SafeYAML::Transform::TransformationMap::CaseAgnosticMap
- SafeYAML::Transform::TransformationMap::ClassMethods
- Object
- YAML

No matching classes.

# YAML

Hack to JRuby 1.8's YAML Parser Yecht

This file is always loaded AFTER either syck or psych are already loaded. It then looks at what constants are available and creates a consistent view on all rubys.

Taken from rubygems and modified. See github.com/rubygems/rubygems/blob/master/lib/rubygems/syck_hack.rb

### Constants

Syck

### Public Class Methods

load(yaml, *original_arguments) click to toggle source
Also aliased as: unsafe_load
Alias for: load_with_options
load_file(file, options={}) click to toggle source
Alias for: load_file_with_options
load_file_with_options(file, options={}) click to toggle source

    # File lib/safe_yaml.rb, line 148
    def self.load_file_with_options(file, options={})
      safe_mode = safe_mode_from_options("load_file", options)
      if safe_mode == :safe
        safe_load_file(file, options_for_safe_load(options))
      else
        unsafe_load_file(file)
      end
    end

Also aliased as: load_file
load_with_options(yaml, *original_arguments) click to toggle source

    # File lib/safe_yaml.rb, line 133
    def self.load_with_options(yaml, *original_arguments)
      filename, options = filename_and_options_from_arguments(original_arguments)
      safe_mode = safe_mode_from_options("load", options)
      arguments = [yaml]

      if safe_mode == :safe
        arguments << filename if SafeYAML::YAML_ENGINE == "psych"
        arguments << options_for_safe_load(options)
        safe_load(*arguments)
      else
        arguments << filename if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
        unsafe_load(*arguments)
      end
    end

Also aliased as: load
safe_load(yaml, filename=nil, options={}) click to toggle source

    # File lib/safe_yaml.rb, line 162
    def self.safe_load(yaml, filename=nil, options={})
      # If the user hasn't whitelisted any tags, we can go with this implementation which is
      # significantly faster.
      if (options && options[:whitelisted_tags] || SafeYAML::OPTIONS[:whitelisted_tags]).empty?
        safe_handler = SafeYAML::PsychHandler.new(options)
        arguments_for_parse = [yaml]
        arguments_for_parse << filename if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
        Psych::Parser.new(safe_handler).parse(*arguments_for_parse)
        return safe_handler.result || false

      else
        safe_resolver = SafeYAML::PsychResolver.new(options)
        tree = SafeYAML::MULTI_ARGUMENT_YAML_LOAD ?
          Psych.parse(yaml, filename) :
          Psych.parse(yaml)
        return safe_resolver.resolve_node(tree)
      end
    end

safe_load_file(filename, options={}) click to toggle source

    # File lib/safe_yaml.rb, line 181
    def self.safe_load_file(filename, options={})
      File.open(filename, 'r:bom|utf-8') { |f| self.safe_load(f, filename, options) }
    end

unsafe_load(yaml, *original_arguments) click to toggle source
Alias for: load
unsafe_load_file(filename) click to toggle source

    # File lib/safe_yaml.rb, line 185
    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.