| 1 | 2 | ▶ | use 5.006; # our | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Dist::Zilla::ExternalPrereq; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | our $VERSION = 'v0.3.0'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # FILENAME: ExternalPrereq.pm | ||||||||||||||||||||||||||||
| 12 | # CREATED: 30/10/11 10:07:40 by Kent Fredric (kentnl) <kentfredric@gmail.com> | ||||||||||||||||||||||||||||
| 13 | # ABSTRACT: A representation of an externalised prerequisite | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use Moose qw( with has ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 2 | with 'Dist::Zilla::Role::Plugin', 'Dist::Zilla::Role::xPANResolver'; | |||||||||||||||||||||||||||
| 30 | 2 | ▶ | use Module::Runtime qw( require_module ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use Try::Tiny qw( try catch ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use Path::ScanINC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | has 'name' => ( isa => 'Str', required => 1, is => 'rw' ); | |||||||||||||||||||||||||||
| 35 | 2 | has 'baseurl' => ( isa => 'Str', required => 1, is => 'rw' ); | |||||||||||||||||||||||||||
| 36 | 2 | has '_uri' => ( | |||||||||||||||||||||||||||
| 37 | isa => 'Str', | ||||||||||||||||||||||||||||
| 38 | required => 0, | ||||||||||||||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||||||||||||
| 40 | predicate => '_has_uri', | ||||||||||||||||||||||||||||
| 41 | init_arg => 'uri', | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | 2 | has 'uri' => ( | |||||||||||||||||||||||||||
| 44 | isa => 'Str', | ||||||||||||||||||||||||||||
| 45 | required => 1, | ||||||||||||||||||||||||||||
| 46 | is => 'rw', | ||||||||||||||||||||||||||||
| 47 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 48 | init_arg => undef, | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 2 | has 'minversion' => ( | |||||||||||||||||||||||||||
| 52 | isa => 'Str', | ||||||||||||||||||||||||||||
| 53 | required => undef, | ||||||||||||||||||||||||||||
| 54 | is => 'rw', | ||||||||||||||||||||||||||||
| 55 | predicate => 'has_minversion', | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub is_satisfied { | ||||||||||||||||||||||||||
|
Subroutine
is_satisfied: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||
| 71 | # Fence the Perl logic first to see if require is going to load a file | ||||||||||||||||||||||||||||
| 72 | 0 | my (@pmname) = split qr/::|'/xs, $self->name; | |||||||||||||||||||||||||||
| 73 | 0 | $pmname[-1] .= '.pm'; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return unless $INC{ join q{/}, @pmname } or defined Path::ScanINC->new()->first_file(@pmname); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$INC{join "/", @pmname} or defined "Path::ScanINC"->new->first_file(@pmname)
MC/DC0%0/2
$INC{join "/", @pmname} or defined "Path::ScanINC"->new->first_file(@pmname)
$INC{join "/", @pmname}
defined "Path::ScanINC"->new->first_file(@pmname)
Truth table0%0/3
A or B
A= $INC{join "/", @pmname}B= defined "Path::ScanINC"->new->first_file(@pmname)
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # If Perl would load the file, do so, and propagate failures. | ||||||||||||||||||||||||||||
| 78 | 0 | require_module( $self->name ); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return 1 unless $self->has_minversion; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | my $satisfied = 1; | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 83 | 0 | $self->name->VERSION( $self->minversion ); | |||||||||||||||||||||||||||
| 84 | 0 | 1; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 87 | ## no critic (RegularExpressions) | ||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( $_ !~ /^.*version.*required.*this is only version.*$/m ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | ## no critic ( RequireCarping ) | ||||||||||||||||||||||||||||
| 90 | 0 | die $_; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 0 | $satisfied = undef; | |||||||||||||||||||||||||||
| 93 | 0 | }; | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | return 1 if $satisfied; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | return; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub _build_uri { | ||||||||||||||||||||||||||
|
Subroutine
_build_uri: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 99 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ( $self->_has_uri ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | require URI; | |||||||||||||||||||||||||||
| 102 | 0 | my $baseuri = URI->new( $self->baseurl ); | |||||||||||||||||||||||||||
| 103 | 0 | return URI->new( $self->_uri )->abs($baseuri)->as_string; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | 0 | return $self->resolve_module( $self->baseurl, $self->name ); | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 2 | 1; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||