line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SmokeRunner::Multi::Config; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Config information for a Smokerunner::Multi setup |
4
|
|
|
|
|
|
|
$SmokeRunner::Multi::Config::VERSION = '0.21'; |
5
|
9
|
|
|
9
|
|
52203
|
use strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
243
|
|
6
|
9
|
|
|
9
|
|
47
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
278
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
7489
|
use Moo; |
|
9
|
|
|
|
|
127924
|
|
|
9
|
|
|
|
|
55
|
|
9
|
|
|
|
|
|
|
with 'MooX::Singleton'; |
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
9
|
|
16454
|
use File::Spec; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
219
|
|
12
|
9
|
|
|
9
|
|
7287
|
use File::HomeDir; |
|
9
|
|
|
|
|
51009
|
|
|
9
|
|
|
|
|
541
|
|
13
|
9
|
|
|
9
|
|
5236
|
use YAML::Syck qw( LoadFile ); |
|
9
|
|
|
|
|
14197
|
|
|
9
|
|
|
|
|
4374
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has config => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $file = $self->_FindConfigFile; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $cfg = LoadFile($file); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
die "Config in $file for the smoke-runner was not valid.\n" |
25
|
|
|
|
|
|
|
unless $cfg && $cfg->{root}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return $cfg; |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _FindConfigFile |
32
|
|
|
|
|
|
|
{ |
33
|
13
|
|
|
13
|
|
31
|
my $class = shift; |
34
|
|
|
|
|
|
|
|
35
|
13
|
|
|
|
|
60
|
my @files = ( |
36
|
|
|
|
|
|
|
$class->_config_from_env, |
37
|
|
|
|
|
|
|
$class->_config_from_home, |
38
|
|
|
|
|
|
|
$class->_config_from_system, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
13
|
|
|
|
|
48
|
for my $file (@files) |
42
|
|
|
|
|
|
|
{ |
43
|
14
|
100
|
66
|
|
|
609
|
return $file if -f $file && -r _; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
27
|
die "Cannot find a config file for the smoke-runner. Looked in [@files].\n"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _config_from_env { |
50
|
13
|
100
|
|
13
|
|
133
|
return $ENV{SMOKERUNNER_CONFIG} if $ENV{SMOKERUNNER_CONFIG}; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
5
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _config_from_home { |
56
|
9
|
|
|
9
|
|
121
|
return File::Spec->catfile( File::HomeDir->my_home , '.smokerunner', |
57
|
|
|
|
|
|
|
'smokerunner.conf' ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
13
|
|
|
13
|
|
564
|
sub _config_from_system { return '/etc/smokerunner/smokerunner.conf' } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has root_dir => ( |
63
|
|
|
|
|
|
|
is => 'ro', |
64
|
|
|
|
|
|
|
lazy => 1, |
65
|
|
|
|
|
|
|
default => sub { $_[0]->config->{root} }, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has runner => ( |
69
|
|
|
|
|
|
|
is => 'ro', |
70
|
|
|
|
|
|
|
lazy => 1, |
71
|
|
|
|
|
|
|
default => sub { $_[0]->config->{runner} }, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has smolder => ( |
75
|
|
|
|
|
|
|
is => 'ro', |
76
|
|
|
|
|
|
|
lazy => 1, |
77
|
|
|
|
|
|
|
default => sub { $_[0]->config->{smolder} || {} }, |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has reporter => ( |
81
|
|
|
|
|
|
|
is => 'ro', |
82
|
|
|
|
|
|
|
lazy => 1, |
83
|
|
|
|
|
|
|
default => sub { $_[0]->config->{reporter} }, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |