File Coverage

blib/lib/Lib/Pepper.pm
Criterion Covered Total %
statement 41 90 45.5
branch 0 16 0.0
condition 0 8 0.0
subroutine 14 19 73.6
pod 5 5 100.0
total 60 138 43.4


line stmt bran cond sub pod time code
1             package Lib::Pepper;
2             #---AUTOPRAGMASTART---
3 6     6   219441 use v5.42;
  6         24  
4 6     6   44 use strict;
  6         21  
  6         230  
5 6     6   1394 use diagnostics;
  6         1376285  
  6         67  
6 6     6   2555 use mro 'c3';
  6         15  
  6         50  
7 6     6   1766 use English;
  6         7642  
  6         45  
8 6     6   3273 use Carp qw[carp croak confess cluck longmess shortmess];
  6         13  
  6         644  
9             our $VERSION = 0.5;
10 6     6   1418 use autodie qw( close );
  6         47096  
  6         71  
11 6     6   3862 use Array::Contains;
  6         7180  
  6         493  
12 6     6   1279 use utf8;
  6         746  
  6         48  
13 6     6   1695 use Data::Dumper;
  6         23874  
  6         423  
14 6     6   1589 use Data::Printer;
  6         97619  
  6         45  
15             #---AUTOPRAGMAEND---
16              
17              
18 6     6   1669 use File::Spec;
  6         14  
  6         209  
19 6     6   34 use File::Basename;
  6         20  
  6         719  
20              
21 6     6   48 use parent 'Exporter';
  6         12  
  6         63  
22              
23             our @EXPORT_OK = qw(
24             pepInitialize
25             pepFinalize
26             pepVersion
27             pepCreateInstance
28             pepFreeInstance
29             pepConfigureWithCallback
30             pepPrepareOperation
31             pepStartOperation
32             pepExecuteOperation
33             pepFinalizeOperation
34             pepOperationStatus
35             pepUtility
36             pepAuxiliary
37             pepDownloadLicense
38             pepOptionListCreate
39             pepOptionListGetStringElement
40             pepOptionListGetIntElement
41             pepOptionListGetChildOptionListElement
42             pepOptionListAddStringElement
43             pepOptionListAddIntElement
44             pepOptionListAddChildOptionListElement
45             pepOptionListGetElementList
46             isValidHandle
47             isSuccess
48             isFailure
49             );
50              
51             our %EXPORT_TAGS = (
52             all => \@EXPORT_OK,
53             );
54              
55             require XSLoader;
56             XSLoader::load('Lib::Pepper', $VERSION);
57              
58             # Library initialization wrapper with better error handling
59 0     0 1   sub initialize($class, %params) {
  0            
  0            
  0            
60 0   0       my $libPath = $params{library_path} || '';
61 0           my $configXml = $params{config_xml};
62 0           my $licenseXml = $params{license_xml};
63              
64 0           my ($result, $terminalTypeList) = pepInitialize($libPath, $configXml, $licenseXml);
65              
66 0 0         if($result < 0) {
67 0           croak("Library initialization failed with code: $result");
68             }
69              
70 0           return $terminalTypeList;
71             }
72              
73             # Library finalization wrapper
74 0     0 1   sub finalize($class) {
  0            
  0            
75 0           my $result = pepFinalize();
76              
77 0 0         if($result < 0) {
78 0           croak("Library finalization failed with code: $result");
79             }
80              
81 0           return 1;
82             }
83              
84             # Get version information
85 0     0 1   sub version($class) {
  0            
  0            
86 0           my ($result, $major, $minor, $service, $revision, $api, $osArch, $releaseType, $configType) = pepVersion();
87              
88 0 0         if($result < 0) {
89 0           croak("Version query failed with code: $result");
90             }
91              
92             return {
93 0           major => $major,
94             minor => $minor,
95             service => $service,
96             revision => $revision,
97             api => $api,
98             osArch => $osArch,
99             releaseType => $releaseType,
100             configType => $configType,
101             string => "$major.$minor.$service.$revision",
102             };
103             }
104              
105             # Get the installation directory for library data files
106 0     0 1   sub dataDir($class) {
  0            
  0            
107             # Try to find the installed data directory
108             # Data files are installed alongside shared libraries in auto/Lib/Pepper/
109              
110             # Method 1: Check installed location (after 'make install')
111 0           foreach my $inc (@INC) {
112 0           my $dataDir = File::Spec->catdir($inc, 'auto', 'Lib', 'Pepper');
113 0 0 0       if(-d $dataDir && -f File::Spec->catfile($dataDir, 'pepper_cardtypes.xml')) {
114 0           return $dataDir;
115             }
116             }
117              
118             # Method 2: Check development location (for testing before install)
119             # Look for share/ directory relative to this module's location
120             # Module is at lib/Lib/Pepper.pm, share/ is at share/
121 0           my $module_path = $INC{'Lib/Pepper.pm'};
122 0 0         if(defined $module_path) {
123 0           require File::Basename;
124 0           require Cwd;
125 0           my $moduleDir = File::Basename::dirname($module_path); # lib/Lib
126 0           my $projectRoot = Cwd::abs_path(File::Spec->catdir($moduleDir, '..', '..')); # Go up to project root
127 0           my $devShare = File::Spec->catdir($projectRoot, 'share');
128 0 0 0       if(-d $devShare && -f File::Spec->catfile($devShare, 'pepper_cardtypes.xml')) {
129 0           return $devShare;
130             }
131             }
132              
133             # Not found
134 0           return;
135             }
136              
137             # Get the path to the installed pepper_cardtypes.xml file
138 0     0 1   sub cardtypesFile($class) {
  0            
  0            
139 0           my $dataDir = $class->dataDir();
140 0 0         return unless defined $dataDir;
141              
142 0           my $cardtypesPath = File::Spec->catfile($dataDir, 'pepper_cardtypes.xml');
143 0 0         return -f $cardtypesPath ? $cardtypesPath : undef;
144             }
145              
146             1;
147             __END__