line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
48
|
use 5.008; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
77
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
105
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Class::Scaffold::Introspect; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
2
|
|
|
2
|
|
41
|
$Class::Scaffold::Introspect::VERSION = '1.102280'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Find configuration files within the framework |
10
|
2
|
|
|
2
|
|
727
|
use FindBin '$Bin'; |
|
2
|
|
|
|
|
1150
|
|
|
2
|
|
|
|
|
264
|
|
11
|
2
|
|
|
2
|
|
11
|
use Cwd; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
161
|
|
12
|
2
|
|
|
2
|
|
1781
|
use File::Spec::Functions qw/curdir updir rootdir rel2abs/; |
|
2
|
|
|
|
|
1690
|
|
|
2
|
|
|
|
|
161
|
|
13
|
2
|
|
|
2
|
|
11
|
use Sys::Hostname; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
101
|
|
14
|
2
|
|
|
2
|
|
12
|
use Exporter qw(import); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
949
|
|
15
|
|
|
|
|
|
|
our %EXPORT_TAGS = (conf => [qw/find_conf_file/],); |
16
|
|
|
|
|
|
|
our @EXPORT_OK = @{ $EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ] }; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub find_file_upwards { |
19
|
2
|
|
|
2
|
1
|
4
|
my $wanted_file = shift; |
20
|
2
|
|
|
|
|
12
|
my $previous_cwd = getcwd; |
21
|
2
|
|
|
|
|
3
|
my $result; # left undef as we'll return undef if we didn't find it |
22
|
2
|
|
|
|
|
8
|
while (rel2abs(curdir()) ne rootdir()) { |
23
|
4
|
100
|
|
|
|
148
|
if (-f $wanted_file) { |
24
|
2
|
|
|
|
|
8
|
$result = rel2abs(curdir()); |
25
|
2
|
|
|
|
|
34
|
last; |
26
|
|
|
|
|
|
|
} |
27
|
2
|
|
|
|
|
17
|
chdir(updir()); |
28
|
|
|
|
|
|
|
} |
29
|
2
|
|
|
|
|
29
|
chdir($previous_cwd); |
30
|
2
|
|
|
|
|
17
|
$result; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub find_conf_file { |
34
|
2
|
|
|
2
|
1
|
5
|
my $file = 'SMOKEconf.yaml'; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# the distribution root is where Build.PL is; start the search from where |
37
|
|
|
|
|
|
|
# the bin file was (presumably within the distro). This way we can say any |
38
|
|
|
|
|
|
|
# of: |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
# perl t/sometest.t |
41
|
|
|
|
|
|
|
# cd t; perl sometest.t |
42
|
|
|
|
|
|
|
# perl /abs/path/to/distro/t/sometest.t |
43
|
2
|
50
|
|
|
|
65
|
chdir($Bin) or die "can't chdir to [$Bin]: $!\n"; |
44
|
2
|
|
33
|
|
|
8
|
my $distro_root = find_file_upwards('Makefile.PL') |
45
|
|
|
|
|
|
|
|| find_file_upwards('dist.ini'); |
46
|
2
|
50
|
33
|
|
|
22
|
unless (defined $distro_root && length $distro_root) { |
47
|
0
|
|
|
|
|
0
|
warn "can't find distro root from [$Bin]\n"; |
48
|
0
|
0
|
|
|
|
0
|
warn "might not be able to find conf file using [$ENV{CF_CONF}]\n" |
49
|
|
|
|
|
|
|
if $ENV{CF_CONF} eq 'local'; |
50
|
0
|
|
|
|
|
0
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
2
|
|
|
|
|
5
|
my $etc = "$distro_root/etc"; |
53
|
2
|
50
|
|
|
|
58
|
return "$etc/$file" if -e "$etc/$file"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# warn "find_conf_file: not in [$etc/$file]"; |
56
|
0
|
|
|
|
|
|
(my $hostname = hostname) =~ s/\W.*//; |
57
|
0
|
|
|
|
|
|
my $dir = "$etc/$hostname"; |
58
|
0
|
0
|
0
|
|
|
|
return "$dir/$file" if -d $dir && -e "$dir/$file"; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# warn "find_conf_file: not in [$dir/$file]"; |
61
|
0
|
|
|
|
|
|
undef; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |