blib/lib/App/Prove/Elasticsearch/Versioner/Default.pm

filter: Statementstmt 100% 30 / 30 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 97.8% 46 / 47 CC 6 SCAR 13.2
CC
6
Cov
98%
get_version
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« blib/lib/App/ape/update.pm ↑ Summary blib/lib/App/Prove/Elasticsearch/Blamer/Default.pm »
1 # ABSTRACT: Determine the version of a system under test via the module's Changes file for upload to elasticsearch
2 # PODNAME: App::Prove::Elasticsearch::Versioner::Default
3  
4 package App::Prove::Elasticsearch::Versioner::Default;
5 3 $App::Prove::Elasticsearch::Versioner::Default::VERSION = '0.001';
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use File::Basename qw{dirname};
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Cwd qw{abs_path};
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 our $version = {};
14  
15 4 ▶sub get_version {
Subroutine get_version: called CC=6 SCAR=17.9
Pod documented
16 4 my $loc = abs_path(dirname(shift) . "/../Changes");
17  
18 4 ▶ return $version->{$loc} if $version->{$loc};
Branch: 1 branch
BranchTrueFalseTotal
if $App::Prove::Elasticsearch::Versioner::Default::version->{$loc} 1 3 4
19 3 my $ret;
20 3 ▶ open(my $fh, '<', $loc) or die "Could not open Changes in $loc";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $loc or die "Could not open Changes in $loc" 2 1 3
21 2 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 1 1 2
22 1 ($ret) = $_ =~ m/(^\S*)/;
23 1 ▶ last if $ret;
Branch: 1 branch
BranchTrueFalseTotal
if $ret 1 0 1
24 }
25 2 close $fh;
26 2 ▶ die 'Could not determine the latest version from Changes!' unless $ret;
Branch: 1 branch
BranchTrueFalseTotal
unless $ret 1 1 2
27 1 $version->{$loc} = $ret;
28 1 return $ret;
29 }
30  
31 3 *get_file_version = \&get_version;
32  
33 3 1;
34  
35 __END__
« blib/lib/App/ape/update.pm ↑ Summary blib/lib/App/Prove/Elasticsearch/Blamer/Default.pm »