| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Datahub::Factory::Env; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use Datahub::Factory::Sane; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.77'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
483
|
use Config::Simple; |
|
|
1
|
|
|
|
|
7590
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
1
|
|
|
1
|
|
369
|
use Config::Onion; |
|
|
1
|
|
|
|
|
12950
|
|
|
|
1
|
|
|
|
|
30
|
|
|
9
|
1
|
|
|
1
|
|
346
|
use Datahub::Factory::Util qw(require_package); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
49
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
19
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
12
|
|
|
|
|
|
|
require Datahub::Factory; |
|
13
|
1
|
|
|
1
|
|
266
|
use namespace::clean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _search_up { |
|
16
|
0
|
|
|
0
|
|
|
my $dir = $_[0]; |
|
17
|
0
|
|
|
|
|
|
my @dirs = grep length, File::Spec->splitdir(Datahub::Factory->default_load_path); |
|
18
|
0
|
|
|
|
|
|
for (; @dirs; pop @dirs) { |
|
19
|
0
|
|
|
|
|
|
my $path = File::Spec->catdir(File::Spec->rootdir, @dirs); |
|
20
|
0
|
0
|
|
|
|
|
opendir my $dh, $path or last; |
|
21
|
|
|
|
|
|
|
return $path |
|
22
|
0
|
0
|
|
|
|
|
if grep {-r File::Spec->catfile($path, $_)} |
|
|
0
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
grep /^datahubfactory.+(?:yaml|yml|json|pl)$/, readdir $dh; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
0
|
|
|
|
|
|
Datahub::Factory->default_load_path; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has load_paths => ( |
|
29
|
|
|
|
|
|
|
is => 'ro', |
|
30
|
|
|
|
|
|
|
default => sub {[]}, |
|
31
|
|
|
|
|
|
|
coerce => sub { |
|
32
|
|
|
|
|
|
|
[ |
|
33
|
|
|
|
|
|
|
map {File::Spec->canonpath($_)} |
|
34
|
|
|
|
|
|
|
map {$_ eq ':up' ? _search_up($_) : $_} split /,/, |
|
35
|
|
|
|
|
|
|
join ',', |
|
36
|
|
|
|
|
|
|
ref $_[0] ? @{$_[0]} : $_[0] |
|
37
|
|
|
|
|
|
|
]; |
|
38
|
|
|
|
|
|
|
}, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has config => (is => 'rwp', default => sub {+{}}); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
with 'Datahub::Factory::Logger'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub BUILD { |
|
46
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my @config_dirs = @{$self->load_paths}; |
|
|
0
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if (@config_dirs) { |
|
51
|
|
|
|
|
|
|
my @globs = map { |
|
52
|
0
|
|
|
|
|
|
my $dir = $_; |
|
|
0
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
map {File::Spec->catfile($dir, "datahubfactory*.$_")} |
|
|
0
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
qw(yaml yml json pl) |
|
55
|
|
|
|
|
|
|
} reverse @config_dirs; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $config = Config::Onion->new(prefix_key => '_prefix'); |
|
58
|
0
|
|
|
|
|
|
$config->load_glob(@globs); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ($self->log->is_debug) { |
|
61
|
1
|
|
|
1
|
|
1271
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
5232
|
|
|
|
1
|
|
|
|
|
495
|
|
|
62
|
0
|
|
|
|
|
|
$self->log->debug(Dumper($config->get)); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
0
|
|
|
|
|
|
$self->_set_config($config->get); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub importer { |
|
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
|
my $name = shift; |
|
71
|
0
|
|
|
|
|
|
my $ns = "Datahub::Factory::Importer"; |
|
72
|
|
|
|
|
|
|
# If the "plugin" in [Importer] is empty, $name is an empty array |
|
73
|
0
|
0
|
0
|
|
|
|
if (!defined($name) || (ref $name eq 'ARRAY' && scalar @{$name} == 0)) { |
|
|
0
|
|
0
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
die 'Undefined value for plugin at [Importer]'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return require_package($name, $ns); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub fixer { |
|
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
82
|
0
|
|
|
|
|
|
my $name = shift; |
|
83
|
0
|
|
|
|
|
|
my $ns = "Datahub::Factory::Fixer"; |
|
84
|
|
|
|
|
|
|
# If the "plugin" in [Fixer] is empty, $name is an empty array |
|
85
|
0
|
0
|
0
|
|
|
|
if (!defined($name) || (ref $name eq 'ARRAY' && scalar @{$name} == 0)) { |
|
|
0
|
|
0
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
die 'Undefined value for plugin at [Fixer]'; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return require_package($name, $ns); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub exporter { |
|
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
94
|
0
|
|
|
|
|
|
my $name = shift; |
|
95
|
0
|
|
|
|
|
|
my $ns = "Datahub::Factory::Exporter"; |
|
96
|
|
|
|
|
|
|
# If the "plugin" in [Exporter] is empty, $name is an empty array |
|
97
|
0
|
0
|
0
|
|
|
|
if (!defined($name) || (ref $name eq 'ARRAY' && scalar @{$name} == 0)) { |
|
|
0
|
|
0
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
die 'Undefined value for plugin at [Exporter]'; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return require_package($name, $ns); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub indexer { |
|
105
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
106
|
0
|
|
|
|
|
|
my $name = shift; |
|
107
|
0
|
|
|
|
|
|
my $ns = "Datahub::Factory::Indexer"; |
|
108
|
|
|
|
|
|
|
# If the "plugin" in [Indexer] is empty, $name is an empty array |
|
109
|
0
|
0
|
0
|
|
|
|
if (!defined($name) || (ref $name eq 'ARRAY' && scalar @{$name} == 0)) { |
|
|
0
|
|
0
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
die 'Undefined value for plugin at [Indexer]'; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return require_package($name, $ns); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub pipeline { |
|
117
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
118
|
0
|
|
|
|
|
|
my $file_name = shift; |
|
119
|
0
|
|
|
|
|
|
my $pipeline = shift; |
|
120
|
|
|
|
|
|
|
# require_package('Pipeline', 'Datahub::Factory')->new({'file_name' => @_}); |
|
121
|
0
|
|
|
|
|
|
require_package($pipeline, 'Datahub::Factory::Pipeline')->new({'file_name' => $file_name}); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub module { |
|
125
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
126
|
0
|
|
|
|
|
|
my $name = shift; |
|
127
|
0
|
|
|
|
|
|
my $ns = "Datahub::Factory::Module"; |
|
128
|
0
|
|
|
|
|
|
return require_package($name, $ns); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 NAME |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Datahub::Factory::Env - A Datahub::Factory configuration file loader |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|