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.002001'; |
4
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
94
|
|
5
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1130
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
24742
|
|
|
24742
|
1
|
77285
|
my ($class, $args, %opts) = @_; |
10
|
24742
|
|
33
|
|
|
95871
|
$class = ref($class) || $class; |
11
|
24742
|
|
|
|
|
87998
|
my $self = {args => $args, options => \%opts, method => $opts{transform}}; |
12
|
24742
|
|
|
|
|
52733
|
bless $self, $class; |
13
|
24742
|
|
|
|
|
99164
|
$self->{m_process} = $self->can($opts{transform}); |
14
|
24742
|
|
|
|
|
98357
|
$self->{m_final} = $self->can("$opts{transform}_final"); |
15
|
24742
|
|
|
|
|
81378
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub metadata { |
20
|
54
|
|
|
54
|
1
|
106
|
my ($class) = @_; |
21
|
54
|
|
33
|
|
|
233
|
my $name = lc(ref $class || $class); |
22
|
54
|
|
|
|
|
238
|
$name =~ s/^.*:://; |
23
|
54
|
|
|
|
|
200
|
return {name => $name}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub process { |
28
|
98330
|
|
|
98330
|
1
|
182524
|
my ($self, $data) = @_; |
29
|
98330
|
|
|
|
|
170379
|
my $func = $self->{m_process}; |
30
|
98330
|
|
|
|
|
240722
|
return $self->$func($data); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub final { |
35
|
24742
|
|
|
24742
|
1
|
50613
|
my ($self, $data) = @_; |
36
|
24742
|
|
|
|
|
48068
|
my $func = $self->{m_final}; |
37
|
24742
|
|
|
|
|
65635
|
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.002001 |
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 |