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
|
|
211557
|
use strict; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
361
|
|
6
|
14
|
|
|
14
|
|
60
|
use warnings; |
|
14
|
|
|
|
|
22
|
|
|
14
|
|
|
|
|
528
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Raisin::Encoder; |
9
|
|
|
|
|
|
|
$Raisin::Encoder::VERSION = '0.94'; |
10
|
14
|
|
|
14
|
|
475
|
use Plack::Util; |
|
14
|
|
|
|
|
10778
|
|
|
14
|
|
|
|
|
632
|
|
11
|
14
|
|
|
14
|
|
392
|
use Plack::Util::Accessor qw(registered); |
|
14
|
|
|
|
|
240
|
|
|
14
|
|
|
|
|
90
|
|
12
|
|
|
|
|
|
|
|
13
|
78
|
|
|
78
|
0
|
47335
|
sub new { bless { registered => {} }, shift } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub register { |
16
|
2
|
|
|
2
|
1
|
9
|
my ($self, $format, $class) = @_; |
17
|
2
|
|
|
|
|
9
|
$self->{registered}{$format} = $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub builtin { |
21
|
|
|
|
|
|
|
{ |
22
|
152
|
|
|
152
|
1
|
628
|
json => 'Raisin::Encoder::JSON', |
23
|
|
|
|
|
|
|
yaml => 'Raisin::Encoder::YAML', |
24
|
|
|
|
|
|
|
text => 'Raisin::Encoder::Text', |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub all { |
29
|
193
|
|
|
193
|
1
|
423
|
my $self = shift; |
30
|
|
|
|
|
|
|
my %s = ( |
31
|
193
|
|
|
|
|
334
|
%{ $self->builtin }, |
32
|
193
|
|
|
|
|
233
|
%{ $self->registered }, |
|
193
|
|
|
|
|
376
|
|
33
|
|
|
|
|
|
|
); |
34
|
193
|
|
|
|
|
1356
|
\%s; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub for { |
38
|
66
|
|
|
66
|
1
|
353
|
my ($self, $format) = @_; |
39
|
66
|
|
|
|
|
172
|
$self->all->{$format}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub media_types_map_flat_hash { |
43
|
71
|
|
|
71
|
1
|
423
|
my $self = shift; |
44
|
71
|
|
|
|
|
127
|
my $s = $self->all; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my %media_types_map = map { |
47
|
71
|
|
|
|
|
173
|
Plack::Util::load_class($s->{$_}); |
|
217
|
|
|
|
|
530
|
|
48
|
217
|
|
|
|
|
2381
|
$_ => $s->{$_}->detectable_by; |
49
|
|
|
|
|
|
|
} keys %$s; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my %media_types_map_flat_hash = map { |
52
|
71
|
|
|
|
|
190
|
my $k = $_; map { $_ => $k } @{ $media_types_map{$k} } |
|
217
|
|
|
|
|
255
|
|
|
217
|
|
|
|
|
212
|
|
|
789
|
|
|
|
|
1424
|
|
|
217
|
|
|
|
|
298
|
|
53
|
|
|
|
|
|
|
} keys %media_types_map; |
54
|
|
|
|
|
|
|
|
55
|
71
|
|
|
|
|
549
|
%media_types_map_flat_hash; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |