line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Page; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
5
|
1
|
|
|
1
|
|
3
|
use Carp(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
313
|
use Archive::Har::Page::PageTimings(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
653
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
0
|
|
my ( $class, $params ) = @_; |
12
|
0
|
|
|
|
|
|
my $self = {}; |
13
|
0
|
|
|
|
|
|
bless $self, $class; |
14
|
0
|
0
|
|
|
|
|
if ( defined $params ) { |
15
|
0
|
|
|
|
|
|
$self->id( $params->{id} ); |
16
|
0
|
0
|
|
|
|
|
if ( defined $params->{title} ) { |
17
|
0
|
|
|
|
|
|
$self->title( $params->{title} ); |
18
|
|
|
|
|
|
|
} |
19
|
0
|
0
|
|
|
|
|
if ( defined $params->{startedDateTime} ) { |
20
|
0
|
|
|
|
|
|
$self->started_date_time( $params->{startedDateTime} ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
$self->page_timings( |
23
|
|
|
|
|
|
|
Archive::Har::Page::PageTimings->new( |
24
|
|
|
|
|
|
|
$params->{pageTimings} || {} |
25
|
|
|
|
|
|
|
) |
26
|
0
|
|
0
|
|
|
|
); |
27
|
0
|
0
|
|
|
|
|
if ( defined $params->{comment} ) { |
28
|
0
|
|
|
|
|
|
$self->comment( $params->{comment} ); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$params} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
32
|
0
|
|
|
|
|
|
$self->$key( $params->{$key} ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub id { |
40
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
41
|
0
|
|
|
|
|
|
my $old = $self->{id}; |
42
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
43
|
0
|
|
|
|
|
|
$self->{id} = $new; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
return $old; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub title { |
49
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
50
|
0
|
|
|
|
|
|
my $old = $self->{title}; |
51
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
52
|
0
|
|
|
|
|
|
$self->{title} = $new; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
55
|
0
|
|
|
|
|
|
return $old; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub started_date_time { |
63
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
64
|
0
|
|
|
|
|
|
my $old = $self->{startedDateTime}; |
65
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
66
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
67
|
0
|
|
|
|
|
|
my $date_regex = qr/\d{4}[-]\d{2}[-]\d{2}/smx; |
68
|
0
|
|
|
|
|
|
my $time_regex = qr/\d{2}:\d{2}:\d{2}[.]\d+/smx; |
69
|
0
|
|
|
|
|
|
my $zone_regex = qr/(?:[+]\d{2}:\d{2}|Z)/smx; |
70
|
0
|
0
|
|
|
|
|
if ( $new =~ /^${date_regex}T${time_regex}${zone_regex}$/smx ) { |
71
|
0
|
|
|
|
|
|
$self->{startedDateTime} = $new; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
|
|
|
|
|
Carp::croak('started_date_time is not formatted correctly'); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
0
|
|
|
|
|
|
$self->{startedDateTime} = '0000-00-00T00:00:00.0+00:00'; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old eq '0000-00-00T00:00:00.0+00:00' ) ) { |
82
|
0
|
|
|
|
|
|
return; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
0
|
|
|
|
|
|
return $old; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub page_timings { |
90
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
91
|
0
|
|
|
|
|
|
my $old = $self->{pageTimings}; |
92
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
93
|
0
|
|
|
|
|
|
$self->{pageTimings} = $new; |
94
|
|
|
|
|
|
|
} |
95
|
0
|
|
|
|
|
|
return $old; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub comment { |
99
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
100
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
101
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
102
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
|
return $old; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub AUTOLOAD { |
108
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Page::AUTOLOAD; |
111
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $old; |
114
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
116
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
117
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
else { |
123
|
0
|
|
|
|
|
|
Carp::croak( |
124
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
|
return $old; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub TO_JSON { |
131
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
132
|
0
|
|
|
|
|
|
my $json = { pageTimings => $self->page_timings(), }; |
133
|
0
|
0
|
|
|
|
|
if ( defined $self->title() ) { |
134
|
0
|
|
|
|
|
|
$json->{title} = $self->title(); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
0
|
|
|
|
|
|
$json->{title} = 'Unknown'; |
138
|
|
|
|
|
|
|
} |
139
|
0
|
0
|
|
|
|
|
if ( defined $self->started_date_time() ) { |
140
|
0
|
|
|
|
|
|
$json->{startedDateTime} = $self->started_date_time(); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
else { |
143
|
0
|
|
|
|
|
|
$json->{startedDateTime} = '0000-00-00T00:00:00.0+00:00'; |
144
|
|
|
|
|
|
|
} |
145
|
0
|
0
|
|
|
|
|
if ( defined $self->id() ) { |
146
|
0
|
|
|
|
|
|
$json->{id} = $self->id(); |
147
|
|
|
|
|
|
|
} |
148
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
149
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
150
|
|
|
|
|
|
|
} |
151
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
153
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
154
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
0
|
|
|
|
|
|
return $json; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
__END__ |