« blib/lib/Perl/Dist/Inno/System.pm
↑ Summary
blib/lib/auto/share/dist/Perl-Dist/default/perl-5.10.0/lib/ExtUtils/Command.pm »
| 1 | package Perl::Dist::Asset; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Convenience base class for Perl::Dist assets | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use File::Spec::Unix (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use File::ShareDir (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use URI::file (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Params::Util qw{ _STRING _CODELIKE }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use vars qw{$VERSION}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 3 | $VERSION = '1.16'; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use Object::Tiny qw{ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | parent | ||||||||||||||||||||||||||||
| 22 | file | ||||||||||||||||||||||||||||
| 23 | url | ||||||||||||||||||||||||||||
| 24 | share | ||||||||||||||||||||||||||||
| 25 | dist | ||||||||||||||||||||||||||||
| 26 | 3 | }; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | ##################################################################### | ||||||||||||||||||||||||||||
| 33 | # Constructor | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=31.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 3 | my $self = shift->SUPER::new(@_); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 3 | ▶ | unless ( $self->url ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | if ( $self->share ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 40 | # Map share to url vis File::ShareDir | ||||||||||||||||||||||||||||
| 41 | 1 | my ($dist, $name) = split /\s+/, $self->share; | |||||||||||||||||||||||||||
| 42 | 1 | $self->trace("Finding $name in $dist... "); | |||||||||||||||||||||||||||
| 43 | 1 | my $file = File::Spec->rel2abs( | |||||||||||||||||||||||||||
| 44 | File::ShareDir::dist_file( $dist, $name ) | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | 1 | ▶ | unless ( -f $file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | croak("Failed to find $file"); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 1 | $self->{url} = URI::file->new($file)->as_string; | |||||||||||||||||||||||||||
| 50 | 1 | $self->trace(" found\n"); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | } elsif ( $self->dist ) { | ||||||||||||||||||||||||||||
| 53 | # Map CPAN dist path to url | ||||||||||||||||||||||||||||
| 54 | 0 | my $dist = $self->dist; | |||||||||||||||||||||||||||
| 55 | 0 | $self->trace("Using distribution path $dist\n"); | |||||||||||||||||||||||||||
| 56 | 0 | my $one = substr( $self->dist, 0, 1 ); | |||||||||||||||||||||||||||
| 57 | 0 | my $two = substr( $self->dist, 1, 1 ); | |||||||||||||||||||||||||||
| 58 | 0 | my $path = File::Spec::Unix->catfile( | |||||||||||||||||||||||||||
| 59 | 'authors', 'id', $one, "$one$two", $dist, | ||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||
| 61 | 0 | $self->{url} = URI->new_abs( $path, $self->cpan )->as_string; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | ▶ | } elsif ( $self->can('name') and $self->name ) { | |||||||||||||||||||||||||||
|
Condition0%0/3
$self->can("name") and $self->name
MC/DC0%0/2
$self->can("name") and $self->name
$self->can("name")
$self->name
Truth table0%0/3
A and B
A= $self->can("name")B= $self->name
| |||||||||||||||||||||||||||||
| 64 | # Map name to URL via the default package path | ||||||||||||||||||||||||||||
| 65 | 0 | $self->{url} = $self->parent->binary_url($self->name); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # Check params | ||||||||||||||||||||||||||||
| 70 | 3 | ▶ | unless ( _STRING($self->url) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | croak("Missing or invalid url param"); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Create the filename from the url | ||||||||||||||||||||||||||||
| 75 | 3 | $self->{file} = $self->url; | |||||||||||||||||||||||||||
| 76 | 3 | $self->{file} =~ s|.+/||; | |||||||||||||||||||||||||||
| 77 | 3 | ▶ | unless ( $self->file and length $self->file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->file and length $self->file
MC/DC0%0/2
$self->file and length $self->file
$self->file
length $self->file
Truth table33%1/3
A and B
A= $self->fileB= length $self->file
| |||||||||||||||||||||||||||||
| 78 | 0 | croak("Missing or invalid file"); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 3 | return $self; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub cpan { | ||||||||||||||||||||||||||
|
Subroutine
cpan: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | 0 | $_[0]->parent->cpan; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | ##################################################################### | ||||||||||||||||||||||||||||
| 93 | # Support Methods | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | ▶ | sub trace { | ||||||||||||||||||||||||||
|
Subroutine
trace: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | 2 | ▶ | if ( _CODELIKE($self->{trace}) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $self->{trace}->(@_); | |||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||
| 100 | 2 | print $_[0]; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 3 | 1; | |||||||||||||||||||||||||||