Atompub/Service.pm

filter: Statementstmt 100% 45 / 45 Branchbran 62.5% 5 / 8 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 92.7% 64 / 69 CC 9 SCAR 12.7
CC
9
Cov
93%
_make_service
6.0
default
4.3
BEGIN
1.0
CRAP 3.5
« Atompub/Base.pm ↑ Summary Atompub.pm »
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
BranchTrueFalseTotal
$service = $self->modify_service($c, $service) or return $self->error($c) 2 0 2
16  
17 2 ▶ $c->res->content_type(media_type('service')) unless $c->res->content_type;
Branch: 1 branch
BranchTrueFalseTotal
unless $c->res->content_type 2 0 2
18  
19 2 ▶ $c->res->body($service->as_xml) unless length $c->res->body;
Branch: 1 branch
BranchTrueFalseTotal
unless length $c->res->body 2 0 2
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'} || []
l!l
11
MC/DC100%1/1
$c->config->{$suffix}{'workspace'} || []
$c->config->{$suffix}{'workspace'}
Truth table100%2/2
A
A= $c->config->{$suffix}{'workspace'}
Aresult
11
00
35 2 ▶ unless (@configs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@configs) 1 1 2
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'} || []
l!l
20
MC/DC0%0/1
$config->{'collection'} || []
$config->{'collection'}
Truth table50%1/2
A
A= $config->{'collection'}
Aresult
11
00
50 2 $service->add_workspace($work);
51 }
52  
53 2 $service;
54 }
55  
56 4 1;
57 __END__
« Atompub/Base.pm ↑ Summary Atompub.pm »