line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
#PODNAME: Raisin::Encoder |
3
|
|
|
|
|
|
|
#ABSTRACT: A helper for L over encoder modules |
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
269885
|
use strict; |
|
14
|
|
|
|
|
41
|
|
|
14
|
|
|
|
|
469
|
|
6
|
14
|
|
|
14
|
|
77
|
use warnings; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
708
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Raisin::Encoder; |
9
|
|
|
|
|
|
|
$Raisin::Encoder::VERSION = '0.92'; |
10
|
14
|
|
|
14
|
|
640
|
use Plack::Util; |
|
14
|
|
|
|
|
12805
|
|
|
14
|
|
|
|
|
391
|
|
11
|
14
|
|
|
14
|
|
540
|
use Plack::Util::Accessor qw(registered); |
|
14
|
|
|
|
|
309
|
|
|
14
|
|
|
|
|
116
|
|
12
|
|
|
|
|
|
|
|
13
|
66
|
|
|
66
|
0
|
50146
|
sub new { bless { registered => {} }, shift } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub register { |
16
|
2
|
|
|
2
|
1
|
12
|
my ($self, $format, $class) = @_; |
17
|
2
|
|
|
|
|
11
|
$self->{registered}{$format} = $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub builtin { |
21
|
|
|
|
|
|
|
{ |
22
|
130
|
|
|
130
|
1
|
675
|
json => 'Raisin::Encoder::JSON', |
23
|
|
|
|
|
|
|
yaml => 'Raisin::Encoder::YAML', |
24
|
|
|
|
|
|
|
text => 'Raisin::Encoder::Text', |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub all { |
29
|
158
|
|
|
158
|
1
|
411
|
my $self = shift; |
30
|
|
|
|
|
|
|
my %s = ( |
31
|
158
|
|
|
|
|
314
|
%{ $self->builtin }, |
32
|
158
|
|
|
|
|
210
|
%{ $self->registered }, |
|
158
|
|
|
|
|
429
|
|
33
|
|
|
|
|
|
|
); |
34
|
158
|
|
|
|
|
1369
|
\%s; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub for { |
38
|
50
|
|
|
50
|
1
|
298
|
my ($self, $format) = @_; |
39
|
50
|
|
|
|
|
107
|
$self->all->{$format}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub media_types_map_flat_hash { |
43
|
60
|
|
|
60
|
1
|
454
|
my $self = shift; |
44
|
60
|
|
|
|
|
139
|
my $s = $self->all; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my %media_types_map = map { |
47
|
60
|
|
|
|
|
171
|
Plack::Util::load_class($s->{$_}); |
|
169
|
|
|
|
|
525
|
|
48
|
169
|
|
|
|
|
2269
|
$_ => $s->{$_}->detectable_by; |
49
|
|
|
|
|
|
|
} keys %$s; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my %media_types_map_flat_hash = map { |
52
|
60
|
|
|
|
|
188
|
my $k = $_; map { $_ => $k } @{ $media_types_map{$k} } |
|
169
|
|
|
|
|
222
|
|
|
169
|
|
|
|
|
217
|
|
|
638
|
|
|
|
|
1329
|
|
|
169
|
|
|
|
|
266
|
|
53
|
|
|
|
|
|
|
} keys %media_types_map; |
54
|
|
|
|
|
|
|
|
55
|
60
|
|
|
|
|
561
|
%media_types_map_flat_hash; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |