Command/load.pm

filter: Statementstmt 25.9% 7 / 27 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 1 / 3 Podpod 0.0% 0 / 1 totaltotal 20.5% 8 / 39 CC 7 SCAR 37.8
CC
7
Cov
20%
run
56.0
__ANON__
1.1
BEGIN
1.0
CRAP 43.8
« Command/webtreebank.pm ↑ Summary Command.pm »
1 package PMLTQ::Command::load;
2 1 our $AUTHORITY = 'cpan:MATY';
3 1 $PMLTQ::Command::load::VERSION = '2.0.3';
4 # ABSTRACT: Load treebank to database
5  
6 1 ▶use PMLTQ::Base 'PMLTQ::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶has usage => sub { shift->extract_usage };
Subroutine __ANON__: not called CC=1 SCAR=1.2
9  
10 0 ▶sub run {
Subroutine run: not called CC=7 SCAR=40.3
Pod undocumented
11 0 my $self = shift;
12  
13 0 my $config = $self->config;
14 0 my $output_dir = $self->config->{output_dir};
15  
16 0 ▶ unless ( -d $output_dir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $output_dir) 0 0 0
17 0 die <<"MSG";
18 Output directory $output_dir does not exist.
19  
20 Maybe you need to run 'pmltq convert' first.
21  
22 MSG
23 }
24  
25 0 my $dbh;
26 0 eval { $dbh = $self->db };
27 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
28 0 die <<"MSG";
29 $@
30 Maybe you need to run 'pmltq initdb' first.
31  
32 MSG
33 }
34  
35 0 for my $layer ( @{ $config->{layers} } ) {
36 0 my $listfile = File::Spec->catfile( $output_dir, "$layer->{name}__init.list" );
37 0 ▶ open my $fh, '<', $listfile or die "Can't open $listfile: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $listfile or die "Can't open ${listfile}: $!" 0 0 0
38 0 for my $file (<$fh>) {
39 0 $file =~ s/\n$//;
40 0 ▶ next unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 0 0
41 0 $self->run_sql_from_file( $file, $output_dir, $dbh );
42 }
43 ###$dbh->do($sql);
44 }
45 0 $dbh->disconnect;
46 }
47  
48 =encoding utf8
49  
50 =head1 SYNOPSIS
51  
52 pmltq load <treebank_config> <sql_dir>
53  
54 =head1 DESCRIPTION
55  
56 Load treebank to database
57  
58 =head1 OPTIONS
59  
60 =head1 PARAMS
61  
62 =over 5
63  
64 =item B<treebank_config>
65  
66 Path to configuration file. If a treebank_config is --, config is readed from STDIN.
67  
68 Path to input directory.
69  
70 =back
71  
72 =cut
73  
74 1 1;
« Command/webtreebank.pm ↑ Summary Command.pm »