| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Muter::Backend; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: App::Muter::Backend - a backend for muter |
|
3
|
|
|
|
|
|
|
$App::Muter::Backend::VERSION = '0.003000'; |
|
4
|
4
|
|
|
4
|
|
23
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
102
|
|
|
5
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
1100
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
24274
|
|
|
24274
|
1
|
59071
|
my ($class, $args, %opts) = @_; |
|
10
|
24274
|
|
33
|
|
|
66830
|
$class = ref($class) || $class; |
|
11
|
24274
|
|
|
|
|
69804
|
my $self = {args => $args, options => \%opts, method => $opts{transform}}; |
|
12
|
24274
|
|
|
|
|
42059
|
bless $self, $class; |
|
13
|
24274
|
|
|
|
|
72984
|
$self->{m_process} = $self->can($opts{transform}); |
|
14
|
24274
|
|
|
|
|
76803
|
$self->{m_final} = $self->can("$opts{transform}_final"); |
|
15
|
24274
|
|
|
|
|
63140
|
return $self; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub metadata { |
|
20
|
58
|
|
|
58
|
1
|
94
|
my ($class) = @_; |
|
21
|
58
|
|
33
|
|
|
181
|
my $name = lc(ref $class || $class); |
|
22
|
58
|
|
|
|
|
229
|
$name =~ s/^.*:://; |
|
23
|
58
|
|
|
|
|
168
|
return {name => $name}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub process { |
|
28
|
96604
|
|
|
96604
|
1
|
137274
|
my ($self, $data) = @_; |
|
29
|
96604
|
|
|
|
|
123939
|
my $func = $self->{m_process}; |
|
30
|
96604
|
|
|
|
|
165790
|
return $self->$func($data); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub final { |
|
35
|
24274
|
|
|
24274
|
1
|
38587
|
my ($self, $data) = @_; |
|
36
|
24274
|
|
|
|
|
34529
|
my $func = $self->{m_final}; |
|
37
|
24274
|
|
|
|
|
47994
|
return $self->$func($data); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub decode { |
|
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
42
|
0
|
|
|
|
|
|
my $name = $self->metadata->{name}; |
|
43
|
0
|
|
|
|
|
|
die "The $name technique doesn't have an inverse transformation.\n"; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
App::Muter::Backend - App::Muter::Backend - a backend for muter |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
version 0.003000 |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 $class->new($args, %opts) |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Create a new backend. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$args is an arrayref of arguments provided to the chain. Currently only the |
|
69
|
|
|
|
|
|
|
first argument is considered, and it will typically be a variant of the main |
|
70
|
|
|
|
|
|
|
algorithm (e.g. I<lower> for lowercase). |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
%opts is a set of additional parameters. The I<transform> value is set to |
|
73
|
|
|
|
|
|
|
either I<encode> for encoding or I<decode> for decoding. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Returns the new object. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 $class->metadata |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Get metadata about this class. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns a hashref containing the metadata about this backend. The following |
|
82
|
|
|
|
|
|
|
keys are defined: |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item name |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The name of this backend. This should be a lowercase string and is the |
|
89
|
|
|
|
|
|
|
identifier used in the chain. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item args |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
A hashref mapping possible arguments to the transform to a human-readable |
|
94
|
|
|
|
|
|
|
description. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 $self->process($data) |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Process a chunk of data. Returns the processed chunk. Note that for buffering |
|
101
|
|
|
|
|
|
|
reasons, the data returned may be larger or smaller than the original data |
|
102
|
|
|
|
|
|
|
passed in. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 $self->final($data) |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Process the final chunk of data. Returns the processed chunk. Note that for |
|
107
|
|
|
|
|
|
|
buffering reasons, the data returned may be larger or smaller than the original |
|
108
|
|
|
|
|
|
|
data passed in. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Calling this function is obligatory. If all actual data has been passed to the |
|
111
|
|
|
|
|
|
|
process function, this function can simply be called with the empty string. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
brian m. carlson <sandals@crustytoothpaste.net> |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This software is Copyright (c) 2016â2017 by brian m. carlson. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is free software, licensed under: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The MIT (X11) License |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |