File Coverage

blib/lib/App/CPAN/Get/Utils.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package App::CPAN::Get::Utils;
2              
3 7     7   62777 use base qw(Exporter);
  7         20  
  7         876  
4 7     7   44 use strict;
  7         11  
  7         140  
5 7     7   30 use warnings;
  7         11  
  7         193  
6              
7 7     7   3455 use Readonly;
  7         25105  
  7         1625  
8              
9             Readonly::Array our @EXPORT_OK => qw(process_module_name_and_version);
10              
11             our $VERSION = 0.06;
12              
13             # Code from Menlo::CLI::Compat
14             sub process_module_name_and_version {
15 3     3 1 1840 my $module_string = shift;
16              
17             # Plack@1.2 -> Plack~"==1.2"
18             # BUT don't expand @ in git URLs
19 3         16 $module_string =~ s/^([A-Za-z0-9_:]+)@([v\d\._]+)$/$1~== $2/;
20              
21             # Plack~1.20, DBI~"> 1.0, <= 2.0"
22 3         5 my ($module_name, $module_version_range);
23 3 100       13 if ($module_string =~ /\~[v\d\._,\!<>= ]+$/) {
24 2         7 ($module_name, $module_version_range)
25             = split '~', $module_string, 2;
26             } else {
27 1         2 $module_name = $module_string;
28             }
29              
30 3         8 return ($module_name, $module_version_range);
31             }
32              
33             1;
34              
35             __END__