line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Common; |
2
|
91
|
|
|
91
|
|
881265
|
use Mojo::Base -strict; |
|
91
|
|
|
|
|
105305
|
|
|
91
|
|
|
|
|
531
|
|
3
|
91
|
|
|
91
|
|
13512
|
use Mojo::Loader; |
|
91
|
|
|
|
|
396246
|
|
|
91
|
|
|
|
|
3866
|
|
4
|
91
|
|
|
91
|
|
562
|
use Encode qw(encode is_utf8); |
|
91
|
|
|
|
|
209
|
|
|
91
|
|
|
|
|
4492
|
|
5
|
|
|
|
|
|
|
|
6
|
91
|
|
|
91
|
|
542
|
use base qw(Exporter); |
|
91
|
|
|
|
|
165
|
|
|
91
|
|
|
|
|
58607
|
|
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
|
417
|
my ($str) = @_; |
15
|
207
|
100
|
|
|
|
499
|
return undef unless defined $str; |
16
|
181
|
|
|
|
|
1074
|
s{^\s+}{}, s{\s+$}{} for $str; |
17
|
181
|
|
|
|
|
552
|
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
|
17
|
return $CHAR_SHIFT; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Around deprication |
26
|
|
|
|
|
|
|
sub find_modules { |
27
|
75
|
50
|
|
75
|
0
|
1158
|
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
|
1462
|
50
|
|
1462
|
0
|
9429
|
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
|
510
|
50
|
|
510
|
0
|
2179
|
return @{ $_[0]->every_param( $_[1] ) } if $_[0]->can('every_param'); |
|
510
|
|
|
|
|
1345
|
|
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
|
32
|
|
|
32
|
0
|
52
|
my $json = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# JSON must be blob |
54
|
32
|
100
|
|
|
|
177
|
$json = encode utf8 => $json if is_utf8 $json; |
55
|
|
|
|
|
|
|
|
56
|
32
|
50
|
|
|
|
736
|
return eval{ Mojo::JSON::decode_json( $json ) } |
|
32
|
|
|
|
|
99
|
|
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; |