line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Code::Statistics::Config; |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Code::Statistics::Config::VERSION = '1.112980'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: merges configuration options from various sources |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
910
|
use Moose; |
|
1
|
|
|
|
|
591406
|
|
|
1
|
|
|
|
|
8
|
|
12
|
1
|
|
|
1
|
|
8755
|
use MooseX::HasDefaults::RO; |
|
1
|
|
|
|
|
13463
|
|
|
1
|
|
|
|
|
8
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
10528
|
use Hash::Merge qw( merge ); |
|
1
|
|
|
|
|
2626
|
|
|
1
|
|
|
|
|
67
|
|
15
|
1
|
|
|
1
|
|
835
|
use Config::INI::Reader; |
|
1
|
|
|
|
|
37287
|
|
|
1
|
|
|
|
|
59
|
|
16
|
1
|
|
|
1
|
|
958
|
use Path::Class qw(file); |
|
1
|
|
|
|
|
45425
|
|
|
1
|
|
|
|
|
159
|
|
17
|
1
|
|
|
1
|
|
2281
|
use File::HomeDir; |
|
1
|
|
|
|
|
7102
|
|
|
1
|
|
|
|
|
614
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has args => ( isa => 'HashRef', default => sub {{}} ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has command => ( isa => 'Str', ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has conf_file => ( isa => 'Str', default => '.codestatrc' ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has global_conf_file => ( isa => 'Str', default => sub { file( File::HomeDir->my_home, '.codestatrc' )->stringify } ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has profile => ( isa => 'Str', ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub assemble { |
31
|
6
|
|
|
6
|
1
|
24623
|
my ( $self ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
17
|
my $config = {}; |
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
30
|
$config = merge( $self->_global_config, $config ); |
36
|
6
|
|
|
|
|
27914
|
$config = merge( $self->_local_config, $config ); |
37
|
6
|
|
|
|
|
20228
|
$config = merge( $self->args, $config ); |
38
|
|
|
|
|
|
|
|
39
|
6
|
|
|
|
|
21626
|
return $config; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _local_config { |
43
|
6
|
|
|
6
|
|
27
|
my ( $self ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
295
|
return $self->_merged_conf_from( $self->conf_file ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _global_config { |
49
|
6
|
|
|
6
|
|
16
|
my ( $self ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
201
|
return $self->_merged_conf_from( $self->global_conf_file ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _merged_conf_from { |
55
|
12
|
|
|
12
|
|
30
|
my ( $self, $file ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
12
|
100
|
66
|
|
|
393
|
return {} if !$file or !-e $file; |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
|
|
81
|
my $conf = Config::INI::Reader->read_file( $file ); |
60
|
|
|
|
|
|
|
|
61
|
7
|
|
|
|
|
11713
|
my $merge; |
62
|
7
|
|
|
|
|
237
|
my @sections = grep { defined } ( '_', $self->command, $self->_profile_section ); |
|
21
|
|
|
|
|
140
|
|
63
|
7
|
|
|
|
|
26
|
for ( @sections ) { |
64
|
21
|
100
|
|
|
|
30287
|
next if !$conf->{$_}; |
65
|
15
|
|
|
|
|
58
|
$merge = merge( $conf->{$_}, $merge ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
7
|
|
|
|
|
20263
|
return $merge; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _profile_section { |
72
|
7
|
|
|
7
|
|
13
|
my ( $self ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
7
|
|
|
|
|
229
|
my $section = $self->command; |
75
|
7
|
100
|
|
|
|
225
|
$section .= '::' . $self->profile if $self->profile; |
76
|
|
|
|
|
|
|
|
77
|
7
|
|
|
|
|
23
|
return $section; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Code::Statistics::Config - merges configuration options from various sources |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
version 1.112980 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 assemble |
94
|
|
|
|
|
|
|
Builds the command-related configuration hash. The hash contains all config |
95
|
|
|
|
|
|
|
options from the global config file, local file and command line arguments. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Christian Walde <mithaldu@yahoo.de> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This software is Copyright (c) 2010 by Christian Walde. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This is free software, licensed under: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE, Version 2, December 2004 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|