line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Bubblegum Wrapper around Content Encoding |
2
|
|
|
|
|
|
|
package Bubblegum::Wrapper::Encoder; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
2395
|
use 5.10.0; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
159
|
|
5
|
4
|
|
|
4
|
|
468
|
use namespace::autoclean; |
|
4
|
|
|
|
|
14467
|
|
|
4
|
|
|
|
|
28
|
|
6
|
4
|
|
|
4
|
|
589
|
use Bubblegum::Class; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
21
|
|
7
|
4
|
|
|
4
|
|
3376
|
use Bubblegum::Exception; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
130
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
19
|
use Encode 'find_encoding'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
1405
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'Bubblegum::Object::Instance'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.45'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub BUILD { |
16
|
4
|
|
|
4
|
0
|
6710
|
my $self = shift; |
17
|
4
|
50
|
|
|
|
79
|
$self->data->typeof('str') |
18
|
|
|
|
|
|
|
or Bubblegum::Exception->throw( |
19
|
|
|
|
|
|
|
verbose => 1, |
20
|
|
|
|
|
|
|
message => ref($self)->format( |
21
|
|
|
|
|
|
|
'Wrapper package "%s" requires string data' |
22
|
|
|
|
|
|
|
), |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub decode { |
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
28
|
0
|
|
0
|
|
|
|
my $type = shift // 'utf-8'; |
29
|
0
|
|
|
|
|
|
my $decoder = find_encoding $type; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
return undef unless $decoder; |
32
|
0
|
|
|
|
|
|
return $decoder->decode($self->data); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub encode { |
36
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
37
|
0
|
|
0
|
|
|
|
my $type = shift // 'utf-8'; |
38
|
0
|
|
|
|
|
|
my $encoder = find_encoding $type; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
return undef unless $encoder; |
41
|
0
|
|
|
|
|
|
return $encoder->encode($self->data); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |