| 1 | package Lib::Pepper; | ||||||||||||||||||||||||||||
| 2 | #---AUTOPRAGMASTART--- | ||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use v5.42; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use diagnostics; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use English; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Carp qw[carp croak confess cluck longmess shortmess]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 6 | our $VERSION = 0.5; | |||||||||||||||||||||||||||
| 10 | 6 | ▶ | use autodie qw( close ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use Array::Contains; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use Data::Printer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | #---AUTOPRAGMAEND--- | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 6 | 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 | 6 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 52 | all => \@EXPORT_OK, | ||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 6 | require XSLoader; | |||||||||||||||||||||||||||
| 56 | 6 | XSLoader::load('Lib::Pepper', $VERSION); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # Library initialization wrapper with better error handling | ||||||||||||||||||||||||||||
| 59 | ▶ | sub initialize($class, %params) { | |||||||||||||||||||||||||||
|
Subroutine
initialize: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $libPath = $params{library_path} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$params{'library_path'} || ''
MC/DC0%0/1
$params{'library_path'} || ''
$params{'library_path'}
Truth table0%0/2
A
A= $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 | ▶ | if($result < 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | croak("Library initialization failed with code: $result"); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | return $terminalTypeList; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # Library finalization wrapper | ||||||||||||||||||||||||||||
| 74 | ▶ | sub finalize($class) { | |||||||||||||||||||||||||||
|
Subroutine
finalize: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 0 | my $result = pepFinalize(); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if($result < 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | croak("Library finalization failed with code: $result"); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | return 1; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # Get version information | ||||||||||||||||||||||||||||
| 85 | ▶ | sub version($class) { | |||||||||||||||||||||||||||
|
Subroutine
version: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | my ($result, $major, $minor, $service, $revision, $api, $osArch, $releaseType, $configType) = pepVersion(); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if($result < 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | ▶ | sub dataDir($class) { | |||||||||||||||||||||||||||
|
Subroutine
dataDir: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 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 | ▶ | if(-d $dataDir && -f File::Spec->catfile($dataDir, 'pepper_cardtypes.xml')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $dataDir and -f "File::Spec"->catfile($dataDir, "pepper_cardtypes.xml")
MC/DC0%0/2
-d $dataDir and -f "File::Spec"->catfile($dataDir, "pepper_cardtypes.xml")
-d $dataDir
-f "File::Spec"->catfile($dataDir, "pepper_cardtypes.xml")
Truth table0%0/3
A and B
A= -d $dataDirB= -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 | ▶ | if(defined $module_path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | ▶ | if(-d $devShare && -f File::Spec->catfile($devShare, 'pepper_cardtypes.xml')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $devShare and -f "File::Spec"->catfile($devShare, "pepper_cardtypes.xml")
MC/DC0%0/2
-d $devShare and -f "File::Spec"->catfile($devShare, "pepper_cardtypes.xml")
-d $devShare
-f "File::Spec"->catfile($devShare, "pepper_cardtypes.xml")
Truth table0%0/3
A and B
A= -d $devShareB= -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 | ▶ | sub cardtypesFile($class) { | |||||||||||||||||||||||||||
|
Subroutine
cardtypesFile: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 139 | 0 | my $dataDir = $class->dataDir(); | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | return unless defined $dataDir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | my $cardtypesPath = File::Spec->catfile($dataDir, 'pepper_cardtypes.xml'); | |||||||||||||||||||||||||||
| 143 | 0 | ▶ | return -f $cardtypesPath ? $cardtypesPath : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 6 | 1; | |||||||||||||||||||||||||||
| 147 | __END__ | ||||||||||||||||||||||||||||