line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::PP; |
2
|
2
|
|
|
2
|
|
852
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
76
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
187
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1711
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
649
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
our @EXPORT = qw(config_get config_set); |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
2308
|
use Data::Dumper; |
|
2
|
|
|
|
|
23599
|
|
|
2
|
|
|
|
|
165
|
|
9
|
2
|
|
|
2
|
|
21
|
use File::Spec; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
51
|
|
10
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
879
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
13
|
|
|
|
|
|
|
our $DIR = File::Spec->catfile($ENV{HOME}, '.ppconfig'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# path: $DIR/${namespace}.pl |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub config_get ($) { |
18
|
1
|
|
|
1
|
1
|
7
|
my $namespace = shift; |
19
|
1
|
|
|
|
|
5
|
my $path = path($namespace); |
20
|
1
|
|
|
|
|
13
|
local $@; |
21
|
1
|
|
33
|
|
|
467
|
return (do $path or Carp::croak "$!$@" ? "$!$@: $path" : "Can't find config: $path"); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub config_set ($$) { |
25
|
1
|
|
|
1
|
1
|
180
|
my ($namespace, $data) = @_; |
26
|
1
|
|
|
|
|
5
|
my $path = path($namespace); |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
161
|
open my $fh, ">", $path or Carp::croak "$!: $path"; |
29
|
1
|
|
|
|
|
3
|
print {$fh} Dumper($data); |
|
1
|
|
|
|
|
9
|
|
30
|
1
|
50
|
|
|
|
245
|
close $fh or Carp::croak $!; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub path { |
34
|
2
|
|
|
2
|
0
|
3
|
my $namespace = shift; |
35
|
|
|
|
|
|
|
|
36
|
2
|
50
|
|
|
|
40
|
unless (-d $DIR) { |
37
|
0
|
0
|
|
|
|
0
|
mkdir $DIR, 0700 or Carp::croak "Can't mkdir: $DIR"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
41
|
File::Spec->catfile($DIR, "${namespace}.pl"); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |