File Coverage

blib/lib/PMVersions/Util.pm
Criterion Covered Total %
statement 27 28 96.4
branch 1 2 50.0
condition 5 11 45.4
subroutine 8 8 100.0
pod 2 2 100.0
total 43 51 84.3


line stmt bran cond sub pod time code
1             package PMVersions::Util;
2              
3             our $DATE = '2018-06-07'; # DATE
4             our $VERSION = '0.001'; # VERSION
5              
6 1     1   73458 use 5.010001;
  1         12  
7 1     1   4 use strict;
  1         1  
  1         16  
8 1     1   4 use warnings;
  1         1  
  1         22  
9              
10 1     1   482 use Config::IOD::Reader;
  1         4729  
  1         30  
11 1     1   408 use File::HomeDir;
  1         4422  
  1         46  
12              
13 1     1   6 use Exporter qw(import);
  1         2  
  1         150  
14             our @EXPORT_OK = qw(read_pmversions version_from_pmversions);
15              
16             sub read_pmversions {
17 2     2 1 1492 my ($path) = @_;
18              
19 2   33     6 $path //= $ENV{PMVERSIONS_PATH};
20 2   33     6 $path //= File::HomeDir->my_home . "/pmversions.ini";
21 2         2 my $hoh;
22 2 50       33 if (-e $path) {
23 2         22 $hoh = Config::IOD::Reader->new->read_file($path);
24             } else {
25 0         0 die "pmversions file '$path' does not exist";
26             }
27              
28 2   50     10240 $hoh->{GLOBAL} // {};
29             }
30              
31             my $pmversions;
32             sub version_from_pmversions {
33 3     3 1 2728 my ($mod, $path) = @_;
34              
35 3   66     13 $pmversions //= read_pmversions($path);
36 3         12 $pmversions->{$mod};
37             }
38              
39             1;
40             # ABSTRACT: Utilities related to pmversions.ini
41              
42             __END__