Home

Awesome

mruby-yaml

Ubuntu Status

YAML gem for mruby

mruby-yaml wraps libyaml and therefore complies with the YAML 1.1 standard. File IO is not supported, as this would create a dependency on other mruby gems.

Defines

NameDefaultDescription
MRUBY_YAML_NULLtrueenables null, Null, NULL
MRUBY_YAML_BOOLEAN_ONtrueenables on, On, ON
MRUBY_YAML_BOOLEAN_YEStrueenables yes, Yes, YES
MRUBY_YAML_BOOLEAN_SHORTHAND_YESfalseenables y, Y
MRUBY_YAML_BOOLEAN_OFFtrueenables off, Off, OFF
MRUBY_YAML_BOOLEAN_NOtrueenables no, No, NO
MRUBY_YAML_BOOLEAN_SHORTHAND_NOfalseenables n, N

If you need to check if a feature is supported at runtime, replace MRUBY_YAML_ with SUPPORT_ for the runtime equivalent.

EG.

if YAML::SUPPORT_NULL
  YAML.load('null') == nil
else  
  YAML.load('null') == 'null'
end

Getting libyaml

If you have a compiled version of libyaml available on your system, you can use it by setting the environment variable MRUBY_YAML_USE_SYSTEM_LIBRARY to a non-empty value and ensuring your compiler can find the library.

Otherwise, Rake will attempt to compile it from sources obtained from the offical libyaml GitHub repository. This requires that you have autoconf installed.

Documentation

YAML.load(yaml_str)

Converts a YAML 1.1 string to a Ruby object containing hashes, arrays, and strings. YAML scalars (i.e. strings) are converted to Fixnum or Floats if possible.

YAML.dump(obj)

Converts a Ruby object to a YAML 1.1 string. Arrays, Hashes, and their subclasses are represented as YAML sequences and mapping nodes. Other objects are converted to strings and represented as scalars.