line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::From; |
2
|
|
|
|
|
|
|
$Config::From::VERSION = '0.05'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
22264
|
use utf8; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
8
|
|
5
|
2
|
|
|
2
|
|
1206
|
use Moose; |
|
2
|
|
|
|
|
811065
|
|
|
2
|
|
|
|
|
16
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14457
|
use Moose::Util::TypeConstraints; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
24
|
|
8
|
2
|
|
|
2
|
|
4554
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
147
|
|
9
|
2
|
|
|
2
|
|
1881
|
use Module::Load; |
|
2
|
|
|
|
|
2894
|
|
|
2
|
|
|
|
|
18
|
|
10
|
2
|
|
|
2
|
|
1747
|
use Hash::Merge qw( merge ); |
|
2
|
|
|
|
|
6716
|
|
|
2
|
|
|
|
|
897
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'debug' => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has config => ( |
19
|
|
|
|
|
|
|
isa => "HashRef", |
20
|
|
|
|
|
|
|
is => "rw", |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has backends => ( |
24
|
|
|
|
|
|
|
isa => "ArrayRef", |
25
|
|
|
|
|
|
|
is => "rw", |
26
|
|
|
|
|
|
|
default => sub {[]}, |
27
|
|
|
|
|
|
|
trigger => sub { |
28
|
|
|
|
|
|
|
shift->_build_config; |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_config { |
34
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
4
|
$self->_log("build config ..."); |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
1
|
my $config = {}; |
39
|
1
|
|
|
|
|
2
|
foreach my $backend ( @{$self->backends }) { |
|
1
|
|
|
|
|
22
|
|
40
|
2
|
|
33
|
|
|
3354
|
$self->_log("merge config " . ($backend->name || ref($backend))); |
41
|
2
|
|
|
|
|
52
|
$config = merge( $config, $backend->datas ); |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
|
|
405
|
$self->config($config); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# XXX: => role |
47
|
|
|
|
|
|
|
sub _log{ |
48
|
3
|
|
|
3
|
|
5
|
my ($self, $msg ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
3
|
50
|
|
|
|
70
|
return if ! $self->debug; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
say STDERR "[debug] $msg"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Config::From - Merge the configuration from several sources |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 0.05 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use Config::From; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $bckfile = Config::From::Backend::File->new(file => 't/conf/file1.yml'); |
71
|
|
|
|
|
|
|
my $bckdbix = Config::From::Backend::DBIx->new(schema => $schema, table => 'Config'); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $config = Config::From->new( backends => [ $bckfile, $bckdbix] )->config; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Daniel Brosseau, C<< <dab at catapulse.org> >> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 BUGS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-config-ordered at rt.cpan.org>, or through |
87
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-From>. I will be notified, and then you'll |
88
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SUPPORT |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
perldoc Config::From |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
You can also look for information at: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Config-From> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Config-From> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * CPAN Ratings |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Config-From> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * Search CPAN |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Config-From/> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright 2015 Daniel Brosseau. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
131
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
132
|
|
|
|
|
|
|
copy of the full license at: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
137
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
138
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
139
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
142
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
143
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
146
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
149
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
150
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
151
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
152
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
153
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
154
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
155
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
158
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
159
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
160
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
161
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
162
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
163
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
164
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; # End of Config::From |