line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Config-Model-Itself |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2007-2017 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Config::Model::Itself::BackendDetector ; |
11
|
|
|
|
|
|
|
$Config::Model::Itself::BackendDetector::VERSION = '2.011'; |
12
|
|
|
|
|
|
|
# since this package is mostly targeted for dev environments |
13
|
|
|
|
|
|
|
# let the detector detect models under development |
14
|
3
|
|
|
3
|
|
24498
|
use lib 'lib'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
22
|
|
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
341
|
use Pod::POM ; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
144
|
|
17
|
3
|
|
|
3
|
|
16
|
use File::Find ; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
150
|
|
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
16
|
use base qw/Config::Model::Value/ ; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
828
|
|
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
61023
|
use strict ; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
59
|
|
22
|
3
|
|
|
3
|
|
14
|
use warnings ; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1451
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub setup_enum_choice { |
25
|
13
|
|
|
13
|
0
|
446
|
my $self = shift ; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# using a hash to make sure that a backend is not listed twice. This may |
28
|
|
|
|
|
|
|
# happen in development environment where a backend in found in /usr/lib |
29
|
|
|
|
|
|
|
# and in ./lib (or ./blib) |
30
|
13
|
50
|
|
|
|
55
|
my %choices = map { ($_ => 1);} ref $_[0] ? @{$_[0]} : @_ ; |
|
40
|
|
|
|
|
129
|
|
|
13
|
|
|
|
|
52
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# find available backends in all @INC directories |
33
|
|
|
|
|
|
|
my $wanted = sub { |
34
|
104
|
|
|
104
|
|
238
|
my $n = $File::Find::name ; |
35
|
104
|
100
|
66
|
|
|
2658
|
if (-f $_ and $n =~ s/\.pm$// and $n !~ /Any$/) { |
|
|
|
100
|
|
|
|
|
36
|
78
|
|
|
|
|
363
|
$n =~ s!.*Backend/!! ; |
37
|
78
|
|
|
|
|
166
|
$n =~ s!/!::!g ; |
38
|
78
|
|
|
|
|
402
|
$choices{$n} = 1 ; |
39
|
|
|
|
|
|
|
} |
40
|
13
|
|
|
|
|
96
|
} ; |
41
|
|
|
|
|
|
|
|
42
|
13
|
|
|
|
|
58
|
foreach my $inc (@INC) { |
43
|
149
|
|
|
|
|
359
|
my $path = "$inc/Config/Model/Backend" ; |
44
|
149
|
100
|
|
|
|
2700
|
find ($wanted, $path ) if -d $path; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
13
|
|
|
|
|
190
|
$self->SUPER::setup_enum_choice(sort keys %choices) ; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub set_help { |
51
|
13
|
|
|
13
|
0
|
41600
|
my ($self,$args) = @_ ; |
52
|
|
|
|
|
|
|
|
53
|
13
|
|
50
|
|
|
65
|
my $help = delete $args->{help} || {} ; |
54
|
|
|
|
|
|
|
|
55
|
13
|
|
|
|
|
50
|
my $path = $INC{"Config/Model.pm"} ; |
56
|
13
|
|
|
|
|
75
|
$path =~ s!\.pm!/Backend! ; |
57
|
|
|
|
|
|
|
|
58
|
13
|
|
|
|
|
124
|
my $parser = Pod::POM->new(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $wanted = sub { |
61
|
104
|
|
|
104
|
|
217547
|
my $n = $File::Find::name ; |
62
|
|
|
|
|
|
|
|
63
|
104
|
100
|
100
|
|
|
5999
|
return unless (-f $n and $n !~ /Any\.pm$/) ; |
64
|
78
|
|
|
|
|
298
|
my $file = $n ; |
65
|
78
|
|
|
|
|
407
|
$n =~ s/\.pm$//; |
66
|
78
|
|
|
|
|
482
|
$n =~ s!/!::!g ; |
67
|
78
|
|
|
|
|
172
|
my $perl_name = $n ; |
68
|
78
|
|
|
|
|
319
|
$n =~ s!.*Backend::!! ; |
69
|
78
|
|
|
|
|
312
|
$perl_name =~ s!.*Config!Config! ; |
70
|
|
|
|
|
|
|
|
71
|
78
|
|
50
|
|
|
389
|
my $pom = $parser->parse_file($file)|| die $parser->error(); |
72
|
|
|
|
|
|
|
|
73
|
78
|
|
|
|
|
838043
|
foreach my $head1 ($pom->head1()) { |
74
|
78
|
50
|
|
|
|
1691
|
if ($head1->title() eq 'NAME') { |
75
|
78
|
|
|
|
|
5443
|
my $c = $head1->content(); |
76
|
78
|
|
|
|
|
1287
|
$c =~ s/.*?-\s*//; |
77
|
78
|
|
|
|
|
11559
|
$c =~ s/\n//g; |
78
|
78
|
|
|
|
|
418
|
$help->{$n} = $c . " provided by L<$perl_name>"; |
79
|
78
|
|
|
|
|
476
|
last; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
13
|
|
|
|
|
291
|
}; |
83
|
|
|
|
|
|
|
|
84
|
13
|
|
|
|
|
1528
|
find ($wanted, $path ) ; |
85
|
|
|
|
|
|
|
|
86
|
13
|
|
|
|
|
280
|
$self->{help} = $help; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# ABSTRACT: Detect available read/write backends usable by config models |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |