| 1 | package Catalyst::Controller::Atompub::Service; | ||||||||||||
| 2 | |||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 4 | ▶ | use Atompub::MediaType qw(media_type); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 4 | ▶ | use XML::Atom::Service; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 4 | ▶ | use base qw(Catalyst::Controller::Atompub::Base); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 2 | ▶ | sub default :Private { | ||||||||||
|
Subroutine
default: called CC=4 SCAR=14.6
| |||||||||||||
| 12 | 2 | my($self, $c) = @_; | |||||||||||
| 13 | |||||||||||||
| 14 | 2 | my $service = $self->_make_service($c); | |||||||||||
| 15 | 2 | ▶ | $service = $self->modify_service($c, $service) or return $self->error($c); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | |||||||||||||
| 17 | 2 | ▶ | $c->res->content_type(media_type('service')) unless $c->res->content_type; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | |||||||||||||
| 19 | 2 | ▶ | $c->res->body($service->as_xml) unless length $c->res->body; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 4 | ▶ | } | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | |||||||||||||
| 22 | 2 | ▶ | sub modify_service { | ||||||||||
|
Subroutine
modify_service: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 23 | 2 | my($self, $c, $service) = @_; | |||||||||||
| 24 | 2 | return $service; | |||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | 2 | ▶ | sub _make_service { | ||||||||||
|
Subroutine
_make_service: called CC=6 SCAR=17.9
| |||||||||||||
| 28 | 2 | my($self, $c) = @_; | |||||||||||
| 29 | |||||||||||||
| 30 | 2 | my $service = XML::Atom::Service->new; | |||||||||||
| 31 | |||||||||||||
| 32 | 2 | my $suffix = Catalyst::Utils::class2classsuffix(ref $self); | |||||||||||
| 33 | |||||||||||||
| 34 | 2 | ▶ | my @configs = @{ $c->config->{$suffix}{workspace} || [] }; | ||||||||||
|
Condition100%2/2
$c->config->{$suffix}{'workspace'} || []
MC/DC100%1/1
$c->config->{$suffix}{'workspace'} || []
$c->config->{$suffix}{'workspace'}
Truth table100%2/2
A
A= $c->config->{$suffix}{'workspace'}
| |||||||||||||
| 35 | 2 | ▶ | unless (@configs) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | my @collections | ||||||||||||
| 37 | 1 | = grep { $self->info->get($c, $_) } keys %{ $c->components }; | |||||||||||
| 38 | 1 | @configs = ({ | |||||||||||
| 39 | title => Catalyst::Utils::class2appclass($self), | ||||||||||||
| 40 | collection => \@collections, | ||||||||||||
| 41 | }); | ||||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 2 | for my $config (@configs) { | |||||||||||
| 45 | 2 | my $work = XML::Atom::Workspace->new; | |||||||||||
| 46 | 2 | $work->title($config->{title}); | |||||||||||
| 47 | 2 | $work->add_collection($_) for grep { defined $_ } | |||||||||||
| 48 | 2 | map { $self->info->get($c, $_) } | |||||||||||
| 49 | 2 | ▶ | @{ $config->{collection} || [] }; | ||||||||||
|
Condition50%1/2
$config->{'collection'} || []
MC/DC0%0/1
$config->{'collection'} || []
$config->{'collection'}
Truth table50%1/2
A
A= $config->{'collection'}
| |||||||||||||
| 50 | 2 | $service->add_workspace($work); | |||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | 2 | $service; | |||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | 4 | 1; | |||||||||||
| 57 | __END__ | ||||||||||||