line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::DuckPAN::Config; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DDG'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Configuration class of the duckpan client |
4
|
|
|
|
|
|
|
$App::DuckPAN::Config::VERSION = '1019'; |
5
|
5
|
|
|
5
|
|
36
|
use Moo; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
29
|
|
6
|
5
|
|
|
5
|
|
3626
|
use File::HomeDir; |
|
5
|
|
|
|
|
20254
|
|
|
5
|
|
|
|
|
253
|
|
7
|
5
|
|
|
5
|
|
651
|
use Path::Tiny; |
|
5
|
|
|
|
|
7956
|
|
|
5
|
|
|
|
|
208
|
|
8
|
5
|
|
|
5
|
|
2001
|
use Config::INI::Reader; |
|
5
|
|
|
|
|
52361
|
|
|
5
|
|
|
|
|
157
|
|
9
|
5
|
|
|
5
|
|
2015
|
use Config::INI::Writer; |
|
5
|
|
|
|
|
15359
|
|
|
5
|
|
|
|
|
1089
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has config_path => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
lazy => 1, |
14
|
|
|
|
|
|
|
default => sub { _path_for('config') }, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
has config_file => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
default => sub { shift->config_path->child('config.ini') }, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
has cache_path => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
lazy => 1, |
24
|
|
|
|
|
|
|
default => sub { _path_for('cache') }, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _path_for { |
28
|
2
|
|
|
2
|
|
9
|
my $which = shift; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
16
|
my $from_env = $ENV{'DUCKPAN_' . uc $which . '_PATH'}; |
31
|
2
|
50
|
|
|
|
37
|
my $path = ($from_env) ? path($from_env) : path(File::HomeDir->my_home, '.duckpan', lc $which); |
32
|
2
|
100
|
|
|
|
318
|
$path->mkpath unless $path->exists; |
33
|
2
|
|
|
|
|
647
|
return $path; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub set_config { |
37
|
0
|
|
|
0
|
0
|
|
my ( $self, $config ) = @_; |
38
|
0
|
|
|
|
|
|
Config::INI::Writer->write_file($config,$self->config_file); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_config { |
42
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
43
|
0
|
0
|
|
|
|
|
return unless $self->config_file->is_file; |
44
|
0
|
|
|
|
|
|
Config::INI::Reader->read_file($self->config_file); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
App::DuckPAN::Config - Configuration class of the duckpan client |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 VERSION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
version 1019 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 AUTHOR |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
DuckDuckGo <open@duckduckgo.com>, Zach Thompson <zach@duckduckgo.com>, Zaahir Moolla <moollaza@duckduckgo.com>, Torsten Raudssus <torsten@raudss.us> L<https://raudss.us/> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by DuckDuckGo, Inc. L<https://duckduckgo.com/>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is free software, licensed under: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |