blib/lib/Astro/App/Satpass2/Format/Template/Provider.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 87.5% 42 / 48 CC 5 SCAR 11.1
CC
5
Cov
85%
_template_content
5.5
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« blib/lib/Astro/App/Satpass2/FormatTime.pm ↑ Summary blib/lib/Astro/App/Satpass2/Macro/Command.pm »
1 package Astro::App::Satpass2::Format::Template::Provider;
2  
3 8 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶use parent qw{ Template::Provider };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use Astro::App::Satpass2::Utils qw{ :os @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 our $VERSION = '0.059';
13  
14 8 ▶use constant ENCODING => OS_IS_WINDOWS ?
Subroutine BEGIN: called CC=1 SCAR=0.0
15 ':crlf:encoding(utf-8)' :
16 8 ':encoding(utf-8)';
17  
18 # Cribbed **ALMOST** verbatim from Template::Provider. The only
19 # difference is the binmode() call, which applies I/O layers as
20 # convenient.
21 ## no critic (UnusedPrivateSubroutines,UnusedVarsStricter,ProhibitBarewordFileHandles,ProhibitInterpolationOfLiterals)
22  
23 2 ▶sub _template_content {
Subroutine _template_content: called CC=5 SCAR=17.1
24 2 my ($self, $path) = @_;
25  
26 2 ▶ return (undef, "No path specified to fetch content from ")
Branch: 1 branch
BranchTrueFalseTotal
unless $path 0 2 2
27 unless $path;
28  
29 2 my $data;
30 my $mod_date;
31 2 my $error;
32  
33 2 local *FH;
34 2 ▶ if(-d $path) {
Branch: 2 branches
BranchTrueFalseTotal
if (-d $path) { } 0 2 2
elsif (open FH, '<', $path) { } 2 0 2
35 0 $error = "$path: not a file";
36 }
37 elsif (open(FH, "<", $path)) {
38 2 local $/;
39 2 binmode(FH, ENCODING);
40 2 $data = <FH>;
41 2 $mod_date = (stat($path))[9];
42 2 close(FH);
43 }
44 else {
45 0 $error = "$path: $!";
46 }
47  
48 return wantarray
49 2 ▶ ? ( $data, $error, $mod_date )
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 0 2
50 : $data;
51 }
52  
53 ## use critic
54  
55 8 1;
56  
57 __END__
« blib/lib/Astro/App/Satpass2/FormatTime.pm ↑ Summary blib/lib/Astro/App/Satpass2/Macro/Command.pm »