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   63320 use base qw(Exporter);
  7         21  
  7         870  
4 7     7   45 use strict;
  7         20  
  7         138  
5 7     7   31 use warnings;
  7         13  
  7         181  
6              
7 7     7   3237 use Readonly;
  7         24116  
  7         1568  
8              
9             Readonly::Array our @EXPORT_OK => qw(process_module_name_and_version);
10              
11             our $VERSION = 0.07;
12              
13             # Code from Menlo::CLI::Compat
14             sub process_module_name_and_version {
15 3     3 1 1956 my $module_string = shift;
16              
17             # Plack@1.2 -> Plack~"==1.2"
18             # BUT don't expand @ in git URLs
19 3         15 $module_string =~ s/^([A-Za-z0-9_:]+)@([v\d\._]+)$/$1~== $2/;
20              
21             # Plack~1.20, DBI~"> 1.0, <= 2.0"
22 3         6 my ($module_name, $module_version_range);
23 3 100       11 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         10 return ($module_name, $module_version_range);
31             }
32              
33             1;
34              
35             __END__