| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::Autobox; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
34094
|
use Mojo::Base -strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
22
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
6
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
425
|
use Mojo::Base 'autobox'; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Mojo::Autobox::String; |
|
11
|
|
|
|
|
|
|
require Mojo::Autobox::Array; |
|
12
|
|
|
|
|
|
|
require Mojo::Autobox::Hash; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
|
15
|
4
|
|
|
4
|
|
24
|
my $class = shift; |
|
16
|
4
|
|
|
|
|
24
|
$class->SUPER::import( |
|
17
|
|
|
|
|
|
|
STRING => 'Mojo::Autobox::String', |
|
18
|
|
|
|
|
|
|
ARRAY => 'Mojo::Autobox::Array', |
|
19
|
|
|
|
|
|
|
HASH => 'Mojo::Autobox::Hash', |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Mojo::Autobox - Some extra Mojo for Perl native datatypes |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Mojo::Base -strict; |
|
32
|
|
|
|
|
|
|
use Mojo::Autobox; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# "site.com\n" |
|
35
|
|
|
|
|
|
|
'{"html": ""}' |
|
36
|
|
|
|
|
|
|
->json('/html') |
|
37
|
|
|
|
|
|
|
->dom->at('a')->{href} |
|
38
|
|
|
|
|
|
|
->url->host |
|
39
|
|
|
|
|
|
|
->byte_stream->say; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Using L, methods are provided to Perl native datatypes. |
|
44
|
|
|
|
|
|
|
This ability is then used to provide methods useful with classes from the L toolkit. |
|
45
|
|
|
|
|
|
|
These are especially useful to contruct objects to continue a "chain" of method invocations. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The effect is lexical, and therefore is contained within the scope that the module is imported into. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 CLASSES |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
When the pragma is in effect, the types are effectively blessed into the following classes: |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item STRING - L |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item ARRAY - L |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item HASH - L |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 ONE-LINERS |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Additionally, for one-liner fun, the class L may be used to load L and L. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
perl -MojoBox -E 'g("http://mojolicio.us")->dom->find("a")->each(sub{$_->{href}->url->host->b->say})' |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SOURCE REPOSITORY |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Joel Berger, Ejoel.a.berger@gmail.comE |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Copyright (C) 2014 by Joel Berger |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
82
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
83
|
|
|
|
|
|
|
|