File Coverage

blib/lib/Module/cpmfile/Util.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 0 1 0.0
total 34 38 89.4


line stmt bran cond sub pod time code
1             package Module::cpmfile::Util;
2 3     3   25 use strict;
  3         7  
  3         112  
3 3     3   16 use warnings;
  3         7  
  3         99  
4              
5 3     3   16 use CPAN::Meta::Requirements;
  3         18  
  3         68  
6              
7 3     3   13 use Exporter 'import';
  3         7  
  3         889  
8             our @EXPORT_OK = qw(merge_version _yaml_hash);
9              
10             my $TEST_PACKAGE = '__TEST_PACKAGE__';
11              
12             sub merge_version {
13 1     1 0 3 my ($v1, $v2) = @_;
14 1         12 my $r = CPAN::Meta::Requirements->new;
15 1 50       32 $r->add_string_requirement($TEST_PACKAGE, $v1) if defined $v1;
16 1 50       216 $r->add_string_requirement($TEST_PACKAGE, $v2) if defined $v2;
17 1         138 $r->requirements_for_module($TEST_PACKAGE);
18             }
19              
20             {
21             my $YAML;
22             sub _yaml_hash {
23 4     4   12 my ($hash, $indent) = @_;
24 4   66     10 $YAML ||= do { require YAML::PP; YAML::PP->new(header => 0) };
  1         11  
  1         8  
25 4         2079 my @string = split /\n/, $YAML->dump_string($hash);
26 4         3800 map { "$indent$_" } @string;
  6         31  
27             }
28             }
29              
30             1;