Aion-Format
view release on metacpan or search on metacpan
lib/Aion/Format/Yaml.pm view on Meta::CPAN
package Aion::Format::Yaml;
use common::sense;
use YAML::Syck qw//;
use Exporter qw/import/;
our @EXPORT = our @EXPORT_OK = grep {
*{$Aion::Format::Yaml::{$_}}{CODE} && !/^(_|(NaN|import)\z)/n
} keys %Aion::Format::Yaml::;
#@category yaml
# ÐаÑÑÑаиваем yaml
$YAML::Syck::Headless = 1;
$YAML::Syck::SortKeys = 1;
$YAML::Syck::ImplicitTyping = 1;
$YAML::Syck::ImplicitUnicode = 1;
$YAML::Syck::ImplicitBinary = 1;
$YAML::Syck::UseCode = 1;
$YAML::Syck::LoadCode = 1;
$YAML::Syck::DumpCode = 1;
# Ð yaml
sub to_yaml(;$) {
YAML::Syck::Dump(@_ == 0? $_: @_)
}
# Ðз yaml
sub from_yaml(;$) {
scalar YAML::Syck::Load(@_ == 0? $_: @_)
}
1;
__END__
=encoding utf-8
=head1 NAME
Aion::Format::Yaml - converter from/to yaml
=head1 SYNOPSIS
use Aion::Format::Yaml qw/from_yaml to_yaml/;
to_yaml {foo => 'bar'} # -> "foo: bar\n"
from_yaml "a: b" # --> {a => "b"}
=head1 DESCRIPTION
Converts from/to yaml. Under the hood it uses C<YAML::Syck>, customized to Aion's requirements.
=head1 SUBROUTINES
=head2 to_yaml ($struct)
In yaml.
to_yaml {foo => undef} # => foo: ~\n
to_yaml {foo => 'true'} # => foo: 'true'\n
=head2 from_yaml ($string)
From yaml.
Boolean values:
( run in 2.126 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )