https://github.com/hone/mruby-yaml
YAML gem for mruby
https://github.com/hone/mruby-yaml
Last synced: 6 months ago
JSON representation
YAML gem for mruby
- Host: GitHub
- URL: https://github.com/hone/mruby-yaml
- Owner: hone
- Fork: true (mrbgems/mruby-yaml)
- Created: 2015-07-11T00:07:27.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-29T08:19:56.000Z (over 6 years ago)
- Last Synced: 2024-08-03T08:02:33.397Z (9 months ago)
- Language: C
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-mruby - mruby-yaml - libyaml wrapper for YAML Structs. Without File IO support. (Configuration)
README
## mruby-yaml
#### YAML gem for [mruby](https://github.com/mruby/mruby)
mruby-yaml wraps [libyaml](http://pyyaml.org/wiki/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
| Name | Default | Description |
| -------------------------------- | ------- | ------------------------------ |
| MRUBY_YAML_NULL | true | enables `null`, `Null`, `NULL` |
| MRUBY_YAML_BOOLEAN_ON | true | enables `on`, `On`, `ON` |
| MRUBY_YAML_BOOLEAN_YES | true | enables `yes`, `Yes`, `YES` |
| MRUBY_YAML_BOOLEAN_SHORTHAND_YES | true | enables `y`, `Y` |
| MRUBY_YAML_BOOLEAN_OFF | true | enables `off`, `Off`, `OFF` |
| MRUBY_YAML_BOOLEAN_NO | true | enables `no`, `No`, `NO` |
| MRUBY_YAML_BOOLEAN_SHORTHAND_NO | true | enables `n`, `N` |If you need to check if a feature is supported at runtime, replace `MRUBY_YAML_` with `SUPPORT_` for the runtime equivalent.
#### EG.
```ruby
if YAML::SUPPORT_NULL
YAML.load('null') == nil
else
YAML.load('null') == 'null'
end
```### 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.