File Coverage

blib/lib/Module/cpmfile/Util.pm
Criterion Covered Total %
statement 32 32 100.0
branch 2 4 50.0
condition 2 3 66.6
subroutine 7 7 100.0
pod 0 1 0.0
total 43 47 91.4


line stmt bran cond sub pod time code
1             package Module::cpmfile::Util;
2 3     3   48 use v5.24;
  3         9  
3 3     3   14 use warnings;
  3         7  
  3         219  
4 3     3   14 use experimental qw(lexical_subs signatures);
  3         4  
  3         24  
5              
6 3     3   499 use CPAN::Meta::Requirements;
  3         5  
  3         120  
7              
8 3     3   14 use Exporter 'import';
  3         4  
  3         1183  
9             our @EXPORT_OK = qw(merge_version _yaml_hash);
10              
11             my $TEST_PACKAGE = '__TEST_PACKAGE__';
12              
13 1     1 0 1 sub merge_version ($v1, $v2) {
  1         2  
  1         2  
  1         2  
14 1         26 my $r = CPAN::Meta::Requirements->new;
15 1 50       37 $r->add_string_requirement($TEST_PACKAGE, $v1) if defined $v1;
16 1 50       332 $r->add_string_requirement($TEST_PACKAGE, $v2) if defined $v2;
17 1         172 $r->requirements_for_module($TEST_PACKAGE);
18             }
19              
20             {
21             my $YAML;
22 4     4   7 sub _yaml_hash ($hash, $indent) {
  4         6  
  4         5  
  4         5  
23 4   66     14 $YAML ||= do { require YAML::PP; YAML::PP->new(header => 0) };
  1         13  
  1         10  
24 4         2797 my @string = split /\n/, $YAML->dump_string($hash);
25 4         4334 map { "$indent$_" } @string;
  6         31  
26             }
27             }
28              
29             1;