blib/lib/Yukki/Web/Response.pm

filter: Statementstmt 65.3% 34 / 52 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 64.7% 11 / 17 Podpod 100% 6 / 6 totaltotal 57.3% 51 / 89 CC 7 SCAR 20.5
CC
7
Cov
55%
navigation_menu
20.0
add_navigation_items
20.0
navigation_menu_names
2.0
CRAP 7.8
« blib/lib/Yukki/Web/Router/Route/Match.pm ↑ Summary blib/lib/Yukki/TemplateUtil.pm »
1 package Yukki::Web::Response;
2 8 $Yukki::Web::Response::VERSION = '0.991_007'; # TRIAL
3 8 $Yukki::Web::Response::VERSION = '0.991007';
4 8 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶use Type::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Types::Standard qw( Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use Yukki::Types qw( BreadcrumbLinks NavigationMenuMap );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 ▶use Plack::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # ABSTRACT: the response to the client
17  
18  
19 8 has response => (
20 is => 'ro',
21 isa => class_type('Plack::Response'),
22 required => 1,
23 lazy => 1,
24 builder => '_build_response',
25 handles => [ qw(
26 status headers body header content_type content_length content_encoding
27 redirect location cookies finalize
28 ) ],
29 );
30  
31 1 ▶sub _build_response {
Subroutine _build_response: called CC=1 SCAR=0.0
32 1 my $self = shift;
33 1 return Plack::Response->new(200, [ 'Content-type' => 'text/html; charset=utf-8' ]);
34 }
35  
36  
37 8 has page_title => (
38 is => 'rw',
39 isa => Str,
40 predicate => 'has_page_title',
41 );
42  
43  
44 has navigation => (
45 is => 'rw',
46 isa => NavigationMenuMap,
47 required => 1,
48 1 ▶ default => sub { +{} },
Subroutine __ANON__: called CC=1 SCAR=0.0
49 8 );
50  
51 0 ▶sub navigation_menu_names {
Subroutine navigation_menu_names: not called CC=1 SCAR=6.9
Pod documented
52 0 my $self = shift;
53 0 keys $self->navigation->%*;
54 }
55  
56  
57 has breadcrumb => (
58 is => 'rw',
59 isa => BreadcrumbLinks,
60 required => 1,
61 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
62 8 );
63  
64 0 ▶sub breadcrumb_links {
Subroutine breadcrumb_links: not called CC=1 SCAR=6.9
Pod documented
65 0 my $self = shift;
66 0 $self->breadcrumb->@*;
67 }
68  
69 0 ▶sub has_breadcrumb {
Subroutine has_breadcrumb: not called CC=1 SCAR=6.9
Pod documented
70 0 my $self = shift;
71 0 scalar $self->breadcrumb->@*;
72 }
73  
74  
75 0 ▶sub navigation_menu {
Subroutine navigation_menu: not called CC=4 SCAR=30.0
Pod documented
76 0 my ($self, $name) = @_;
77 0 ▶ return sort { ($a->{sort}//50) <=> ($b->{sort}//50) }
Condition0%0/4
$Yukki::Web::Response::a->{"sort"} // 50
l!l
00
$Yukki::Web::Response::b->{"sort"} // 50
l!l
00
MC/DC0%0/1
$Yukki::Web::Response::a->{"sort"} // 50
$Yukki::Web::Response::a->{"sort"}
MC/DC0%0/1
$Yukki::Web::Response::b->{"sort"} // 50
$Yukki::Web::Response::b->{"sort"}
Truth table0%0/2
A
A= $Yukki::Web::Response::a->{"sort"}
Aresult
11
00
Truth table0%0/2
A
A= $Yukki::Web::Response::b->{"sort"}
Aresult
11
00
78 0 ▶ @{ $self->navigation->{$name} // [] };
Condition0%0/2
$self->navigation->{$name} // []
l!l
00
MC/DC0%0/1
$self->navigation->{$name} // []
$self->navigation->{$name}
Truth table0%0/2
A
A= $self->navigation->{$name}
Aresult
11
00
79 }
80  
81  
82 0 ▶sub add_navigation_item { shift->add_navigation_items(@_) }
Subroutine add_navigation_item: not called CC=1 SCAR=6.9
Pod documented
83  
84 0 ▶sub add_navigation_items {
Subroutine add_navigation_items: not called CC=4 SCAR=30.0
Pod documented
85 0 my $self = shift;
86 0 my $name_or_names = shift;
87  
88 0 ▶ my @names = ref $name_or_names ? @$name_or_names : ($name_or_names);
Branch: 1 branch
BranchTrueFalseTotal
ref $name_or_names ? : 0 0 0
89  
90 0 for my $name (@names) {
91 0 ▶ $self->navigation->{$name} //= [];
Condition0%0/2
$self->navigation->{$name} //= []
l!l
00
MC/DC0%0/1
$self->navigation->{$name} //= []
$self->navigation->{$name}
Truth table0%0/2
A
A= $self->navigation->{$name}
Aresult
11
00
92 0 push @{ $self->navigation->{$name} }, @_;
93 }
94 }
95  
96  
97 8 1;
98  
99 __END__
« blib/lib/Yukki/Web/Router/Route/Match.pm ↑ Summary blib/lib/Yukki/TemplateUtil.pm »