line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Marvel::Config; |
2
|
3
|
|
|
3
|
|
32241
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
133
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
90
|
|
4
|
3
|
|
|
3
|
|
14
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
970
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# my $cfg = WWW::Marvel::Config->new({ |
7
|
|
|
|
|
|
|
# private_key => 'a1b2', |
8
|
|
|
|
|
|
|
# public_key => 'c3d4', |
9
|
|
|
|
|
|
|
# }); |
10
|
|
|
|
|
|
|
# $cfg->get_private_key(); # a1b2 |
11
|
|
|
|
|
|
|
# $cfg->get_public_key(); # c3d4 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @KEYS = (qw/ private_key public_key /); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
2
|
|
|
2
|
0
|
282
|
my ($class, $args) = @_; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
5
|
my $self = bless {}, $class; |
19
|
2
|
|
|
|
|
6
|
$self->_set_keys($args); |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
253
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
0
|
688
|
sub get_private_key { shift->_get_auth_key('private_key') } |
25
|
3
|
|
|
3
|
0
|
69
|
sub get_public_key { shift->_get_auth_key('public_key') } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _get_auth_key { |
28
|
6
|
|
|
6
|
|
11
|
my ($self, $name) = @_; |
29
|
6
|
100
|
|
|
|
40
|
croak "Unknown '$name' key" if !exists $self->{ $name }; |
30
|
4
|
|
|
|
|
22
|
$self->{ $name }; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _set_keys { |
34
|
3
|
|
|
3
|
|
6
|
my ($self, $hash) = @_; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
8
|
for my $k (@KEYS) { |
37
|
6
|
100
|
50
|
|
|
323
|
carp "no '$k' specified in config" and next if !exists $hash->{ $k }; |
38
|
4
|
|
|
|
|
17
|
$self->{ $k } = $hash->{ $k }; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |