| 1 | package Cake; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use NEXT; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Encode; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use utf8; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Cake::Controllers; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Cake::Exception; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use Cake::Utils::Accessor; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use Cake::Utils; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Cake::URI; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use base qw/Exporter Cake::Dispatcher Cake::Engine/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use FindBin qw($Bin); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 8 | our $VERSION = '0.006_2'; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 8 | my @controller_export = qw( | |||||||||||||||||||||||||||||||
| 22 | get | ||||||||||||||||||||||||||||||||
| 23 | post | ||||||||||||||||||||||||||||||||
| 24 | any | ||||||||||||||||||||||||||||||||
| 25 | args | ||||||||||||||||||||||||||||||||
| 26 | chained | ||||||||||||||||||||||||||||||||
| 27 | Action | ||||||||||||||||||||||||||||||||
| 28 | route | ||||||||||||||||||||||||||||||||
| 29 | auto | ||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 8 | my @plugin_export = qw( | |||||||||||||||||||||||||||||||
| 33 | loadSettings | ||||||||||||||||||||||||||||||||
| 34 | settings | ||||||||||||||||||||||||||||||||
| 35 | register | ||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 8 | my @extra_export = qw( | |||||||||||||||||||||||||||||||
| 39 | bake | ||||||||||||||||||||||||||||||||
| 40 | plugins | ||||||||||||||||||||||||||||||||
| 41 | context | ||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 8 | our @EXPORT = (@controller_export,@plugin_export,@extra_export); | |||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 8 | __PACKAGE__->Accessor('env','app','engine','action','stash','uri'); | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 8 | my ($DEBUG,$ENGINE,$SELF); | |||||||||||||||||||||||||||||||
| 49 | 8 | my $SETTINGS = {}; | |||||||||||||||||||||||||||||||
| 50 | 8 | my $COUNTER = 0; | |||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub clear_counter {$COUNTER = 0} | ||||||||||||||||||||||||||||||
|
Subroutine
clear_counter: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub counter {$COUNTER} | ||||||||||||||||||||||||||||||
|
Subroutine
counter: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | sub debug {return $DEBUG;} | ||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 54 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 55 | # import on app start | ||||||||||||||||||||||||||||||||
| 56 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 57 | 15 | ▶ | sub import { | ||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=10 SCAR=32.3
| |||||||||||||||||||||||||||||||||
| 58 | 15 | my ($class, @options) = @_; | |||||||||||||||||||||||||||||||
| 59 | 15 | my ($package,$script) = caller; | |||||||||||||||||||||||||||||||
| 60 | 15 | my $engine; | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | ###import these to app by default | ||||||||||||||||||||||||||||||||
| 63 | 15 | strict->import; | |||||||||||||||||||||||||||||||
| 64 | 15 | warnings->import; | |||||||||||||||||||||||||||||||
| 65 | 15 | utf8->import; | |||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 15 | foreach (@options) { | |||||||||||||||||||||||||||||||
| 68 | 4 | ▶ | if (/^Plugin$/){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 69 | 4 | $class->export_to_level(1, $class, @plugin_export); | |||||||||||||||||||||||||||||||
| 70 | 4 | return; | |||||||||||||||||||||||||||||||
| 71 | } elsif (/^Controller$/){ | ||||||||||||||||||||||||||||||||
| 72 | 0 | $class->export_to_level(1, $class, @controller_export); | |||||||||||||||||||||||||||||||
| 73 | 0 | return; | |||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | # Import engine, load only one engine | ||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ( /^:Engine=(\S+)/ && !$ENGINE) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
/^:Engine=(\S+)/ and not $ENGINE
MC/DC0%0/2
/^:Engine=(\S+)/ and not $ENGINE
/^:Engine=(\S+)/
not $ENGINE
Truth table0%0/3
A and not(B)
A= /^:Engine=(\S+)/B= not $ENGINE
| |||||||||||||||||||||||||||||||||
| 78 | 0 | $ENGINE = $1; | |||||||||||||||||||||||||||||||
| 79 | 0 | $engine = Cake::Utils::Require($ENGINE,'Cake::Engine'); | |||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $@ ) { die qq/can't load engine "$ENGINE", "$@"/ } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 0 | unshift(@Cake::ISA,$engine); | |||||||||||||||||||||||||||||||
| 82 | } elsif (/^:Debug=(\S+)/){ | ||||||||||||||||||||||||||||||||
| 83 | 0 | $DEBUG = $1; | |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 11 | ▶ | if (!$SELF){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | 8 | $SELF->{'basename'} = $package; | |||||||||||||||||||||||||||||||
| 89 | 8 | $package .='.pm'; | |||||||||||||||||||||||||||||||
| 90 | 8 | ▶ | ( $SELF->{'dir'} = $INC{$package} || $Bin) =~ s/\.pm//; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$INC{$package} || $Cake::Bin
MC/DC0%0/2
$INC{$package} || $Cake::Bin
$INC{$package}
$Cake::Bin
Truth table33%1/3
A || B
A= $INC{$package}B= $Cake::Bin
| |||||||||||||||||||||||||||||||||
| 91 | 8 | push @INC, $SELF->{'dir'}; | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 11 | $class->export_to_level(1, $class, @EXPORT); | |||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 98 | # Load Settings from outer file / must be a valid json file | ||||||||||||||||||||||||||||||||
| 99 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub loadSettings { | ||||||||||||||||||||||||||||||
|
Subroutine
loadSettings: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 101 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||
| 102 | 0 | my $conf; | |||||||||||||||||||||||||||||||
| 103 | 0 | eval { | |||||||||||||||||||||||||||||||
| 104 | 0 | $conf = Cake::Utils::get_file($file); | |||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | }; if ($@){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | 0 | die "can't open file $file"; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | ##json to perl | ||||||||||||||||||||||||||||||||
| 109 | 0 | return Cake::Utils->serialize($conf)->to_perl; | |||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 113 | # settings : get/set application Settings | ||||||||||||||||||||||||||||||||
| 114 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 115 | 4 | ▶ | sub settings { | ||||||||||||||||||||||||||||||
|
Subroutine
settings: called CC=9 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | if (@_ > 1 || ref $_[0] eq 'HASH'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 1 or ref $_[0] eq "HASH"
MC/DC50%1/2
@_ > 1 or ref $_[0] eq "HASH"
@_ > 1
ref $_[0] eq "HASH"
Truth table66%2/3
A or B
A= @_ > 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | if (!ref $_[0]){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | 0 | my $package = shift; | |||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $SETTINGS->{$package} = @_ > 1 ? {@_} : $_[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | } else { | ||||||||||||||||||||||||||||||||
| 121 | 1 | $SETTINGS = {%{$SETTINGS},%{$_[0]}}; | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | if (my $plugins = delete $SETTINGS->{plugins}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if (ref $plugins eq 'ARRAY'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 125 | 0 | &plugins($plugins); | |||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | } else { | ||||||||||||||||||||||||||||||||
| 130 | 3 | ▶ | my $package = $_[0] || caller; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$_[0] || caller
MC/DC0%0/2
$_[0] || caller
$_[0]
caller
Truth table66%2/3
A || B
A= $_[0]B= caller
| |||||||||||||||||||||||||||||||||
| 131 | 3 | ▶ | $SETTINGS->{$package} ? return $SETTINGS->{$package} : return $SETTINGS; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||
| 133 | 1 | return $SETTINGS; | |||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||||||
|
Subroutine
config: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 137 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ($_[0]){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 0 | return $self->{settings}->{$_[0]}; | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | 0 | return $self->{settings}; | |||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 145 | # load plugins | ||||||||||||||||||||||||||||||||
| 146 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | sub plugins { | ||||||||||||||||||||||||||||||
|
Subroutine
plugins: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 148 | 2 | my @plugins = @{$_[0]}; | |||||||||||||||||||||||||||||||
| 149 | 2 | my @pluginsRequire; | |||||||||||||||||||||||||||||||
| 150 | 2 | ▶ | return if !@plugins; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | 2 | my $withOptions; | |||||||||||||||||||||||||||||||
| 152 | 2 | ▶ | for (my $i= 0; $i < @plugins; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | if (!ref $plugins[$i]){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 154 | 4 | my $module = Cake::Utils::noRequire($plugins[$i],'Cake::Plugins'); | |||||||||||||||||||||||||||||||
| 155 | 4 | push(@pluginsRequire,$plugins[$i]); | |||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | if (ref ( my $next = $plugins[$i+1] )){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 157 | 4 | $withOptions->{$module} = $next; | |||||||||||||||||||||||||||||||
| 158 | 4 | splice(@plugins, $i+1, 1); | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | 2 | map {Cake::Utils::Require($_,'Cake::Plugins')} @pluginsRequire; | |||||||||||||||||||||||||||||||
| 163 | 2 | $SETTINGS = {%{$SETTINGS},%{$withOptions}}; | |||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 167 | # Cake Context | ||||||||||||||||||||||||||||||||
| 168 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub context { | ||||||||||||||||||||||||||||||
|
Subroutine
context: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 170 | 0 | my $caller = shift; | |||||||||||||||||||||||||||||||
| 171 | #$ENV{'REQUEST_URI'} = shift || ''; | ||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $ENV{SCRIPT_NAME} = (caller)[0] || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
(caller)[0] || ''
MC/DC0%0/1
(caller)[0] || ''
(caller)[0]
Truth table0%0/2
A
A= (caller)[0]
| |||||||||||||||||||||||||||||||||
| 173 | 0 | my $c = $caller->bake($_[0],1); | |||||||||||||||||||||||||||||||
| 174 | 0 | $c->finalize(); | |||||||||||||||||||||||||||||||
| 175 | 0 | return $c; | |||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 179 | # bakery: bake the cake | ||||||||||||||||||||||||||||||||
| 180 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | sub bake { | ||||||||||||||||||||||||||||||
|
Subroutine
bake: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 182 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||
| 183 | 3 | my $self = bless({}, __PACKAGE__); | |||||||||||||||||||||||||||||||
| 184 | ##load settings | ||||||||||||||||||||||||||||||||
| 185 | 3 | $self->app(bless($SELF, $class)); | |||||||||||||||||||||||||||||||
| 186 | 3 | $self->{pid} = $$; | |||||||||||||||||||||||||||||||
| 187 | 3 | ▶ | $self->env(bless($_[0] || \%ENV, 'Cake::ENV')); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0] || \%ENV
MC/DC0%0/1
$_[0] || \%ENV
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||
| 188 | 3 | $self->{COUNT} = $COUNTER; | |||||||||||||||||||||||||||||||
| 189 | 3 | $self->{response}->{headers} = ["X-Framework: PerlCake"]; | |||||||||||||||||||||||||||||||
| 190 | 3 | $self->{settings} = $SETTINGS; | |||||||||||||||||||||||||||||||
| 191 | 3 | $self->loadOnce(); | |||||||||||||||||||||||||||||||
| 192 | 3 | ▶ | return $self->_runner() if !$_[1]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 193 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | sub loadOnce { | ||||||||||||||||||||||||||||||
|
Subroutine
loadOnce: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 197 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 198 | 3 | ▶ | return if $COUNTER; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | 3 | $self->loadControllers(); | |||||||||||||||||||||||||||||||
| 200 | 3 | $self->cando(); | |||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 204 | # run app | ||||||||||||||||||||||||||||||||
| 205 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 206 | 3 | ▶ | sub _runner { | ||||||||||||||||||||||||||||||
|
Subroutine
_runner: called CC=5 SCAR=17.3
| |||||||||||||||||||||||||||||||||
| 207 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 208 | 3 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||
| 209 | 3 | eval { | |||||||||||||||||||||||||||||||
| 210 | 3 | $self->init(); | |||||||||||||||||||||||||||||||
| 211 | 3 | ▶ | if ($self->app->{can}->{begin}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 0 | $self->app->begin($self); | |||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | 3 | ++$self->{_count}; | |||||||||||||||||||||||||||||||
| 216 | 3 | ▶ | croak('Infinte Loop Detected') if $self->{_count} > '20'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 217 | 3 | $self->setup(); | |||||||||||||||||||||||||||||||
| 218 | 3 | ▶ | if ($self->app->{can}->{end}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | 0 | $self->app->end($self); | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | 3 | $self->finalize(); | |||||||||||||||||||||||||||||||
| 223 | }; | ||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | 3 | ▶ | if ($@){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 226 | 0 | $self->error($@); | |||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 3 | $COUNTER++; | |||||||||||||||||||||||||||||||
| 230 | 3 | return $self; | |||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||
| 233 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 234 | # Run code on destruction ??! | ||||||||||||||||||||||||||||||||
| 235 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=5 SCAR=22.5
| |||||||||||||||||||||||||||||||||
| 237 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | return if !$self->{pid}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | return if $$ != $self->{pid}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | if ( exists $self->{on_destroy} ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | map { | ||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $_->($self) if ref $_ eq "CODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 243 | 0 | } @{$self->{on_destroy}}; | |||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 0 | $self->{on_destroy} = []; | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 250 | # load controllers | ||||||||||||||||||||||||||||||||
| 251 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | sub loadControllers { | ||||||||||||||||||||||||||||||
|
Subroutine
loadControllers: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 253 | 3 | ▶ | return if $COUNTER; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 254 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 255 | 3 | my $dir = $self->app->{'dir'}.'/Controllers'; | |||||||||||||||||||||||||||||||
| 256 | #warn Dumper $dir; | ||||||||||||||||||||||||||||||||
| 257 | 3 | ▶ | return if !-d $dir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | 6 | ▶ | find(sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||
| 260 | 6 | ▶ | if ($_ =~ m/\.pm$/){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 261 | 3 | my $file = $File::Find::name; | |||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 3 | eval "require '$file'"; | |||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | 3 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 266 | 0 | die("can't load controller $file"); | |||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||
| 269 | 3 | }, $dir); | |||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||
| 272 | 3 | ▶ | sub cando { | ||||||||||||||||||||||||||||||
|
Subroutine
cando: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 273 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 274 | $self->app->{can} = { | ||||||||||||||||||||||||||||||||
| 275 | 3 | ▶ | begin => $self->app->can('begin') ? 1 : undef, | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 276 | end => $self->app->can('end') ? 1 : undef, | ||||||||||||||||||||||||||||||||
| 277 | error => $self->app->can('error') ? 1 : undef, | ||||||||||||||||||||||||||||||||
| 278 | notfound => $self->app->can('notfound') ? 1 : undef | ||||||||||||||||||||||||||||||||
| 279 | }; | ||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 283 | # load app model | ||||||||||||||||||||||||||||||||
| 284 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | sub model { | ||||||||||||||||||||||||||||||
|
Subroutine
model: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 286 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 287 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||
| 288 | 0 | my $module = $self->app->{'dir'}."::Model::".$model; | |||||||||||||||||||||||||||||||
| 289 | 0 | $module =~ s/::/\//g; | |||||||||||||||||||||||||||||||
| 290 | 0 | $module .= '.pm'; | |||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | 0 | require "$module"; | |||||||||||||||||||||||||||||||
| 293 | 0 | $model = $self->app->{'basename'}."::Model::".$model; | |||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 0 | my $return; | |||||||||||||||||||||||||||||||
| 296 | 0 | eval { | |||||||||||||||||||||||||||||||
| 297 | 0 | $return = $model->init($self); | |||||||||||||||||||||||||||||||
| 298 | }; | ||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||
| 300 | ##if the model has init sub return it | ||||||||||||||||||||||||||||||||
| 301 | ##other wise bless and return model class | ||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | return $return || bless({ | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$return || bless({'c', $self}, $model)
MC/DC0%0/1
$return || bless({'c', $self}, $model)
$return
Truth table0%0/2
A
A= $return
| |||||||||||||||||||||||||||||||||
| 303 | c => $self | ||||||||||||||||||||||||||||||||
| 304 | },$model); | ||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 308 | # load Plugins | ||||||||||||||||||||||||||||||||
| 309 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub loadPlugins { | ||||||||||||||||||||||||||||||
|
Subroutine
loadPlugins: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 311 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 312 | 0 | my $dir = shift; | |||||||||||||||||||||||||||||||
| 313 | 0 | foreach my $module (@{$SELF->{plugins}}) { | |||||||||||||||||||||||||||||||
| 314 | 0 | Cake::Utils::Require($module,'Cake::Plugins'); | |||||||||||||||||||||||||||||||
| 315 | ####maybe we should register plugins internally, but let's first test | ||||||||||||||||||||||||||||||||
| 316 | #$self->register($module); | ||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 321 | # register plugins | ||||||||||||||||||||||||||||||||
| 322 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 323 | 4 | ▶ | sub register { | ||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 324 | 4 | my @attr = @_; | |||||||||||||||||||||||||||||||
| 325 | 4 | my $caller = caller(0); | |||||||||||||||||||||||||||||||
| 326 | 4 | unshift @Cake::ISA,$caller; | |||||||||||||||||||||||||||||||
| 327 | 4 | return; | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 331 | # server - get server name if set | ||||||||||||||||||||||||||||||||
| 332 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | sub server { | ||||||||||||||||||||||||||||||
|
Subroutine
server: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 334 | 0 | return shift->env->{'cake.server'}; | |||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 338 | # controllers routing | ||||||||||||||||||||||||||||||||
| 339 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 340 | 5 | ▶ | sub get { Cake::Controllers->dispatch('get',@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | sub post { Cake::Controllers->dispatch('post',@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | sub any { Cake::Controllers->dispatch('any',@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
any: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | sub route { Cake::Controllers->dispatch('route',@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
route: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub auto { Cake::Controllers->auto(@_); } | ||||||||||||||||||||||||||||||
|
Subroutine
auto: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | #maybe to be implemented later | ||||||||||||||||||||||||||||||||
| 347 | #sub after { Cake::Controllers->after('after',@_); } | ||||||||||||||||||||||||||||||||
| 348 | #sub before { Cake::Controllers->before('before',@_); } | ||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||
| 350 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 351 | # Custom Action Class Loader | ||||||||||||||||||||||||||||||||
| 352 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub Action { | ||||||||||||||||||||||||||||||
|
Subroutine
Action: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 354 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||
| 355 | 0 | my $caller = (caller)[0]; | |||||||||||||||||||||||||||||||
| 356 | 0 | $class = Cake::Utils::Require($class,'Cake::Actions'); | |||||||||||||||||||||||||||||||
| 357 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if (@_ == 1){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 359 | 0 | $self = $_[0]; | |||||||||||||||||||||||||||||||
| 360 | } elsif (@_){ | ||||||||||||||||||||||||||||||||
| 361 | 0 | $self = \@_; | |||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | ##bless action class | ||||||||||||||||||||||||||||||||
| 365 | 0 | $class = bless($self,$class); | |||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 367 | 0 | my $dispatch = shift; | |||||||||||||||||||||||||||||||
| 368 | 0 | $dispatch->Action->{ActionClass} = $class; | |||||||||||||||||||||||||||||||
| 369 | 0 | }; | |||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 373 | # args | ||||||||||||||||||||||||||||||||
| 374 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub args { | ||||||||||||||||||||||||||||||
|
Subroutine
args: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 376 | 0 | my $args = $_[0]; | |||||||||||||||||||||||||||||||
| 377 | 0 | my $num = $args; | |||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if (ref $args eq 'ARRAY'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 380 | 0 | $num = @{$args}; | |||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 384 | 0 | my $dispatch = shift; | |||||||||||||||||||||||||||||||
| 385 | 0 | my $path = $dispatch->Action->{path}; | |||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if (my $chain = $dispatch->{chains}->{$path}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 387 | 0 | $dispatch->{chains}->{$path}->{path} = $path.'('.$num.')'; | |||||||||||||||||||||||||||||||
| 388 | 0 | $dispatch->{chains}->{$path}->{args} = $num; | |||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if (ref $path eq 'Regexp'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 392 | 0 | $dispatch->Action->{path} = qr{$path(/.*?)(/.*?)$}; | |||||||||||||||||||||||||||||||
| 393 | } else { | ||||||||||||||||||||||||||||||||
| 394 | 0 | $dispatch->Action->{path} .= '('.$num.')'; | |||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | 0 | $dispatch->Action->{args} = $args; | |||||||||||||||||||||||||||||||
| 398 | 0 | }; | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 402 | # chained controllers | ||||||||||||||||||||||||||||||||
| 403 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | sub chained { | ||||||||||||||||||||||||||||||
|
Subroutine
chained: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 405 | 0 | my $chain_path = $_[0]; | |||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 407 | 0 | my $dispatch = shift; | |||||||||||||||||||||||||||||||
| 408 | 0 | my $path = $dispatch->Action->{path}; | |||||||||||||||||||||||||||||||
| 409 | ##tell dispatcher this can be called on chains only | ||||||||||||||||||||||||||||||||
| 410 | 0 | $dispatch->Action->{chain} = 1; | |||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||
| 412 | 0 | my $class; | |||||||||||||||||||||||||||||||
| 413 | my $namespace; | ||||||||||||||||||||||||||||||||
| 414 | 0 | my $abs_path = $chain_path; | |||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | 0 | $class = $dispatch->Action->{class}; | |||||||||||||||||||||||||||||||
| 417 | 0 | ($class) = $class =~ m/Controllers(::.*)$/; | |||||||||||||||||||||||||||||||
| 418 | 0 | ($class = lc $class) =~ s/::/\//g; | |||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | 0 | $namespace = $dispatch->Action->{namespace}; | |||||||||||||||||||||||||||||||
| 421 | 0 | my $to_chain = $chain_path; | |||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | unless ($chain_path =~ m/^\// ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 423 | 0 | $to_chain = lc $class.'/'.$chain_path; | |||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if (!$abs_path){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 427 | 0 | push @{$dispatch->{chains_index}},$path; | |||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||
| 430 | 0 | my ($dir) = $path =~ m/^$namespace(.*?)$/; | |||||||||||||||||||||||||||||||
| 431 | 0 | $dispatch->{chains}->{$path}->{dir} = $dir; | |||||||||||||||||||||||||||||||
| 432 | 0 | $dispatch->{chains}->{$path}->{path} = $path; | |||||||||||||||||||||||||||||||
| 433 | 0 | $dispatch->{chains}->{$path}->{namespace} = $namespace; | |||||||||||||||||||||||||||||||
| 434 | 0 | push @{$dispatch->{chains}->{$to_chain}->{chained_by}},$path; | |||||||||||||||||||||||||||||||
| 435 | 0 | }; | |||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 439 | # some short cuts | ||||||||||||||||||||||||||||||||
| 440 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub capture { | ||||||||||||||||||||||||||||||
|
Subroutine
capture: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 443 | 0 | return $_[0]->action->{args}->[$_[1]]; | |||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||
| 445 | return $_[0]->action->{args} | ||||||||||||||||||||||||||||||||
| 446 | 0 | } | |||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||
| 448 | 3 | ▶ | sub ActionClass { | ||||||||||||||||||||||||||||||
|
Subroutine
ActionClass: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 449 | 3 | return shift->action->{ActionClass}; | |||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||
| 451 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 452 | # return controller class object | ||||||||||||||||||||||||||||||||
| 453 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 454 | 9 | ▶ | sub controller { | ||||||||||||||||||||||||||||||
|
Subroutine
controller: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 455 | 9 | return shift->action->{controller}; | |||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||
| 457 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 458 | # return current action code | ||||||||||||||||||||||||||||||||
| 459 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 460 | 3 | ▶ | sub code { | ||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 461 | 3 | return shift->action->{code}; | |||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||
| 463 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 464 | # set body content | ||||||||||||||||||||||||||||||||
| 465 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 466 | 4 | ▶ | sub body { | ||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 467 | 4 | my ($self,$content) = @_; | |||||||||||||||||||||||||||||||
| 468 | 4 | ▶ | if (@_ == 2){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 469 | 4 | my $body; | |||||||||||||||||||||||||||||||
| 470 | 4 | ▶ | if (ref $content eq ('CODE' || 'ARRAY' || 'GLOB')){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 471 | 0 | $body = $content; | |||||||||||||||||||||||||||||||
| 472 | } else { | ||||||||||||||||||||||||||||||||
| 473 | #truncates and open for reading and writing | ||||||||||||||||||||||||||||||||
| 474 | 4 | open($body, "+>", undef); | |||||||||||||||||||||||||||||||
| 475 | 4 | $body->write($content); | |||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||
| 478 | 4 | $self->{response}->{'body'} = $body; | |||||||||||||||||||||||||||||||
| 479 | 4 | return $self; | |||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||
| 481 | 0 | my $body = $self->{response}->{'body'}; | |||||||||||||||||||||||||||||||
| 482 | 0 | return $body; | |||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | sub getBody { | ||||||||||||||||||||||||||||||
|
Subroutine
getBody: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 486 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 487 | 1 | my $body = $self->{response}->{'body'}; | |||||||||||||||||||||||||||||||
| 488 | 1 | ▶ | if (ref $body eq 'GLOB'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 489 | 1 | $body->seek(0,0); | |||||||||||||||||||||||||||||||
| 490 | 1 | local $/; | |||||||||||||||||||||||||||||||
| 491 | 1 | return <$body>; | |||||||||||||||||||||||||||||||
| 492 | } else { | ||||||||||||||||||||||||||||||||
| 493 | 0 | return $body; | |||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||
| 497 | ##append content to the body | ||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 499 | 0 | my ($self,$chunk) = @_; | |||||||||||||||||||||||||||||||
| 500 | 0 | my $fh = $self->body(); | |||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | if ($fh && ref $fh eq 'GLOB'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$fh and ref $fh eq "GLOB"
MC/DC0%0/2
$fh and ref $fh eq "GLOB"
$fh
ref $fh eq "GLOB"
Truth table0%0/3
A and B
A= $fhB= ref $fh eq "GLOB"
| |||||||||||||||||||||||||||||||||
| 502 | 0 | $fh->write($chunk); | |||||||||||||||||||||||||||||||
| 503 | } else { | ||||||||||||||||||||||||||||||||
| 504 | 0 | $self->body($chunk); | |||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||
| 508 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 509 | # dump data | ||||||||||||||||||||||||||||||||
| 510 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | sub dumper { | ||||||||||||||||||||||||||||||
|
Subroutine
dumper: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 512 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 513 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||
| 514 | 0 | $self->body(Dumper $data); | |||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | sub json { | ||||||||||||||||||||||||||||||
|
Subroutine
json: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 518 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 519 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if (ref $data eq 'HASH'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 521 | 0 | $data = $self->serialize($data)->to_json; | |||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||
| 523 | 0 | $self->content_type('application/javascript; charset=utf-8'); | |||||||||||||||||||||||||||||||
| 524 | 0 | $self->body($data); | |||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | sub detach { | ||||||||||||||||||||||||||||||
|
Subroutine
detach: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 528 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 529 | 0 | $self->finalize(); | |||||||||||||||||||||||||||||||
| 530 | 0 | Cake::Exception::Mercy_Killing($self); | |||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||
| 532 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 533 | # param : set/get param | ||||||||||||||||||||||||||||||||
| 534 | # copied form catalyst param method :P that's why it looks sophisticated :)) | ||||||||||||||||||||||||||||||||
| 535 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub param { | ||||||||||||||||||||||||||||||
|
Subroutine
param: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 537 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if ( @_ == 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 539 | 0 | return keys %{ $self->parameters }; | |||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if (ref($_[0]) eq 'HASH'){ | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 543 | 0 | my $hash = shift; | |||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | while (my ($key,$value) = each(%{$hash})){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 545 | 0 | $self->parameters->{$key} = $value; | |||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | } elsif ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||
| 549 | 0 | my $param = shift; | |||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | unless ( exists $self->parameters->{$param} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | return wantarray ? () : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | if ( ref $self->parameters->{$param} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 555 | return (wantarray) | ||||||||||||||||||||||||||||||||
| 556 | 0 | ? @{ $self->parameters->{$param} } | |||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | : $self->parameters->{$param}->[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||
| 559 | else { | ||||||||||||||||||||||||||||||||
| 560 | return (wantarray) | ||||||||||||||||||||||||||||||||
| 561 | ? ( $self->parameters->{$param} ) | ||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | : $self->parameters->{$param}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||
| 565 | } elsif ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||
| 566 | 0 | my $field = shift; | |||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | $self->parameters->{$field} = @_ >= 2 ? [@_] : $_[0] ; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||
| 569 | 0 | return $self->parameters(); | |||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||
| 572 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 573 | # params : alias for parameters | ||||||||||||||||||||||||||||||||
| 574 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 575 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 576 | # parameters : Implemented in Cake::Engine | ||||||||||||||||||||||||||||||||
| 577 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | sub params { | ||||||||||||||||||||||||||||||
|
Subroutine
params: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 579 | 0 | return shift->parameters(@_); | |||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||
| 582 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 583 | # push_header : add header | ||||||||||||||||||||||||||||||||
| 584 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub push_header { | ||||||||||||||||||||||||||||||
|
Subroutine
push_header: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 586 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 587 | 0 | my ($header) = @_; | |||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | if (ref $header eq 'HASH'){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 589 | 0 | foreach my $key (keys %{$header}){ | |||||||||||||||||||||||||||||||
| 590 | 0 | my $head = $key.': '.$header->{$key}; | |||||||||||||||||||||||||||||||
| 591 | 0 | $self->push_header($head); | |||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||
| 593 | 0 | return; | |||||||||||||||||||||||||||||||
| 594 | } elsif (ref $header eq 'ARRAY'){ | ||||||||||||||||||||||||||||||||
| 595 | 0 | map { $self->push_header($_) } @{$header}; | |||||||||||||||||||||||||||||||
| 596 | 0 | return; | |||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 600 | 0 | $header = $_[0].': '.$_[1]; | |||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | croak 'Headers accept a Hash ref, Array of Hash refs or scalar' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $header or not $header =~ /(.*?):(.*?)/
MC/DC0%0/2
ref $header or not $header =~ /(.*?):(.*?)/
ref $header
not $header =~ /(.*?):(.*?)/
Truth table0%0/3
A or not(B)
A= ref $headerB= not $header =~ /(.*?):(.*?)/
| |||||||||||||||||||||||||||||||||
| 604 | if ref $header || $header !~ /(.*?):(.*?)/; | ||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if ($header =~ s/^content-type:\s*//i){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 607 | 0 | $self->content_type($header); | |||||||||||||||||||||||||||||||
| 608 | } elsif ($header =~ s/^status:\s*//i){ | ||||||||||||||||||||||||||||||||
| 609 | 0 | $self->status_code($header); | |||||||||||||||||||||||||||||||
| 610 | } else { | ||||||||||||||||||||||||||||||||
| 611 | 0 | push(@{$self->{response}->{headers}}, $header); | |||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||
| 614 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||
| 617 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 618 | # add multiple headers / get all headers | ||||||||||||||||||||||||||||||||
| 619 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | sub headers { | ||||||||||||||||||||||||||||||
|
Subroutine
headers: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 621 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 623 | 0 | foreach my $header (@_){ | |||||||||||||||||||||||||||||||
| 624 | 0 | $self->push_header($header); | |||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||
| 626 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | return wantarray ? @{$self->{response}->{headers}} : $self->{response}->{headers}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||
| 631 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 632 | # get/set content type header | ||||||||||||||||||||||||||||||||
| 633 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | sub content_type { | ||||||||||||||||||||||||||||||
|
Subroutine
content_type: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 635 | 0 | my ($self,$type) = @_; | |||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | if ($type){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 637 | 0 | $self->{response}->{content_type} = $type; | |||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | return $self->{response}->{content_type} || 'text/html'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'response'}{'content_type'} || 'text/html'
MC/DC0%0/1
$self->{'response'}{'content_type'} || 'text/html'
$self->{'response'}{'content_type'}
Truth table0%0/2
A
A= $self->{'response'}{'content_type'}
| |||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||
| 642 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 643 | # get/set response status code header | ||||||||||||||||||||||||||||||||
| 644 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 645 | 3 | ▶ | sub status_code { | ||||||||||||||||||||||||||||||
|
Subroutine
status_code: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 646 | 3 | my ($self,$code) = @_; | |||||||||||||||||||||||||||||||
| 647 | 3 | ▶ | if ($code){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 648 | 3 | $self->{response}->{status_code} = $code; | |||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||
| 650 | 3 | ▶ | return $self->{response}->{status_code} || '200'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'response'}{'status_code'} || '200'
MC/DC0%0/1
$self->{'response'}{'status_code'} || '200'
$self->{'response'}{'status_code'}
Truth table50%1/2
A
A= $self->{'response'}{'status_code'}
| |||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||
| 653 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 654 | # redirect | ||||||||||||||||||||||||||||||||
| 655 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | sub redirect { | ||||||||||||||||||||||||||||||
|
Subroutine
redirect: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 657 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 658 | 0 | my $url = shift; | |||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | my $status = shift || 302; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 302
MC/DC0%0/1
shift() || 302
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 660 | 0 | $url = $self->uri_for($url); | |||||||||||||||||||||||||||||||
| 661 | 0 | $self->status_code($status); | |||||||||||||||||||||||||||||||
| 662 | 0 | $self->push_header("Location: $url"); | |||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||
| 664 | ##just in case ?? inject this HTNL/javascript redirect | ||||||||||||||||||||||||||||||||
| 665 | 0 | my $html = qq~<html><head><script type="text/javascript"> | |||||||||||||||||||||||||||||||
| 666 | window.location.href='$url';</script></head><body> | ||||||||||||||||||||||||||||||||
| 667 | This page has moved to <a href="$url">$url</a></body></html>~; | ||||||||||||||||||||||||||||||||
| 668 | 0 | $self->body($html); | |||||||||||||||||||||||||||||||
| 669 | 0 | $self->finalize(); | |||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||
| 672 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 673 | # forward | ||||||||||||||||||||||||||||||||
| 674 | # to stop after forward use | ||||||||||||||||||||||||||||||||
| 675 | # return $c->forward(); | ||||||||||||||||||||||||||||||||
| 676 | #============================================================================ | ||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | sub forward { | ||||||||||||||||||||||||||||||
|
Subroutine
forward: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 678 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 679 | 0 | my $forward_to = shift; | |||||||||||||||||||||||||||||||
| 680 | 0 | my $args = shift; | |||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | if (ref $forward_to eq 'CODE'){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 682 | 0 | $forward_to->($self->controller,$self,$args); | |||||||||||||||||||||||||||||||
| 683 | } elsif ($forward_to !~ /^\//){ | ||||||||||||||||||||||||||||||||
| 684 | 0 | $self->controller()->$forward_to($self,$args); | |||||||||||||||||||||||||||||||
| 685 | } else { | ||||||||||||||||||||||||||||||||
| 686 | ####alter reguest path | ||||||||||||||||||||||||||||||||
| 687 | 0 | $self->path($forward_to); | |||||||||||||||||||||||||||||||
| 688 | 0 | $self->run($args); | |||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||
| 692 | package Cake::ENV; | ||||||||||||||||||||||||||||||||
| 693 | 8 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | sub ip { shift->{REMOTE_ADDR} } | ||||||||||||||||||||||||||||||
|
Subroutine
ip: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | sub host { shift->{HTTP_HOST} } | ||||||||||||||||||||||||||||||
|
Subroutine
host: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | sub referrer { shift->{HTTP_REFERER} } | ||||||||||||||||||||||||||||||
|
Subroutine
referrer: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 698 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 699 | 0 | my $sub = $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 700 | 0 | $sub =~ s/.*:://; | |||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | while (my ($key,$val) = each %{$self} ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | if ($key =~ m/$sub/i){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 703 | 0 | return $val; | |||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||
| 706 | 0 | return ''; | |||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||
| 709 | 8 | 1; | |||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||
| 711 | __END__ | ||||||||||||||||||||||||||||||||