blib/lib/Yukki/Types.pm

filter: Statementstmt 75.3% 49 / 65 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 45.0% 9 / 20 Podpod n/a totaltotal 61.7% 58 / 94 CC 4 SCAR 11.0
CC
4
Cov
68%
__ANON__
12.0
__ANON__
6.0
__ANON__
2.0
CRAP 3.0
« blib/lib/Yukki/Web/Response.pm ↑ Summary blib/lib/Yukki/Model.pm »
1 package Yukki::Types;
2 {
3 4 $Yukki::Types::VERSION = '0.140290';
4 }
5 4 ▶use 5.12.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use MooseX::Types -declare => [ qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
9 LoginName AccessLevel
10 NavigationLinks NavigationMenuMap
11 BaseURL BaseURLEnum BreadcrumbLinks RepositoryMap
12 PluginConfig PluginList
13 4 ) ];
14  
15 4 ▶use MooseX::Types::Moose qw( Str Int ArrayRef Maybe HashRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use MooseX::Types::Structured qw( Dict );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use MooseX::Types::URI qw( Uri );
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 4 ▶use Email::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use List::Util qw( first );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use List::MoreUtils qw( all );
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # ABSTRACT: standard types for use in Yukki
24  
25  
26 subtype LoginName,
27 as Str,
28 0 ▶ where { /^[a-z0-9]+$/ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 ▶ message { "login name $_ must only contain letters and numbers" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
30  
31  
32 4 enum AccessLevel, [qw( read write none )];
33  
34  
35 4 subtype NavigationLinks,
36 as ArrayRef[
37 Dict[
38 label => Str,
39 href => Str|Uri,
40 sort => Maybe[Int],
41 ],
42 ];
43  
44  
45 4 subtype NavigationMenuMap,
46 as HashRef[ NavigationLinks ];
47  
48  
49 4 enum BaseURLEnum, [qw( SCRIPT_NAME REWRITE )];
50  
51 4 subtype BaseURL, as BaseURLEnum|Uri;
52  
53  
54 4 subtype BreadcrumbLinks,
55 as ArrayRef[
56 Dict[
57 label => Str,
58 href => Str,
59 ],
60 ];
61  
62  
63 4 subtype RepositoryMap,
64 as HashRef['Yukki::Settings::Repository'];
65  
66 coerce RepositoryMap,
67 from HashRef,
68 0 ▶ via {
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 0 my $source = $_;
70 +{
71 0 map { $_ => Yukki::Settings::Repository->new($source->{$_}) }
72 keys %$source
73 }
74 4 };
75  
76  
77 subtype PluginConfig,
78 as ArrayRef[HashRef],
79 0 ▶ where { all { defined $_->{module} } @$_ };
Subroutine __ANON__: not called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=2.6
80  
81  
82 4 class_type 'Yukki::Web::Plugin';
83 subtype PluginList,
84 as ArrayRef['Yukki::Web::Plugin'],
85 0 ▶ message {
Subroutine __ANON__: not called CC=3 SCAR=24.8
86 0 ▶ return 'It is not an array of objects.' unless ref $_ eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ eq "ARRAY" 0 0 0
87 0 ▶ my $bad = first { not blessed $_ or not $_->isa('Yukki::Web::Plugin') }
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
builtin::blessed($_) && $_->isa('Yukki::Web::Plugin')
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_) && $_->isa('Yukki::Web::Plugin')
builtin::blessed($_) $_->isa('Yukki::Web::Plugin')
Truth table0%0/3
A && B
A= builtin::blessed($_)B= $_->isa('Yukki::Web::Plugin')
ABresult
0X0
100
111
88 0 @$_;
89 0 ▶ $bad = blessed $bad if blessed $bad;
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($bad) 0 0 0
90 0 return "It contains $bad, which is not a Yukki::Web::Plugin.";
91 4 };
92  
93  
94 4 class_type 'Email::Address';
95 coerce 'Email::Address',
96 from Str,
97 0 ▶ via { (Email::Address->parse($_))[0] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
98  
99  
100 4 class_type 'Yukki::Settings';
101 coerce 'Yukki::Settings',
102 from HashRef,
103 0 ▶ via { Yukki::Settings->new($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
104  
105  
106 4 class_type 'Yukki::Web::Settings';
107 coerce 'Yukki::Web::Settings',
108 from HashRef,
109 0 ▶ via { Yukki::Web::Settings->new($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
110  
111  
112 4 class_type 'Yukki::Settings::Anonymous';
113 coerce 'Yukki::Settings::Anonymous',
114 from HashRef,
115 0 ▶ via { Yukki::Settings::Anonymous->new($_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
116  
117 4 1;
118  
119 __END__
« blib/lib/Yukki/Web/Response.pm ↑ Summary blib/lib/Yukki/Model.pm »