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   165595 use base qw(Exporter);
  7         13  
  7         1173  
4 7     7   53 use strict;
  7         16  
  7         222  
5 7     7   33 use warnings;
  7         13  
  7         410  
6              
7 7     7   1656 use Readonly;
  7         15048  
  7         2627  
8              
9             Readonly::Array our @EXPORT_OK => qw(process_module_name_and_version);
10              
11             our $VERSION = 0.14;
12              
13             # Code from Menlo::CLI::Compat
14             sub process_module_name_and_version {
15 5     5 1 285893 my $module_string = shift;
16              
17             # Plack@1.2 -> Plack~"==1.2"
18             # BUT don't expand @ in git URLs
19 5         30 $module_string =~ s/^([A-Za-z0-9_:]+)@([v\d\._]+)$/$1~== $2/;
20              
21             # Plack~1.20, DBI~"> 1.0, <= 2.0"
22 5         23 my ($module_name, $module_version_range);
23 5 100       29 if ($module_string =~ /\~[v\d\._,\!<>= ]+$/) {
24 2         15 ($module_name, $module_version_range)
25             = split '~', $module_string, 2;
26             } else {
27 3         6 $module_name = $module_string;
28             }
29              
30 5         41 return ($module_name, $module_version_range);
31             }
32              
33             1;
34              
35             __END__