lib/BeamerReveal/TemplateStore.pm

filter: Statementstmt 30.7% 12 / 39 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 42.8% 3 / 7 Podpod 100% 3 / 3 totaltotal 27.2% 18 / 66 CC 9 SCAR 26.5
CC
9
Cov
22%
_readTemplate
30.0
stampTemplate
12.0
new
6.0
CRAP 14.2
« lib/BeamerReveal/Object/Presentation.pm ↑ Summary lib/BeamerReveal/FrameConverter.pm »
1 # -*- cperl -*-
2 # ABSTRACT: TemplateStore
3  
4  
5 package BeamerReveal::TemplateStore;
6 1 our $VERSION = '20261115.1249'; # VERSION
7  
8 1 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use BeamerReveal::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 my $store = undef;
14  
15  
16 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
17 0 my $class = shift;
18
19 0 ▶ $class = (ref $class ? ref $class : $class );
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
20 0 my $self = {};
21 0 bless $self, $class;
22 }
23  
24  
25  
26 0 ▶sub fetch {
Subroutine fetch: not called CC=2 SCAR=17.9
Pod documented
27 0 my $self = shift;
28 0 my ( $library, $fileName ) = @_;
29  
30 0 my $key = $library . '/' . $fileName;
31 0 ▶ $store->{$key} = _readTemplate( $library, $fileName ) unless( exists $store->{$key} );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $store->{$key} 0 0 0
32 0 return $store->{$key};
33 }
34  
35  
36 0 ▶sub stampTemplate {
Subroutine stampTemplate: not called CC=3 SCAR=24.8
Pod documented
37 0 my ( $string, $hash ) = @_;
38
39 0 ▶ while( my ( $stamp, $value ) = each %$hash ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$hash) 0 0 0
40 0 ▶ if ( defined( $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
41 0 $string =~ s/---${stamp}---/$value/g;
42 }
43 else {
44 0 my $lcstamp = lc( $stamp );
45 0 $string =~ s/(?:${lcstamp}\s*[:=]\s*)?"?-*-${stamp}-*-"?//g;
46 }
47 }
48 0 return $string;
49 }
50  
51  
52 0 ▶sub _readTemplate {
Subroutine _readTemplate: not called CC=5 SCAR=34.0
53 0 my ( $library, $fileName ) = @_;
54  
55 0 ▶ my $home = $^O eq 'MSWin32' ? $ENV{'userprofile'} : $ENV{'HOME'};
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 0 0
56 0 ▶ my $configDir = $ENV{'BEAMERREVEAL_CONFIG'}
Condition0%0/2
$ENV{"BEAMERREVEAL_CONFIG"} // "$home/.config/BeamerReveal"
l!l
00
MC/DC0%0/1
$ENV{"BEAMERREVEAL_CONFIG"} // "$home/.config/BeamerReveal"
$ENV{"BEAMERREVEAL_CONFIG"}
Truth table0%0/2
A
A= $ENV{"BEAMERREVEAL_CONFIG"}
Aresult
11
00
57 // "$home/.config/BeamerReveal";
58 0 my $templateFileName = "$configDir/templates/$library/$fileName";
59 0 ▶ $templateFileName = File::ShareDir::dist_dir( 'BeamerReveal' ) . "/templates/$library/$fileName"
Branch: 1 branch
BranchTrueFalseTotal
unless -r $templateFileName 0 0 0
60 if ( ! -r $templateFileName );
61
62 0 my $templateFile = IO::File->new();
63 0 ▶ $templateFile->open( "<$templateFileName" )
Branch: 1 branch
BranchTrueFalseTotal
$templateFile->open("<$templateFileName") or $BeamerReveal::Log::logger->fatal("Error: installation incomplete - cannot find the template file '${fileName}'") 0 0 0
64 or $BeamerReveal::Log::logger->fatal( "Error: installation incomplete - cannot find the template file '$fileName'" );
65 0 my $content = do { local $/; <$templateFile> };
66 0 return $content;
67 }
68  
69  
70 1 1;
71  
72 __END__
« lib/BeamerReveal/Object/Presentation.pm ↑ Summary lib/BeamerReveal/FrameConverter.pm »