line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Browser; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
757
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
1
|
|
my ( $class, $params ) = @_; |
11
|
0
|
|
|
|
|
|
my $self = {}; |
12
|
0
|
|
|
|
|
|
bless $self, $class; |
13
|
0
|
0
|
|
|
|
|
if ( defined $params ) { |
14
|
0
|
|
|
|
|
|
$self->name( $params->{name} ); |
15
|
0
|
|
|
|
|
|
$self->version( $params->{version} ); |
16
|
0
|
0
|
|
|
|
|
if ( defined $params->{comment} ) { |
17
|
0
|
|
|
|
|
|
$self->comment( $params->{comment} ); |
18
|
|
|
|
|
|
|
} |
19
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$params} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
21
|
0
|
|
|
|
|
|
$self->$key( $params->{$key} ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub name { |
29
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
30
|
0
|
|
|
|
|
|
my $old = $self->{name}; |
31
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
32
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
33
|
0
|
|
|
|
|
|
$self->{name} = $new; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
|
$self->{name} = 'Unknown'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old eq 'Unknown' ) ) { |
40
|
0
|
|
|
|
|
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
0
|
|
|
|
|
|
return $old; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub version { |
48
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
49
|
0
|
|
|
|
|
|
my $old = $self->{version}; |
50
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
51
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
52
|
0
|
|
|
|
|
|
$self->{version} = $new; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
0
|
|
|
|
|
|
$self->{version} = 'Unknown'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old eq 'Unknown' ) ) { |
59
|
0
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
0
|
|
|
|
|
|
return $old; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub comment { |
67
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
68
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
69
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
70
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
|
return $old; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub AUTOLOAD { |
76
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Browser::AUTOLOAD; |
79
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $old; |
82
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
84
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
85
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
0
|
|
|
|
|
|
Carp::croak( |
92
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
|
return $old; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub TO_JSON { |
99
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
100
|
0
|
|
|
|
|
|
my $json = {}; |
101
|
0
|
0
|
|
|
|
|
if ( defined $self->name() ) { |
102
|
0
|
|
|
|
|
|
$json->{name} = $self->name(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
else { |
105
|
0
|
|
|
|
|
|
$json->{name} = 'Unknown'; |
106
|
|
|
|
|
|
|
} |
107
|
0
|
0
|
|
|
|
|
if ( defined $self->version() ) { |
108
|
0
|
|
|
|
|
|
$json->{version} = $self->version(); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else { |
111
|
0
|
|
|
|
|
|
$json->{version} = 'Unknown'; |
112
|
|
|
|
|
|
|
} |
113
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
114
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
115
|
|
|
|
|
|
|
} |
116
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
118
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
119
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
0
|
|
|
|
|
|
return $json; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
__END__ |