version 0.01
+=head1 SYNOPSIS
+
+ use TOML::Tiny qw(from_toml to_toml);
+
+ binmode STDIN, ':encoding(UTF-8)';
+ binmode STDOUT, ':encoding(UTF-8)';
+
+ # Decoding TOML
+ my $toml = do{ local $/; <STDIN> };
+ my ($parsed, $error) = from_toml $toml;
+
+ # Encoding TOML
+ say to_toml({
+ stuff => {
+ about => ['other', 'stuff'],
+ },
+ });
+
+ # Object API
+ my $parser = TOML::Tiny->new;
+ my $result = $parser->parse($toml);
+
+=head1 DESCRIPTION
+
+C<TOML::Tiny> implements a pure-perl parser and generator for the
+L<TOML|https://github.com/toml-lang/toml> data format. It conforms to TOML
+v5.0.
+
+C<TOML::Tiny> strives to maintain an interface compatible to the L<TOML> and
+L<TOML::Parser> modules, and could even be used to override C<$TOML::Parser>:
+
+ use TOML;
+ use TOML::Tiny;
+
+ local $TOML::Parser = TOML::Tiny->new(...);
+ say to_toml(...);
+
+=head1 EXPORTS
+
+=head2 from_toml
+
+=head2 to_toml
+
+=head1 OBJECT API
+
+=head2 new
+
+=head2 decode
+
+=head2 encode
+
+=head2 parse
+
+=head1 COMPATIBILITY
+
=head1 AUTHOR
Jeff Ober <sysread@fastmail.fm>
requires 'perl' => '>= 5.018';
-requires 'Scalar::Util' => '>= 1.14';
-requires 'Data::Dumper' => '0';
+
+requires 'Scalar::Util' => '>= 1.14';
+requires 'Data::Dumper' => '0';
+requires 'DateTime::Format::RFC3339' => '0';
recommends 'Types::Serialiser' => 0;
on test => sub{
requires 'Data::Dumper' => '0';
- requires 'DateTime::Format::ISO8601' => '0';
+ requires 'DateTime::Format::RFC3339' => '0';
requires 'TOML::Parser' => '0';
requires 'Test2::V0' => '0';
requires 'Test::Pod' => '0';
to_toml
);
+#-------------------------------------------------------------------------------
+# TOML module compatibility
+#-------------------------------------------------------------------------------
sub from_toml {
my $source = shift;
my $parser = TOML::Tiny::Parser->new(@_);
goto \&TOML::Tiny::Writer::to_toml;
}
+#-------------------------------------------------------------------------------
+# Object API
+#-------------------------------------------------------------------------------
+sub new {
+ my ($class, %param) = @_;
+ bless{ parser => TOML::Tiny::Parser->new(%param) }, $class;
+}
+
+sub encode {
+ my ($self, $source) = @_;
+ $self->{parser}->parse;
+}
+
+sub decode {
+ my ($self, $data) = @_;
+ TOML::Tiny::Writer::to_toml($data);
+}
+
+#-------------------------------------------------------------------------------
+# For compatibility with TOML::from_toml's use of $TOML::Parser
+#-------------------------------------------------------------------------------
+sub parse {
+ goto \&encode;
+}
+
1;
+
+=head1 SYNOPSIS
+
+ use TOML::Tiny qw(from_toml to_toml);
+
+ binmode STDIN, ':encoding(UTF-8)';
+ binmode STDOUT, ':encoding(UTF-8)';
+
+ # Decoding TOML
+ my $toml = do{ local $/; <STDIN> };
+ my ($parsed, $error) = from_toml $toml;
+
+ # Encoding TOML
+ say to_toml({
+ stuff => {
+ about => ['other', 'stuff'],
+ },
+ });
+
+ # Object API
+ my $parser = TOML::Tiny->new;
+ my $result = $parser->parse($toml);
+
+
+=head1 DESCRIPTION
+
+C<TOML::Tiny> implements a pure-perl parser and generator for the
+L<TOML|https://github.com/toml-lang/toml> data format. It conforms to TOML
+v5.0.
+
+C<TOML::Tiny> strives to maintain an interface compatible to the L<TOML> and
+L<TOML::Parser> modules, and could even be used to override C<$TOML::Parser>:
+
+ use TOML;
+ use TOML::Tiny;
+
+ local $TOML::Parser = TOML::Tiny->new(...);
+ say to_toml(...);
+
+
+=head1 EXPORTS
+
+=head2 from_toml
+
+=head2 to_toml
+
+
+=head1 OBJECT API
+
+=head2 new
+
+=head2 decode
+
+=head2 encode
+
+=head2 parse
+
+
+=head1 COMPATIBILITY
};
subtest 'inflate_datetime' => sub{
- require DateTime::Format::ISO8601;
- my $inflate = sub{ DateTime::Format::ISO8601->parse_datetime(shift) };
+ require DateTime::Format::RFC3339;
+ my $inflate = sub{ DateTime::Format::RFC3339->parse_datetime(shift) };
my $exp = TOML::Parser->new(inflate_datetime => $inflate)->parse($toml);
my $got = TOML::Tiny::Parser->new(inflate_datetime => $inflate)->parse($toml);
is $got, $exp, 'equivalence'