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.57-15-gab8b720
3              
4             our $AUTHORITY = 'cpan:SCHWIGON';
5             # ABSTRACT: DPath is not XPath!
6             $Data::DPath::VERSION = '0.58';
7 10     10   662013 use 5.008;
  10         106  
8 10     10   53 use strict;
  10         16  
  10         203  
9 10     10   44 use warnings;
  10         17  
  10         628  
10              
11             our $DEBUG = 0;
12             our $USE_SAFE = 1;
13             our $PARALLELIZE = 0;
14              
15 10     10   4234 use Data::DPath::Path;
  10         32  
  10         307  
16 10     10   57 use Data::DPath::Context;
  10         17  
  10         2234  
17              
18             sub build_dpath {
19             return sub ($) {
20 390     390   1217886 my ($path_str) = @_;
21 390         1951 Data::DPath::Path->new(path => $path_str);
22 8     8 1 1072 };
23             }
24              
25             sub build_dpathr {
26             return sub ($) {
27 38     38   84626 my ($path_str) = @_;
28 38         159 Data::DPath::Path->new(path => $path_str, give_references => 1);
29 4     4 1 203 };
30             }
31              
32             sub build_dpathi {
33             return sub ($) {
34 1     1   1091 my ($data, $path_str) = @_;
35              
36 1         27 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 141 };
43             }
44              
45 10         100 use Sub::Exporter -setup => {
46             exports => [ dpath => \&build_dpath,
47             dpathr => \&build_dpathr,
48             dpathi => \&build_dpathi,
49             ],
50             groups => { all => [ 'dpath', 'dpathr' ] },
51 10     10   5807 };
  10         93600  
52              
53             sub match {
54 6     6 1 23659 my ($class, $data, $path_str) = @_;
55 6         31 Data::DPath::Path->new(path => $path_str)->match($data);
56             }
57              
58             sub matchr {
59 2     2 1 18 my ($class, $data, $path_str) = @_;
60 2         8 Data::DPath::Path->new(path => $path_str)->matchr($data);
61             }
62              
63             # ------------------------------------------------------------
64              
65             1;
66              
67             __END__