examples/yapc-talk-examples/120-bind-path.psgi

filter: Statementstmt 100% 28 / 28 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 39 / 39 CC 2 SCAR 1.8
CC
2
Cov
100%
to_html
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« examples/yapc-talk-examples/110-service-unavailable.psgi ↑ Summary blib/lib/Web/Machine/I18N.pm »
1 #!perl
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Web::Machine;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =pod
9  
10 curl -v http://0:5000/
11  
12 curl -v http://0:5000/edit/100
13  
14 =cut
15  
16 {
17 package YAPC::NA::2012::Example120::Resource;
18 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use Web::Machine::Util qw[ bind_path ];
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶ use parent 'Web::Machine::Resource';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 6 ▶ sub content_types_provided { [{ 'text/html' => 'to_html' }] }
Subroutine content_types_provided: called CC=1 SCAR=0.0
25  
26 2 ▶ sub to_html {
Subroutine to_html: called CC=2 SCAR=6.9
27 2 my $self = shift;
28 2 ▶ if ( my ($action, $id) = bind_path( '/:action/:id', $self->request->path_info ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = bind_path('/:action/:id', $self->request->path_info)) { } 1 1 2
29 1 return "<html><body><h1>action('$action') id('$id')</h1></body></html>";
30 }
31 else {
32 1 return \404;
33 }
34 }
35 }
36  
37 1 Web::Machine->new( resource => 'YAPC::NA::2012::Example120::Resource' )->to_app;
« examples/yapc-talk-examples/110-service-unavailable.psgi ↑ Summary blib/lib/Web/Machine/I18N.pm »