File Coverage

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


line stmt bran cond sub pod time code
1             package Data::Path::XS;
2 12     12   1588350 use strict;
  12         28  
  12         496  
3 12     12   116 use warnings;
  12         25  
  12         967  
4              
5             our $VERSION = '0.01';
6              
7 12     12   5084 use parent 'Exporter';
  12         3518  
  12         75  
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 12     12   137 my $class = shift;
18 12         45 my @args = @_;
19              
20             # Check for :keywords tag
21 12         23 my $enable_keywords = 0;
22 12         23 my @export_args;
23 12         34 for my $arg (@args) {
24 46 100       110 if ($arg eq ':keywords') {
25 7         16 $enable_keywords = 1;
26             } else {
27 39         74 push @export_args, $arg;
28             }
29             }
30              
31             # Enable keyword hints if requested
32 12 100       61 if ($enable_keywords) {
33 7         49 $^H{"Data::Path::XS/pathget"} = 1;
34 7         24 $^H{"Data::Path::XS/pathset"} = 1;
35 7         18 $^H{"Data::Path::XS/pathdelete"} = 1;
36 7         21 $^H{"Data::Path::XS/pathexists"} = 1;
37             }
38              
39             # Forward to Exporter for function exports
40 12 100       25483 if (@export_args) {
41 6         28663 $class->export_to_level(1, $class, @export_args);
42             }
43             }
44              
45             sub unimport {
46 0     0     my $class = shift;
47 0           delete $^H{"Data::Path::XS/pathget"};
48 0           delete $^H{"Data::Path::XS/pathset"};
49 0           delete $^H{"Data::Path::XS/pathdelete"};
50 0           delete $^H{"Data::Path::XS/pathexists"};
51             }
52              
53             1;
54              
55             __END__