line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::Common; |
2
|
90
|
|
|
90
|
|
1118162
|
use Mojo::Base -strict; |
|
90
|
|
|
|
|
8809
|
|
|
90
|
|
|
|
|
599
|
|
3
|
90
|
|
|
90
|
|
15346
|
use Mojo::Loader; |
|
90
|
|
|
|
|
1961999
|
|
|
90
|
|
|
|
|
3552
|
|
4
|
90
|
|
|
90
|
|
576
|
use Encode qw(encode is_utf8); |
|
90
|
|
|
|
|
199
|
|
|
90
|
|
|
|
|
4005
|
|
5
|
|
|
|
|
|
|
|
6
|
90
|
|
|
90
|
|
489
|
use base qw(Exporter); |
|
90
|
|
|
|
|
185
|
|
|
90
|
|
|
|
|
48432
|
|
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
|
400
|
my ($str) = @_; |
15
|
207
|
100
|
|
|
|
689
|
return undef unless defined $str; |
16
|
181
|
|
|
|
|
996
|
s{^\s+}{}, s{\s+$}{} for $str; |
17
|
181
|
|
|
|
|
577
|
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
|
18
|
return $CHAR_SHIFT; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Around deprication |
26
|
|
|
|
|
|
|
sub find_modules { |
27
|
74
|
50
|
|
74
|
0
|
1124
|
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
|
9991
|
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
|
2332
|
return @{ $_[0]->every_param( $_[1] ) } if $_[0]->can('every_param'); |
|
502
|
|
|
|
|
1553
|
|
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
|
43
|
my $json = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# JSON must be blob |
54
|
24
|
100
|
|
|
|
146
|
$json = encode utf8 => $json if is_utf8 $json; |
55
|
|
|
|
|
|
|
|
56
|
24
|
50
|
|
|
|
720
|
return eval{ Mojo::JSON::decode_json( $json ) } |
|
24
|
|
|
|
|
83
|
|
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; |