File Coverage

blib/lib/Data/Path/XS.pm
Criterion Covered Total %
statement 29 29 100.0
branch 6 6 100.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 40 40 100.0


line stmt bran cond sub pod time code
1             package Data::Path::XS;
2 20     20   1864897 use strict;
  20         37  
  20         648  
3 20     20   160 use warnings;
  20         37  
  20         1346  
4              
5             our $VERSION = '0.03';
6              
7 20     20   7230 use parent 'Exporter';
  20         4950  
  20         97  
8             our @EXPORT_OK = qw(path_get path_set path_delete path_exists
9             patha_get patha_set patha_delete patha_exists
10             path_compile pathc_get pathc_set pathc_delete pathc_exists);
11              
12             require XSLoader;
13             XSLoader::load('Data::Path::XS', $VERSION);
14              
15             # Custom import to handle both Exporter and keyword hints
16             sub import {
17 33     33   298673 my $class = shift;
18 33         108 my @args = @_;
19              
20             # Check for :keywords tag
21 33         41 my $enable_keywords = 0;
22 33         43 my @export_args;
23 33         90 for my $arg (@args) {
24 132 100       210 if ($arg eq ':keywords') {
25 18         34 $enable_keywords = 1;
26             } else {
27 114         166 push @export_args, $arg;
28             }
29             }
30              
31             # Enable keyword hints if requested
32 33 100       105 if ($enable_keywords) {
33 18         78 $^H{"Data::Path::XS/pathget"} = 1;
34 18         46 $^H{"Data::Path::XS/pathset"} = 1;
35 18         43 $^H{"Data::Path::XS/pathdelete"} = 1;
36 18         37 $^H{"Data::Path::XS/pathexists"} = 1;
37             }
38              
39             # Forward to Exporter for function exports
40 33 100       40036 if (@export_args) {
41 15         19818 $class->export_to_level(1, $class, @export_args);
42             }
43             }
44              
45             sub unimport {
46 1     1   5 my $class = shift;
47 1         3 delete $^H{"Data::Path::XS/pathget"};
48 1         1 delete $^H{"Data::Path::XS/pathset"};
49 1         2 delete $^H{"Data::Path::XS/pathdelete"};
50 1         1283 delete $^H{"Data::Path::XS/pathexists"};
51             }
52              
53             1;
54              
55             __END__