File Coverage

blib/lib/Data/DPath.pm
Criterion Covered Total %
statement 30 30 100.0
branch n/a
condition n/a
subroutine 14 14 100.0
pod 5 5 100.0
total 49 49 100.0


line stmt bran cond sub pod time code
1             package Data::DPath;
2             # git description: v0.59-6-g53d9a3f
3              
4             our $AUTHORITY = 'cpan:SCHWIGON';
5             # ABSTRACT: DPath is not XPath!
6             $Data::DPath::VERSION = '0.60';
7 11     11   2052734 use 5.008;
  11         44  
8 11     11   62 use strict;
  11         80  
  11         332  
9 11     11   55 use warnings;
  11         21  
  11         1086  
10              
11             our $DEBUG = 0;
12             our $USE_SAFE = 1;
13             our $PARALLELIZE = 0;
14              
15 11     11   6028 use Data::DPath::Path;
  11         44  
  11         515  
16 11     11   100 use Data::DPath::Context;
  11         29  
  11         3155  
17              
18             sub build_dpath {
19             return sub ($) {
20 375     375   4818637 my ($path_str) = @_;
21 375         2627 Data::DPath::Path->new(path => $path_str);
22 8     8 1 1161 };
23             }
24              
25             sub build_dpathr {
26             return sub ($) {
27 37     37   111707 my ($path_str) = @_;
28 37         268 Data::DPath::Path->new(path => $path_str, give_references => 1);
29 4     4 1 313 };
30             }
31              
32             sub build_dpathi {
33             return sub ($) {
34 1     1   485794 my ($data, $path_str) = @_;
35              
36 1         29 Data::DPath::Context
37             ->new
38             ->current_points([ Data::DPath::Point->new->ref(\$data) ])
39             ->_search(Data::DPath::Path->new(path => "/"))
40             ->_iter
41             ->value; # there is always exactly one root "/"
42 1     1 1 191 };
43             }
44              
45 11         552 use Sub::Exporter -setup => {
46             exports => [ dpath => \&build_dpath,
47             dpathr => \&build_dpathr,
48             dpathi => \&build_dpathi,
49             ],
50             groups => { all => [ 'dpath', 'dpathr' ] },
51 11     11   9190 };
  11         195350  
52              
53             sub match {
54 6     6 1 23762 my ($class, $data, $path_str) = @_;
55 6         46 Data::DPath::Path->new(path => $path_str)->match($data);
56             }
57              
58             sub matchr {
59 2     2 1 45 my ($class, $data, $path_str) = @_;
60 2         11 Data::DPath::Path->new(path => $path_str)->matchr($data);
61             }
62              
63             # ------------------------------------------------------------
64              
65             1;
66              
67             __END__