Dancer.pm

filter: Statementstmt 55.3% 31 / 56 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 41.6% 5 / 12 Podpod 100% 1 / 1 totaltotal 46.4% 39 / 84 CC 9 SCAR 20.0
CC
9
Cov
48%
__ANON__
17.5
debug
12.0
import
7.1
CRAP 7.4
↑ Summary Object.pm »
1 package Dancer::OO::Dancer;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Dancer ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.01';
7  
8 2 our @route_handler = qw( get post any patch del options put );
9  
10 0 ▶sub debug {
Subroutine debug: not called CC=3 SCAR=24.8
Pod documented
11 0 ▶ Dancer::debug( join( ' ', map { ref $_ ? Dump($_) : $_ } map { $_ ? $_ : '_' } @_ ) );
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 0 0
$_ ? : 0 0 0
12 }
13  
14 3 ▶sub import {
Subroutine import: called CC=4 SCAR=19.6
15 3 my ($self) = @_;
16 3 my $class = caller;
17 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # redefine router handlers
20 3 foreach my $handler (@route_handler) {
21 21 ▶ *{"$class\::$handler"} = sub {
Subroutine __ANON__: not called CC=1 SCAR=3.5
22 0 push @{ ${"$class\::_handler"} }, [ $handler, @_ ];
23 21 };
24 }
25  
26 # dancer improvements
27 3 ▶ *{"$class\::template"} = sub {
Subroutine __ANON__: not called CC=4 SCAR=28.6
28 0 my ( $self, $template, $args ) = @_;
29 0 ▶ $args = {} unless $args;
Branch: 1 branch
BranchTrueFalseTotal
unless $args 0 0 0
30 0 ▶ $args->{uri} = sub { join( '', ${"$self\::_prefix"}, $_[0] ) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 0 my $k = join( '/', ${"$self\::_prefix"}, 'pager' );
32 0 ▶ $args->{c} ||= Dancer::session($k) || {};
Condition0%0/5
$args->{"c"} ||= Dancer::session($k) || {}
l!l&&r!l&&!r
000
Dancer::session($k) || {}
l!l
00
MC/DC0%0/2
$args->{"c"} ||= Dancer::session($k) || {}
$args->{"c"} Dancer::session($k)
Truth table0%0/3
A ||= B
A= $args->{"c"}B= Dancer::session($k)
ABresult
1X1
011
000
33 0 return Dancer::template( join( '/', ${"$self\::_prefix"}, $template ), $args );
34 3 };
35  
36 3 ▶ *{"$class\::wrap"} = sub (&) {
Subroutine __ANON__: not called CC=1 SCAR=4.4
37 0 my ($handler) = @_;
38 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 my ($self) = @_;
40 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 my $params = Dancer::params;
42 0 my $context = Dancer::session;
43 0 my $ret = $handler->( $self, $context, $params );
44 0 Dancer::session( $context );
45 0 return $ret;
46 }
47 0 }
48 0 };
49  
50 3 *{"$class\::debug"} = \&debug;
51  
52 # suck in all Dancer methods
53 3 for my $method (@Dancer::EXPORT) {
54 201 ▶ *{"$class\::$method"} = *{"Dancer\::$method"} if not defined &{"$class\::$method"};
Branch: 1 branch
BranchTrueFalseTotal
unless defined &{"${class}::$method";} 173 28 201
55 }
56 }
57  
58 =head1 NAME
59  
60 Dancer::OO::Dancer - Allows to set params variables in scope of route handler
61  
62 =head1 VERSION
63  
64 Version 0.01
65  
66 =cut
67  
68 =head1 SYNOPSIS
69  
70 use Dancer::OO::Dancer;
71  
72 =head1 EXPORT
73  
74 All Dancer methods
75  
76 =head1 SUBROUTINES/METHODS
77  
78 =head2 debug
79  
80 A replacement for default Dancer debug with automatic objects dumping with YAML::Dump method.
81  
82 =cut
83  
84 =head1 AUTHOR
85  
86 Roman Galeev, C<< <jamhedd at gmail.com> >>
87  
88 =head1 BUGS
89  
90 Please report any bugs or feature requests to C<bug-dancer-plugin-scoped at rt.cpan.org>, or through
91 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-OO-Dancer>. I will be notified, and then you'll
92 automatically be notified of progress on your bug as I make changes.
93  
94 =head1 SUPPORT
95  
96 You can find documentation for this module with the perldoc command.
97  
98 perldoc Dancer::OO::Dancer
99  
100 You can also look for information at:
101  
102 =over 4
103  
104 =item * RT: CPAN's request tracker
105  
106 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-OO-Dancer>
107  
108 =item * AnnoCPAN: Annotated CPAN documentation
109  
110 L<http://annocpan.org/dist/Dancer-OO-Dancer>
111  
112 =item * CPAN Ratings
113  
114 L<http://cpanratings.perl.org/d/Dancer-OO-Dancer>
115  
116 =item * Search CPAN
117  
118 L<http://search.cpan.org/dist/Dancer-OO-Dancer/>
119  
120 =back
121  
122 =head1 ACKNOWLEDGEMENTS
123  
124 =head1 LICENSE AND COPYRIGHT
125  
126 Copyright 2012 Roman Galeev.
127  
128 This program is free software; you can redistribute it and/or modify it
129 under the terms of either: the GNU General Public License as published
130 by the Free Software Foundation; or the Artistic License.
131  
132 See http://dev.perl.org/licenses/ for more information.
133  
134 =cut
135  
136 2 1; # End of Dancer::OO::Dancer
↑ Summary Object.pm »