line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Headers::ActionPack::PriorityList; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
7
|
|
|
7
|
|
53729
|
$HTTP::Headers::ActionPack::PriorityList::AUTHORITY = 'cpan:STEVAN'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$HTTP::Headers::ActionPack::PriorityList::VERSION = '0.09'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: A Priority List |
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
48
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
230
|
|
11
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
243
|
|
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
|
|
56
|
use HTTP::Headers::ActionPack::Util qw[ |
14
|
|
|
|
|
|
|
split_header_words |
15
|
|
|
|
|
|
|
join_header_words |
16
|
7
|
|
|
7
|
|
3011
|
]; |
|
7
|
|
|
|
|
22
|
|
17
|
|
|
|
|
|
|
|
18
|
7
|
|
|
7
|
|
3923
|
use parent 'HTTP::Headers::ActionPack::Core::BaseHeaderList'; |
|
7
|
|
|
|
|
602
|
|
|
7
|
|
|
|
|
47
|
|
19
|
|
|
|
|
|
|
|
20
|
62
|
|
|
62
|
1
|
407
|
sub BUILDARGS { +{ 'index' => {}, 'items' => {} } } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub BUILD { |
23
|
34
|
|
|
34
|
1
|
56
|
my ($self, @items) = @_; |
24
|
34
|
|
|
|
|
185
|
foreach my $item ( @items ) { |
25
|
5
|
|
|
|
|
14
|
$self->add( @$item ) |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
236
|
|
|
236
|
1
|
2196
|
sub index { (shift)->{'index'} } |
30
|
638
|
|
|
638
|
1
|
2824
|
sub items { (shift)->{'items'} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new_from_string { |
33
|
58
|
|
|
58
|
1
|
4425
|
my ($class, $header_string) = @_; |
34
|
58
|
|
|
|
|
250
|
my $list = $class->new; |
35
|
58
|
|
|
|
|
192
|
foreach my $header ( split_header_words( $header_string ) ) { |
36
|
140
|
|
|
|
|
380
|
$list->add_header_value( $header ); |
37
|
|
|
|
|
|
|
} |
38
|
58
|
|
|
|
|
266
|
$list; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub as_string { |
42
|
5
|
|
|
5
|
1
|
13
|
my $self = shift; |
43
|
18
|
|
|
|
|
37
|
join ', ' => map { |
44
|
5
|
|
|
|
|
17
|
my ($q, $subject) = @{ $_ }; |
|
18
|
|
|
|
|
23
|
|
45
|
18
|
|
|
|
|
62
|
join_header_words( $subject, q => $q ); |
46
|
|
|
|
|
|
|
} $self->iterable; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub add { |
50
|
158
|
|
|
158
|
1
|
259
|
my ($self, $q, $choice) = @_; |
51
|
|
|
|
|
|
|
# XXX - should failure to canonicalize be an error? or should |
52
|
|
|
|
|
|
|
# canonicalize_choice itself throw an error on bad values? |
53
|
158
|
50
|
|
|
|
409
|
$choice = $self->canonicalize_choice($choice) |
54
|
|
|
|
|
|
|
or return; |
55
|
158
|
|
|
|
|
935
|
$q += 0; # be sure to numify this |
56
|
158
|
|
|
|
|
330
|
$self->index->{ $choice } = $q; |
57
|
158
|
100
|
|
|
|
411
|
$self->items->{ $q } = [] unless exists $self->items->{ $q }; |
58
|
158
|
|
|
|
|
212
|
push @{ $self->items->{ $q } } => $choice; |
|
158
|
|
|
|
|
304
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub add_header_value { |
62
|
64
|
|
|
64
|
1
|
80
|
my $self = shift; |
63
|
64
|
|
|
|
|
66
|
my ($choice, %params) = @{ $_[0] }; |
|
64
|
|
|
|
|
157
|
|
64
|
64
|
100
|
|
|
|
218
|
$self->add( exists $params{'q'} ? $params{'q'} : 1.0, $choice ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get { |
68
|
7
|
|
|
7
|
1
|
1273
|
my ($self, $q) = @_; |
69
|
7
|
|
|
|
|
23
|
$self->items->{ $q }; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub priority_of { |
73
|
78
|
|
|
78
|
1
|
112
|
my ($self, $choice) = @_; |
74
|
78
|
50
|
|
|
|
228
|
$choice = $self->canonicalize_choice($choice) |
75
|
|
|
|
|
|
|
or return; |
76
|
78
|
|
|
|
|
325
|
$self->index->{ $choice }; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub iterable { |
80
|
39
|
|
|
39
|
1
|
57
|
my $self = shift; |
81
|
77
|
|
|
|
|
103
|
map { |
82
|
39
|
|
|
|
|
119
|
my $q = $_; |
83
|
77
|
|
|
|
|
111
|
map { [ $q, $_ ] } @{ $self->items->{ $q } } |
|
96
|
|
|
|
|
427
|
|
|
77
|
|
|
|
|
139
|
|
84
|
39
|
|
|
|
|
50
|
} reverse sort keys %{ $self->items }; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub canonicalize_choice { |
88
|
46
|
|
|
46
|
1
|
143
|
return $_[1]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |