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