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   1524749 use strict;
  12         26  
  12         438  
3 12     12   107 use warnings;
  12         24  
  12         956  
4              
5             our $VERSION = '0.02';
6              
7 12     12   5185 use parent 'Exporter';
  12         3437  
  12         81  
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 13     13   141 my $class = shift;
18 13         46 my @args = @_;
19              
20             # Check for :keywords tag
21 13         48 my $enable_keywords = 0;
22 13         19 my @export_args;
23 13         38 for my $arg (@args) {
24 46 100       132 if ($arg eq ':keywords') {
25 7         16 $enable_keywords = 1;
26             } else {
27 39         76 push @export_args, $arg;
28             }
29             }
30              
31             # Enable keyword hints if requested
32 13 100       57 if ($enable_keywords) {
33 7         50 $^H{"Data::Path::XS/pathget"} = 1;
34 7         33 $^H{"Data::Path::XS/pathset"} = 1;
35 7         23 $^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 13 100       30478 if (@export_args) {
41 6         22459 $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__