| 1 | package App::ThisDist; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Log::ger; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use File::chdir; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $DATE = '2024-12-21'; # DATE | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our $DIST = 'App-ThisDist'; # DIST | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '0.024'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our @EXPORT_OK = qw(this_dist this_mod); | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub this_dist { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
this_dist: not called CC=42 SCAR=74.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | require File::Slurper; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my ($dir, $extract_version, $detail) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if (defined $dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | log_debug "chdir to $dir ..."; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | local $CWD = $dir if defined $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | unless (defined $dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $dir = Cwd::getcwd(); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | (my $dir_basename = $dir) =~ s!.+[/\\]!!; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my ($distname, $distver, $detailinfo); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $detailinfo = {}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | GUESS: { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | FROM_DISTMETA_2: { | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | for my $file ("MYMETA.json", "META.json") { | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | next unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | log_debug "Found distribution metadata $file"; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $content = File::Slurper::read_text($file); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $meta = JSON::PP::decode_json($content); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($meta && ref $meta eq 'HASH' && defined $meta->{name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$meta and ref $meta eq "HASH" and defined $meta->{"name"}
$meta and ref $meta eq "HASH"
MC/DC0%0/3
$meta and ref $meta eq "HASH" and defined $meta->{"name"}
$meta
ref $meta eq "HASH"
defined $meta->{"name"}
Truth table0%0/4
A and B and C
A= $metaB= ref $meta eq "HASH"C= defined $meta->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $distname = $meta->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | log_debug "Got distname=$distname from distribution metadata $file"; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $detailinfo->{source} = 'dist meta v2'; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $detailinfo->{dist_meta_file} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (defined $meta->{version}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $distver = $meta->{version}; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | log_debug "Got distver=$distver from distribution metadata $file"; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | FROM_DISTMETA_1_1: { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | for my $file ("MYMETA.yml", "META.yml") { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | next unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | log_debug "Found distribution metadata $file"; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | require YAML::XS; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $meta = YAML::XS::LoadFile($file); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ($meta && ref $meta eq 'HASH' && defined $meta->{name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$meta and ref $meta eq "HASH" and defined $meta->{"name"}
$meta and ref $meta eq "HASH"
MC/DC0%0/3
$meta and ref $meta eq "HASH" and defined $meta->{"name"}
$meta
ref $meta eq "HASH"
defined $meta->{"name"}
Truth table0%0/4
A and B and C
A= $metaB= ref $meta eq "HASH"C= defined $meta->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $distname = $meta->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | log_debug "Got distname=$distname from distribution metadata $file"; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $detailinfo->{source} = 'dist meta v1.1'; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $detailinfo->{dist_meta_file} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (defined $meta->{version}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $distver = $meta->{version}; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | log_debug "Got distver=$distver from distribution metadata $file"; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | FROM_DIST_INI: { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | last unless -f "dist.ini"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | log_debug "Found dist.ini"; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $content = File::Slurper::read_text("dist.ini"); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | while ($content =~ /^\s*name\s*=\s*(.+)/mg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $distname = $1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | log_debug "Got distname=$distname from dist.ini"; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $detailinfo->{source} = "dist.ini"; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($content =~ /^version\s*=\s*(.+)/m) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $distver = $1; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | log_debug "Got distver=$distver from dist.ini"; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | FROM_MAKEFILE_PL: { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | last unless -f "Makefile.PL"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | log_debug "Found Makefile.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $content = File::Slurper::read_text("Makefile.PL"); | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | unless ($content =~ /use ExtUtils::MakeMaker/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | log_debug "Makefile.PL doesn't seem to use ExtUtils::MakeMaker, skipped"; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | unless ($content =~ /["']DISTNAME["']\s*=>\s*["'](.+?)["']/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | log_debug "Couldn't extract value of DISTNAME from Makefile.PL, skipped"; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $distname = $1; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | log_debug "Got distname=$distname from Makefile.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $detailinfo->{source} = "Makefile.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($content =~ /["']VERSION["']\s*=>\s*["'](.+?)["']/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $distver = $1; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | log_debug "Got distver=$distver from Makefile.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | FROM_MAKEFILE: { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | last unless -f "Makefile"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | log_debug "Found Makefile"; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $content = File::Slurper::read_text("Makefile"); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | unless ($content =~ /by MakeMaker/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | log_debug "Makefile doesn't seem to be generated from MakeMaker.PL, skipped"; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | unless ($content =~ /^DISTNAME\s*=\s*(.+)/m) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | log_debug "Couldn't extract value of DISTNAME from Makefile, skipped"; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $distname = $1; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | log_debug "Got distname=$distname from Makefile"; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $detailinfo->{source} = "Makefile"; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if ($content =~ /^VERSION\s*=\s*(.+)/m) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $distver = $1; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | log_debug "Got distver=$distver from Makefile"; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | FROM_BUILD_PL: { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | last unless -f "Build.PL"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | log_debug "Found Build.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $content = File::Slurper::read_text("Build.PL"); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | unless ($content =~ /use Module::Build/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | log_debug "Build.PL doesn't seem to use Module::Build, skipped"; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | unless ($content =~ /module_name\s*=>\s*["'](.+?)["']/s) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | log_debug "Couldn't extract value of module_name from Build.PL, skipped"; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $distname = $1; $distname =~ s/::/-/g; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | log_debug "Got distname=$distname from Build.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $detailinfo->{source} = "Build.PL"; | |||||||||||||||||||||||||||||||||||||||||
| 159 | # XXX extract version? | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | # note: Build script does not contain dist name | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | FROM_GIT_CONFIG: { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | last; # currently disabled | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | last unless -f ".git/config"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | log_debug "Found .git/config"; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $content = File::Slurper::read_text(".git/config"); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | while ($content =~ /^\s*url\s*=\s*(.+)/mg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $url = $1; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | log_debug "Found URL '$url' in git config"; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | require CPAN::Dist::FromURL; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $res = CPAN::Dist::FromURL::extract_cpan_dist_from_url($url); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if (defined $distname) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | log_debug "Guessed distname=$distname from .git/config URL '$url'"; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $detailinfo->{source} = "git config"; | |||||||||||||||||||||||||||||||||||||||||
| 178 | # XXX extract version? | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | __DISABLED__FROM_REPO_NAME: { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | last; # currently disabled | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | log_debug "Using CPAN::Dist::FromRepoName to guess from dir name ..."; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | require CPAN::Dist::FromRepoName; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $res = CPAN::Dist::FromRepoName::extract_cpan_dist_from_repo_name($dir_basename); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if (defined $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $distname = $res; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | log_debug "Guessed distname=$distname from repo name '$dir_basename'"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $detailinfo->{source} = "repo name"; | |||||||||||||||||||||||||||||||||||||||||
| 193 | # XXX extract version? | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | FROM_ARCHIVE: { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | require Filename::Type::Perl::Release; | |||||||||||||||||||||||||||||||||||||||||
| 200 | # if there is a single archive in the directory which looks like a | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # perl release, use that. | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my @files = grep { -f } glob "*"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my ($distfile, $dist, $ver); | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | for my $file (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $res = Filename::Type::Perl::Release::check_perl_release_filename(filename=>$file); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | next unless $res; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | last FROM_ARCHIVE if defined $dist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $dist = $res->{distribution}; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $ver = $res->{version}; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $distfile = $file; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | last unless defined $dist; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $distname = $dist; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $distver = $ver; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | log_debug "Guessed distname=$distname from a single perl archive file in the directory ($distfile)"; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $detailinfo->{source} = "archive"; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $detailinfo->{archive_file} = $distfile; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | last GUESS; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | log_debug "Can't guess distribution, giving up"; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } # GUESS | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ($detail) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $detailinfo->{dist} = $distname; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $detailinfo->{dist_version} = $distver; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $detailinfo; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | return unless defined $distname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $extract_version ? "$distname ".(defined $distver ? $distver : "?") : $distname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub this_mod { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
this_mod: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $res = this_dist(@_); | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | return $res unless defined $res; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if (ref $res) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return $res unless $res->{dist} && $res->{dist} =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"dist"} and $res->{"dist"} =~ /\S/
MC/DC0%0/2
$res->{"dist"} and $res->{"dist"} =~ /\S/
$res->{"dist"}
$res->{"dist"} =~ /\S/
Truth table0%0/3
A and B
A= $res->{"dist"}B= $res->{"dist"} =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ($res->{module} = $res->{dist}) =~ s/-/::/g; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | return $res unless $res =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $res =~ s/-/::/g; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 248 | # ABSTRACT: Print Perl {distribution,module,author,...} associated with current directory | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | __END__ | ||||||||||||||||||||||||||||||||||||||||||