line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Common; |
2
|
90
|
|
|
90
|
|
1209305
|
use Mojo::Base -strict; |
|
90
|
|
|
|
|
9793
|
|
|
90
|
|
|
|
|
653
|
|
3
|
90
|
|
|
90
|
|
17175
|
use Mojo::Loader; |
|
90
|
|
|
|
|
2265871
|
|
|
90
|
|
|
|
|
4045
|
|
4
|
90
|
|
|
90
|
|
652
|
use Encode qw(encode is_utf8); |
|
90
|
|
|
|
|
232
|
|
|
90
|
|
|
|
|
4431
|
|
5
|
|
|
|
|
|
|
|
6
|
90
|
|
|
90
|
|
570
|
use base qw(Exporter); |
|
90
|
|
|
|
|
198
|
|
|
90
|
|
|
|
|
54549
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw(trim); |
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(char_shift find_modules load_class params decode_json); |
9
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $CHAR_SHIFT = ord('A') - 10; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub trim($) { |
14
|
207
|
|
|
207
|
0
|
463
|
my ($str) = @_; |
15
|
207
|
100
|
|
|
|
622
|
return undef unless defined $str; |
16
|
181
|
|
|
|
|
1174
|
s{^\s+}{}, s{\s+$}{} for $str; |
17
|
181
|
|
|
|
|
648
|
return $str; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Shift for convert ASCII char position to simple sequence 0,1,2...9,A,B,C,,, |
21
|
|
|
|
|
|
|
sub char_shift() { |
22
|
9
|
|
|
9
|
0
|
24
|
return $CHAR_SHIFT; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Around deprication |
26
|
|
|
|
|
|
|
sub find_modules { |
27
|
74
|
50
|
|
74
|
0
|
1353
|
return Mojo::Loader::find_modules( $_[0] ) |
28
|
|
|
|
|
|
|
if Mojo::Loader->can('find_modules'); |
29
|
0
|
0
|
|
|
|
0
|
return @{ Mojo::Loader->new->search( $_[0] ) } |
|
0
|
|
|
|
|
0
|
|
30
|
|
|
|
|
|
|
if Mojo::Loader->can('new'); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Around deprication |
34
|
|
|
|
|
|
|
sub load_class($) { |
35
|
1445
|
50
|
|
1445
|
0
|
12023
|
return Mojo::Loader::load_class( $_[0] ) |
36
|
|
|
|
|
|
|
if Mojo::Loader->can('load_class'); |
37
|
0
|
0
|
|
|
|
0
|
return Mojo::Loader->new->load( $_[0] ) |
38
|
|
|
|
|
|
|
if Mojo::Loader->can('load'); |
39
|
0
|
|
|
|
|
0
|
die 'Looks like Mojo again depricate module Mojo::Loader'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Around deprication |
43
|
|
|
|
|
|
|
sub params($$) { |
44
|
502
|
50
|
|
502
|
0
|
2811
|
return @{ $_[0]->every_param( $_[1] ) } if $_[0]->can('every_param'); |
|
502
|
|
|
|
|
1869
|
|
45
|
0
|
0
|
|
|
|
0
|
return $_[0]->param( $_[1] ) if $_[0]->can('param'); |
46
|
0
|
|
|
|
|
0
|
die 'Looks like Mojo again depricate module Mojo::Controller'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Around deprication + blob fix |
50
|
|
|
|
|
|
|
sub decode_json($) { |
51
|
24
|
|
|
24
|
0
|
53
|
my $json = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# JSON must be blob |
54
|
24
|
100
|
|
|
|
197
|
$json = encode utf8 => $json if is_utf8 $json; |
55
|
|
|
|
|
|
|
|
56
|
24
|
50
|
|
|
|
865
|
return eval{ Mojo::JSON::decode_json( $json ) } |
|
24
|
|
|
|
|
115
|
|
57
|
|
|
|
|
|
|
if Mojo::JSON->can('decode_json'); |
58
|
0
|
0
|
|
|
|
|
return @{ Mojo::JSON->new->decode( $json ) } |
|
0
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if Mojo::JSON->can('new'); |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |