| 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
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)/
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
my $mobile_layout = plugin_setting()->{"mobile_layout"} and is_mobile_device()
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()
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
plugin_setting()->{"mobile_layout"} and is_mobile_device()
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()
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||