| 1 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Maven::Repositories; | ||||||||||||||||||||||||||||
| 5 | 5 | $Maven::Repositories::VERSION = '1.12'; | |||||||||||||||||||||||||||
| 6 | # ABSTRACT: An ordered collection of repositories from which to resolve artifacts | ||||||||||||||||||||||||||||
| 7 | # PODNAME: Maven::Repositories | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use parent qw(Class::Accessor); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 5 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||
| 11 | 5 | __PACKAGE__->mk_accessors(qw(repositories)); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use Log::Any; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Maven::LocalRepository; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use Maven::RemoteRepository; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | my $logger = Log::Any->get_logger(); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub new { | ||||||||||||||||||||||||||||
| 21 | 9 | ▶ | return bless( {}, shift )->_init(@_); | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | sub add_central { | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my ( $self, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add_central: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 0 | $logger->debug('adding central'); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | return $self->add_repository( 'http://repo.maven.apache.org/maven2', @args ); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub _artifact_not_found { | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ( $self, $coordinate_or_artifact, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_artifact_not_found: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $artifact = | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $coordinate_or_artifact and UNIVERSAL::isa($coordinate_or_artifact, "Maven::Artifact")
MC/DC0%0/2
ref $coordinate_or_artifact and UNIVERSAL::isa($coordinate_or_artifact, "Maven::Artifact")
ref $coordinate_or_artifact
UNIVERSAL::isa($coordinate_or_artifact, "Maven::Artifact")
Truth table0%0/3
A and B
A= ref $coordinate_or_artifactB= UNIVERSAL::isa($coordinate_or_artifact, "Maven::Artifact")
| |||||||||||||||||||||||||||||
| 34 | ref($coordinate_or_artifact) | ||||||||||||||||||||||||||||
| 35 | && UNIVERSAL::isa( $coordinate_or_artifact, 'Maven::Artifact' ) | ||||||||||||||||||||||||||||
| 36 | ? $coordinate_or_artifact | ||||||||||||||||||||||||||||
| 37 | : Maven::Artifact->new( $coordinate_or_artifact, %$options )->get_coordinate(); | ||||||||||||||||||||||||||||
| 38 | 0 | return "artifact $artifact not found"; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub add_local { | ||||||||||||||||||||||||||||
| 42 | 9 | ▶ | my ( $self, $local_repository_path, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add_local: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 9 | $logger->debugf( 'adding local %s', $local_repository_path ); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | push( | ||||||||||||||||||||||||||||
| 46 | 9 | @{ $self->{repositories} }, | |||||||||||||||||||||||||||
| 47 | Maven::LocalRepository->new( $local_repository_path, @args ) | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 9 | return $self; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub add_repository { | ||||||||||||||||||||||||||||
| 54 | 11 | ▶ | my ( $self, $url, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add_repository: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 11 | $logger->debugf( 'adding repo %s', $url ); | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 11 | push( @{ $self->{repositories} }, Maven::RemoteRepository->new( $url, @args ) ); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 11 | return $self; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub _init { | ||||||||||||||||||||||||||||
| 63 | 9 | ▶ | my ( $self, @args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 64 | 9 | $logger->trace('initializing repositories'); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 9 | $self->{repositories} = []; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 9 | return $self; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub get_repository { | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my ( $self, $url ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_repository: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 0 | foreach my $repository ( @{ $self->{repositories} } ) { | |||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( $repository->contains($url) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | return $repository; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 0 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | sub resolve { | ||||||||||||||||||||||||||||
| 82 | 4 | ▶ | my ( $self, $coordinate_or_artifact, @parts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 4 | my $artifact; | |||||||||||||||||||||||||||
| 85 | 4 | foreach my $repository ( @{ $self->{repositories} } ) { | |||||||||||||||||||||||||||
| 86 | 4 | ▶ | last if ( $artifact = $repository->resolve( $coordinate_or_artifact, @parts ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 4 | return $artifact; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | sub resolve_or_die { | ||||||||||||||||||||||||||||
| 93 | 3 | ▶ | my ( $self, $coordinate_or_artifact, %parts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
resolve_or_die: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 3 | my $resolved = $self->resolve( $coordinate_or_artifact, %parts ); | |||||||||||||||||||||||||||
| 95 | 3 | ▶ | croak( $self->_artifact_not_found( $coordinate_or_artifact, \%parts ) ) if ( !$resolved ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 3 | return $resolved; | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 5 | 1; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||||||||||