lib/Dancer/Plugin/MobileDevice.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond 100% 8 / 8 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 56 / 56 CC 6 SCAR 6.9
CC
6
Cov
100%
__ANON__
3.0
__ANON__
3.0
__ANON__
2.0
CRAP 2.0
↑ Summary
1 package Dancer::Plugin::MobileDevice;
2 4 our $AUTHORITY = 'cpan:YANICK';
3 #ABSTRACT: make a Dancer app mobile-aware
4 4 $Dancer::Plugin::MobileDevice::VERSION = '0.06';
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use Dancer ':syntax';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Dancer::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 25 ▶register 'is_mobile_device' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
12 4 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 25 ▶ return request->user_agent
Condition100%2/2
request()->user_agent =~ /(?:iP(?:ad|od|hone)|Android|BlackBerry|Mobile|Palm)/ || 0
l!l
1411
MC/DC100%1/1
request()->user_agent =~ /(?:iP(?:ad|od|hone)|Android|BlackBerry|Mobile|Palm)/ || 0
request()->user_agent =~ /(?:iP(?:ad|od|hone)|Android|BlackBerry|Mobile|Palm)/
Truth table100%2/2
A
A= request()->user_agent =~ /(?:iP(?:ad|od|hone)|Android|BlackBerry|Mobile|Palm)/
Aresult
11
00
14 =~ /(?:iP(?:ad|od|hone)|Android|BlackBerry|Mobile|Palm)/ || 0 ;
15 4 };
16  
17 17 ▶hook before => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
18 # If we don't have a mobile layout declared, do nothing.
19 my $mobile_layout = plugin_setting->{mobile_layout}
20 17 ▶ and is_mobile_device()
Branch: 1 branch
BranchTrueFalseTotal
my $mobile_layout = plugin_setting()->{"mobile_layout"} and is_mobile_device() or return 2 15 17
Condition100%3/3
my $mobile_layout = plugin_setting()->{"mobile_layout"} and is_mobile_device()
!ll&&!rl&&r
1322
MC/DC100%2/2
my $mobile_layout = plugin_setting()->{"mobile_layout"} and is_mobile_device()
my $mobile_layout = plugin_setting()->{"mobile_layout"} is_mobile_device()
Truth table100%3/3
A and B
A= my $mobile_layout = plugin_setting()->{"mobile_layout"}B= is_mobile_device()
ABresult
0X0
100
111
21 or return;
22  
23 2 var orig_layout => setting('layout');
24 2 setting layout => $mobile_layout;
25 4 };
26  
27 17 ▶hook after => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
28 setting layout => delete vars->{orig_layout}
29 if plugin_setting->{mobile_layout}
30 17 ▶ and is_mobile_device();
Branch: 1 branch
BranchTrueFalseTotal
if plugin_setting()->{"mobile_layout"} and is_mobile_device() 2 15 17
Condition100%3/3
plugin_setting()->{"mobile_layout"} and is_mobile_device()
!ll&&!rl&&r
1322
MC/DC100%2/2
plugin_setting()->{"mobile_layout"} and is_mobile_device()
plugin_setting()->{"mobile_layout"} is_mobile_device()
Truth table100%3/3
A and B
A= plugin_setting()->{"mobile_layout"}B= is_mobile_device()
ABresult
0X0
100
111
31 4 };
32  
33 9 ▶hook before_template => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
34 9 my $tokens = shift;
35 9 $tokens->{'is_mobile_device'} = is_mobile_device();
36 4 };
37  
38 4 register_plugin;
39  
40 4 1;
41  
42 __END__
↑ Summary