line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::HTTP::UserAgent::Base::Dumper; |
2
|
|
|
|
|
|
|
$Parse::HTTP::UserAgent::Base::Dumper::VERSION = '0.41'; |
3
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
68
|
|
5
|
2
|
|
|
2
|
|
42
|
use Carp qw( croak ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
94
|
|
6
|
2
|
|
|
2
|
|
10
|
use Parse::HTTP::UserAgent::Constants qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1560
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub dumper { |
9
|
281
|
|
|
281
|
1
|
1226
|
my($self, @args) = @_; |
10
|
281
|
50
|
|
|
|
1125
|
my %opt = @args % 2 ? () : ( |
11
|
|
|
|
|
|
|
type => 'dumper', |
12
|
|
|
|
|
|
|
format => 'none', |
13
|
|
|
|
|
|
|
interpret => 0, |
14
|
|
|
|
|
|
|
@args |
15
|
|
|
|
|
|
|
); |
16
|
281
|
|
|
|
|
673
|
my $meth = '_dumper_' . lc $opt{type}; |
17
|
281
|
50
|
|
|
|
919
|
croak "Don't know how to dump with $opt{type}" if ! $self->can( $meth ); |
18
|
281
|
|
|
|
|
611
|
my $buf = $self->$meth( \%opt ); |
19
|
281
|
50
|
|
|
|
1523
|
return $buf if defined wantarray; |
20
|
0
|
|
|
|
|
0
|
my $pok = print $buf ."\n"; |
21
|
0
|
|
|
|
|
0
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _dump_to_struct { |
25
|
0
|
|
|
0
|
|
0
|
my %struct = shift->as_hash; |
26
|
0
|
|
0
|
|
|
0
|
$struct{$_} ||= [] for qw( dotnet mozilla extras tk ); |
27
|
0
|
|
0
|
|
|
0
|
$struct{$_} ||= 0 for qw( unknown ); |
28
|
0
|
|
|
|
|
0
|
return \%struct; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _dumper_json { |
32
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
33
|
0
|
|
|
|
|
0
|
my $opt = shift; |
34
|
0
|
|
|
|
|
0
|
require JSON; |
35
|
|
|
|
|
|
|
return JSON::to_json( |
36
|
|
|
|
|
|
|
$self->_dump_to_struct, |
37
|
0
|
|
|
|
|
0
|
{ pretty => $opt->{format} eq 'pretty' } |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _dumper_xml { |
42
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
43
|
0
|
|
|
|
|
0
|
my $opt = shift; |
44
|
0
|
|
|
|
|
0
|
require XML::Simple; |
45
|
|
|
|
|
|
|
return XML::Simple::XMLout( |
46
|
|
|
|
|
|
|
$self->_dump_to_struct, |
47
|
|
|
|
|
|
|
RootName => 'ua', |
48
|
0
|
|
|
|
|
0
|
NoIndent => $opt->{format} ne 'pretty', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _dumper_yaml { |
53
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
54
|
0
|
|
|
|
|
0
|
my $opt = shift; |
55
|
0
|
|
|
|
|
0
|
require YAML; |
56
|
0
|
|
|
|
|
0
|
return YAML::Dump( $self->_dump_to_struct ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _dumper_dumper { |
60
|
|
|
|
|
|
|
# yeah, I know. Fugly code here |
61
|
281
|
|
|
281
|
|
405
|
my $self = shift; |
62
|
281
|
|
|
|
|
360
|
my $opt = shift; |
63
|
281
|
50
|
|
|
|
849
|
my @ids = $opt->{args} ? @{ $opt->{args} } : $self->_object_ids; |
|
0
|
|
|
|
|
0
|
|
64
|
281
|
50
|
|
|
|
1545
|
my $args = $opt->{args} ? 1 : 0; |
65
|
281
|
|
|
|
|
358
|
my $max = 0; |
66
|
281
|
100
|
|
|
|
415
|
map { $max = length $_ if length $_ > $max; } @ids; |
|
6463
|
|
|
|
|
11635
|
|
67
|
281
|
|
|
|
|
498
|
my @titles = qw( FIELD VALUE ); |
68
|
281
|
|
|
|
|
1336
|
my $buf = sprintf "%s%s%s\n%s%s%s\n", |
69
|
|
|
|
|
|
|
$titles[0], |
70
|
|
|
|
|
|
|
(q{ } x (2 + $max - length $titles[0])), |
71
|
|
|
|
|
|
|
$titles[1], |
72
|
|
|
|
|
|
|
q{-} x $max, q{ } x 2, q{-} x ($max*2); |
73
|
281
|
|
|
|
|
1834
|
require Data::Dumper; |
74
|
281
|
|
|
|
|
5258
|
my @buf; |
75
|
281
|
|
|
|
|
513
|
foreach my $id ( @ids ) { |
76
|
6463
|
50
|
|
|
|
9907
|
my $name = $args ? $id->{name} : $id; |
77
|
6463
|
50
|
|
|
|
13814
|
my $val = $args ? $id->{value} : $self->[ $self->$id() ]; |
78
|
6463
|
100
|
100
|
|
|
12957
|
if ( $val && ref $val ) { |
79
|
421
|
|
|
|
|
1248
|
my $d = Data::Dumper->new([$val]); |
80
|
421
|
|
|
|
|
8575
|
$d->Indent(0); |
81
|
421
|
|
|
|
|
3852
|
my $rv = $d->Dump; |
82
|
421
|
|
|
|
|
8623
|
$rv =~ s{ \$VAR1 \s+ = \s+ }{}xms; |
83
|
421
|
|
|
|
|
1061
|
$rv =~ s{ ; }{}xms; |
84
|
421
|
50
|
|
|
|
2252
|
$val = $rv eq '[]' ? q{} : $rv; |
85
|
|
|
|
|
|
|
} |
86
|
6463
|
100
|
|
|
|
17363
|
push @buf, [ |
87
|
|
|
|
|
|
|
$name, |
88
|
|
|
|
|
|
|
(q{ } x (2 + $max - length $name)), |
89
|
|
|
|
|
|
|
defined $val ? $val : q{} |
90
|
|
|
|
|
|
|
]; |
91
|
|
|
|
|
|
|
} |
92
|
281
|
|
|
|
|
973
|
foreach my $row ( sort { lc $a->[0] cmp lc $b->[0] } @buf ) { |
|
21878
|
|
|
|
|
28948
|
|
93
|
6463
|
|
|
|
|
7411
|
$buf .= sprintf "%s%s%s\n", @{ $row }; |
|
6463
|
|
|
|
|
11286
|
|
94
|
|
|
|
|
|
|
} |
95
|
281
|
|
|
|
|
2176
|
return $buf; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |