| 1 | package Docker::Registry::RequestBuilder; | ||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Docker::Registry::Request; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Docker::Registry::Types qw(DockerRegistryURI); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 5 | has url => (is => 'ro', coerce => 1, isa => DockerRegistryURI, required => 1); | |||||||||||||||||||||||||||||||
| 8 | 5 | has api_base => (is => 'ro', default => 'v2'); | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | sub build_request { | ||||||||||||||||||||||||||||||
|
Subroutine
build_request: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 11 | 15 | my ($self, $call) = @_; | |||||||||||||||||||||||||||||||
| 12 | 15 | my $request; | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 15 | my $url_params = $self->_build_url_params($call); | |||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 15 | ▶ | if (ref($call) eq 'Docker::Registry::Call::Repositories') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 17 | 7 | $request = Docker::Registry::Request->new( | |||||||||||||||||||||||||||||||
| 18 | method => 'GET', | ||||||||||||||||||||||||||||||||
| 19 | url => (join '/', $self->url, $self->api_base, "_catalog$url_params"), | ||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | } elsif (ref($call) eq 'Docker::Registry::Call::RepositoryTags') { | ||||||||||||||||||||||||||||||||
| 23 | 8 | $request = Docker::Registry::Request->new( | |||||||||||||||||||||||||||||||
| 24 | method => 'GET', | ||||||||||||||||||||||||||||||||
| 25 | url => (join '/', $self->url, $self->api_base, $call->repository, "tags/list$url_params"), | ||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||
| 27 | } else { | ||||||||||||||||||||||||||||||||
| 28 | 0 | Docker::Exception->throw( | |||||||||||||||||||||||||||||||
| 29 | message => sprintf("Unknown call class: %s", ref($call)), | ||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 15 | return $request; | |||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 15 | ▶ | sub _build_url_params { | ||||||||||||||||||||||||||||||
|
Subroutine
_build_url_params: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||||||
| 37 | 15 | my ($self, $call) = @_; | |||||||||||||||||||||||||||||||
| 38 | 15 | my $url_params = URI->new(); | |||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 15 | ▶ | if ($call->n or $call->last) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$call->n or $call->last
MC/DC100%2/2
$call->n or $call->last
$call->n
$call->last
Truth table100%3/3
A or B
A= $call->nB= $call->last
| |||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | if ($call->n and !$call->last) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$call->n and not $call->last
MC/DC50%1/2
$call->n and not $call->last
$call->n
not $call->last
Truth table66%2/3
A and not(B)
A= $call->nB= not $call->last
| |||||||||||||||||||||||||||||||||
| 42 | 1 | $url_params->query_form(n => $call->n); | |||||||||||||||||||||||||||||||
| 43 | ▶ | } elsif (!$call->n and $call->last) { | |||||||||||||||||||||||||||||||
|
Condition33%1/3
not $call->n and $call->last
MC/DC0%0/2
not $call->n and $call->last
not $call->n
$call->last
Truth table33%1/3
not(A) and B
A= not $call->nB= $call->last
| |||||||||||||||||||||||||||||||||
| 44 | 1 | $url_params->query_form(last => $call->last); | |||||||||||||||||||||||||||||||
| 45 | } else { | ||||||||||||||||||||||||||||||||
| 46 | 0 | $url_params->query_form(last => $call->last, n => $call->n); | |||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 15 | return $url_params->as_string; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 5 | 1; | |||||||||||||||||||||||||||||||