blib/lib/Dancer/Plugin/Swagger/Response.pm

filter: Statementstmt 45.4% 15 / 33 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 2 totaltotal 33.9% 18 / 53 CC 6 SCAR 26.4
CC
6
Cov
35%
fill_example
30.0
__ANON__
6.0
gen_from_example
2.0
CRAP 14.0
« blib/lib/Dancer/Plugin/Swagger/Path.pm ↑ Summary lib/Dancer/Plugin/Swagger.pm »
1 package Dancer::Plugin::Swagger::Response;
2 1 our $AUTHORITY = 'cpan:YANICK';
3 1 $Dancer::Plugin::Swagger::Response::VERSION = '0.2.1';
4 1 ▶use Dancer;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 extends 'Dancer::Response';
9  
10 use overload '&{}' => \&gen_from_example,
11 1 ▶ '""' => sub { (shift)->{status} };
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
12  
13 1 has desc => ( is => 'ro' );
14 1 has example => ( is => 'ro' );
15  
16 sub fill_example {
17 0 ▶ my($var,$struct) = @_;
Subroutine fill_example: not called CC=5 SCAR=34.0
Pod undocumented
18  
19 0 ▶ if( ref $struct eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $struct eq "ARRAY") 0 0 0
20 0 return [ map { fill_example( $var, $_ ) } @$struct ]
21 }
22  
23 0 ▶ if( ref $struct eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $struct eq "HASH") 0 0 0
24 0 return { map { fill_example( $var, $_ ) } %$struct }
25 }
26  
27 0 ▶ if( $struct =~ /^\$\{(\w+):.*\}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($struct =~ /^\$\{(\w+):.*\}$/) 0 0 0
28 0 ▶ die "missing variable '$1'" unless exists $var->{$1};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $var->{$1} 0 0 0
29 0 return $var->{$1};
30 }
31  
32 0 return $struct;
33 }
34  
35 sub gen_from_example {
36 0 ▶ my $self = shift;
Subroutine gen_from_example: not called CC=1 SCAR=6.9
Pod undocumented
37 sub {
38 0 ▶ my %var = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
39  
40 0 my $content = fill_example( \%var, $self->example );
41  
42 0 ▶ status( $self->status // 200 );
Condition0%0/2
$self->status // 200
l!l
00
MC/DC0%0/1
$self->status // 200
$self->status
Truth table0%0/2
A
A= $self->status
Aresult
11
00
43 0 $content;
44 }
45 0 }
46  
47 1 1;
48  
49 __END__
50  
51 =pod
52  
53 =encoding UTF-8
54  
55 =head1 NAME
56  
57 Dancer::Plugin::Swagger::Response
58  
59 =head1 VERSION
60  
61 version 0.2.1
62  
63 =head1 AUTHOR
64  
65 Yanick Champoux <yanick@cpan.org>
66  
67 =head1 COPYRIGHT AND LICENSE
68  
69 This software is copyright (c) 2021, 2016, 2015 by Yanick Champoux.
70  
71 This is free software; you can redistribute it and/or modify it under
72 the same terms as the Perl 5 programming language system itself.
73  
74 =cut
« blib/lib/Dancer/Plugin/Swagger/Path.pm ↑ Summary lib/Dancer/Plugin/Swagger.pm »