line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PerlWatcher::Util::Bootstrap; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$App::PerlWatcher::Util::Bootstrap::VERSION = '0.20'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Collection of various helper-methods to boostrap PerlWatcher |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
54030
|
use 5.12.0; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
237
|
|
8
|
5
|
|
|
5
|
|
36
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
190
|
|
9
|
5
|
|
|
5
|
|
33
|
use warnings; |
|
5
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
160
|
|
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
26
|
use Carp; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
382
|
|
12
|
5
|
|
|
5
|
|
70282
|
use Class::Load ':all'; |
|
5
|
|
|
|
|
35977
|
|
|
5
|
|
|
|
|
1132
|
|
13
|
5
|
|
|
5
|
|
5412
|
use File::Copy; |
|
5
|
|
|
|
|
13794
|
|
|
5
|
|
|
|
|
330
|
|
14
|
5
|
|
|
5
|
|
13719
|
use File::ShareDir::ProjectDistDir ':all'; |
|
5
|
|
|
|
|
132148
|
|
|
5
|
|
|
|
|
44
|
|
15
|
5
|
|
|
5
|
|
3074
|
use File::Spec; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
108
|
|
16
|
5
|
|
|
5
|
|
22532
|
use Path::Tiny; |
|
5
|
|
|
|
|
34747
|
|
|
5
|
|
|
|
|
323
|
|
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
43
|
use parent qw/Exporter/; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
42
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw/engine_config get_home_file get_home_dir config/; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub engine_config { |
24
|
1
|
|
33
|
1
|
1
|
4192
|
my $config_file = $ARGV[0] |
25
|
|
|
|
|
|
|
// get_home_file('engine.conf', |
26
|
|
|
|
|
|
|
'App-PerlWatcher-Engine', 'examples/engine.conf.example'); |
27
|
1
|
|
|
|
|
7
|
return config($config_file); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub config { |
32
|
2
|
|
|
2
|
1
|
1148
|
my ($file) = @_; |
33
|
2
|
|
|
|
|
13
|
my $content_config = path($file)->slurp_utf8; |
34
|
2
|
|
|
2
|
|
19
|
my $config = eval "no warnings; $content_config "; |
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
|
|
96
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
4266
|
|
35
|
2
|
50
|
|
|
|
16
|
croak("error in config: $@") if $@ ; |
36
|
2
|
|
|
|
|
11
|
return $config; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_home_file { |
41
|
1
|
|
|
1
|
1
|
101
|
my ($file, $package, $package_example) = @_; |
42
|
1
|
|
|
|
|
6
|
my $config_file = File::Spec->catfile(get_home_dir(), $file); |
43
|
1
|
50
|
|
|
|
47
|
if (not -e $config_file) { |
44
|
1
|
|
|
|
|
7
|
my $example = dist_file($package, $package_example); |
45
|
1
|
|
|
|
|
177048
|
copy($example, $config_file); |
46
|
|
|
|
|
|
|
} |
47
|
1
|
|
|
|
|
578
|
return $config_file; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_home_dir { |
52
|
11
|
|
|
11
|
1
|
312
|
my $home = path(File::Spec->catfile($ENV{'HOME'}, '.perl-watcher')); |
53
|
11
|
100
|
|
|
|
769
|
if ( not-X $home ) { |
54
|
5
|
50
|
|
|
|
780
|
mkdir $home or croak("can't create $home : $!"); |
55
|
|
|
|
|
|
|
} |
56
|
11
|
|
|
|
|
1003
|
return $home; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |