line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Autobox::String; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
16
|
use Mojo::Base -strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
26
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub byte_stream { |
6
|
3
|
|
|
3
|
1
|
3460
|
require Mojo::ByteStream; |
7
|
3
|
|
|
|
|
44579
|
Mojo::ByteStream->new(shift); |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
*b = \&byte_stream; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub dom { |
13
|
3
|
|
|
3
|
1
|
3911
|
require Mojo::DOM; |
14
|
3
|
|
|
|
|
26490
|
my $dom = Mojo::DOM->new(shift); |
15
|
3
|
100
|
|
|
|
981
|
return @_ ? $dom->find(@_) : $dom; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub json { |
19
|
5
|
|
|
5
|
1
|
4904
|
require Mojo::JSON; |
20
|
5
|
|
|
|
|
42254
|
require Mojo::JSON::Pointer; |
21
|
5
|
|
|
|
|
1297
|
my $data = Mojo::JSON::decode_json(shift); |
22
|
5
|
100
|
|
|
|
614
|
return @_ ? Mojo::JSON::Pointer->new($data)->get(shift) : $data; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
*j = \&json; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub url { |
28
|
3
|
|
|
3
|
1
|
4255
|
require Mojo::URL; |
29
|
3
|
|
|
|
|
13004
|
Mojo::URL->new(shift); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Mojo::Autobox::String - Autobox string methods for Mojo::Autobox |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use Mojo::Autobox; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# "Trimmed" |
43
|
|
|
|
|
|
|
' Trimmed '->byte_stream->trim; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# "Text" |
46
|
|
|
|
|
|
|
' Text '->dom->at('p')->text; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# "world" |
49
|
|
|
|
|
|
|
'{"hello": "world"}'->json->{hello}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# "anchor" |
52
|
|
|
|
|
|
|
'http://mysite.com/path#anchor'->url->fragment; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
String methods for L. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHODS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 byte_stream |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns an instance of L, constructed from the invocant string. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 b |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
An alias for L. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 dom |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns an instance of L, constructed from the invocant string. |
71
|
|
|
|
|
|
|
Optionally takes a CSS3 selector which is passed to the L instance's L method. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 json |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Parses the invocant string as JSON using L and returns the result. |
76
|
|
|
|
|
|
|
Optionally takes a JSON pointer used to delve into the resulting structure using L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 j |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
An alias for L. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 url |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns an instance of L, constructed from the invocant string. |
85
|
|
|
|
|
|
|
|