File Coverage

blib/lib/Text/KDL/XS.pm
Criterion Covered Total %
statement 30 30 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 2 2 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1             package Text::KDL::XS;
2              
3 7     7   951462 use strict;
  7         15  
  7         283  
4 7     7   95 use warnings;
  7         15  
  7         546  
5              
6             our $VERSION = '0.001';
7              
8 7     7   44 use XSLoader;
  7         13  
  7         265  
9             XSLoader::load(__PACKAGE__, $VERSION);
10              
11 7     7   3551 use Text::KDL::XS::Parser;
  7         18  
  7         280  
12 7     7   3437 use Text::KDL::XS::Value;
  7         21  
  7         1877  
13 7     7   3358 use Text::KDL::XS::Node;
  7         24  
  7         267  
14 7     7   3716 use Text::KDL::XS::Document;
  7         19  
  7         291  
15              
16 7     7   49 use Exporter 'import';
  7         17  
  7         1304  
17             our @EXPORT_OK = qw(parse_kdl emit_kdl);
18              
19             # parse_kdl($source, %opts) -> Text::KDL::XS::Document
20             # $source : string | filehandle | coderef
21             # %opts : version => 'detect'|'1'|'2', emit_comments => 0|1
22             sub parse_kdl {
23 20     20 1 862014 my ($source, %opts) = @_;
24 20         130 my $parser = Text::KDL::XS::Parser->new($source, %opts);
25 19         115 return Text::KDL::XS::Document->_build_from_parser($parser);
26             }
27              
28             # emit_kdl($tree, %opts) -> string
29             # $tree : Text::KDL::XS::Document | Text::KDL::XS::Node | arrayref of Nodes
30             sub emit_kdl {
31 13     13 1 166415 my ($tree, %opts) = @_;
32 13         1214 require Text::KDL::XS::Emitter;
33 13         75 return Text::KDL::XS::Emitter->_emit_tree($tree, %opts);
34             }
35              
36             1;
37              
38             __END__