blib/lib/Filename/Perl/Release.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 38 / 38 CC 3 SCAR 6.2
CC
3
Cov
100%
check_perl_release_filename
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
↑ Summary
1 package Filename::Perl::Release;
2  
3 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 2 our $DATE = '2023-12-16'; # DATE
11 2 our $DIST = 'Filename-Perl-Release'; # DIST
12 2 our $VERSION = '0.002'; # VERSION
13  
14 2 our @EXPORT_OK = qw(check_perl_release_filename);
15  
16 2 our %SPEC;
17  
18 $SPEC{check_perl_release_filename} = {
19 2 v => 1.1,
20 summary => 'Check whether filename looks like a perl module release archive, e.g. a CPAN release tarball',
21 description => <<'MARKDOWN',
22  
23  
24 MARKDOWN
25 args => {
26 filename => {
27 schema => 'str*',
28 req => 1,
29 pos => 0,
30 },
31 },
32 result_naked => 1,
33 result => {
34 schema => ['any*', of=>['bool*', 'hash*']],
35 description => <<'MARKDOWN',
36  
37 Return false if not detected like a perl module release archive. Otherwise
38 return a hash of information, which contains these keys: `distribution`,
39 `module`, `version`.
40  
41 MARKDOWN
42 },
43 examples => [
44 {
45 args => {filename=>'foo.bar'},
46 },
47 {
48 args => {filename=>'qux-quux-0.123.tar.gz'},
49 },
50 ],
51 };
52 3 ▶sub check_perl_release_filename {
Subroutine check_perl_release_filename: called CC=3 SCAR=11.0
Pod documented
53 3 require Filename::Archive;
54  
55 3 my %args = @_;
56  
57 3 my $filename = $args{filename};
58  
59 3 my $cares = Filename::Archive::check_archive_filename(filename=>$filename, ci=>1);
60 3 ▶ return 0 unless $cares;
Branch: 1 branch
BranchTrueFalseTotal
unless $cares 1 2 3
61  
62 $cares->{filename_without_suffix} =~
63 2 ▶ /\A
Branch: 1 branch
BranchTrueFalseTotal
$cares->{"filename_without_suffix"} =~ /\A (\w+(?:-\w+)*) -v?(\d+(?:\.\d+){0,}(_\d+|-TRIAL)?) \z/xi or return 0 1 1 2
64 (\w+(?:-\w+)*)
65 -v?(\d+(?:\.\d+){0,}(_\d+|-TRIAL)?)
66 \z/ix
67 or return 0;
68 1 my ($dist, $ver) = ($1, $2);
69 1 (my $mod = $dist) =~ s/-/::/g;
70 1 {distribution => $dist, module=>$mod, version=>$ver, archive_suffix=>$cares->{archive_suffix}};
71 }
72  
73 2 1;
74 # ABSTRACT: Check whether filename looks like a perl module release archive, e.g. a CPAN release tarball
75  
76 __END__
↑ Summary