Command/webverify.pm

filter: Statementstmt 26.3% 10 / 38 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 1 totaltotal 15.5% 12 / 77 CC 15 SCAR 53.0
CC
15
Cov
15%
run
240.0
__ANON__
1.1
BEGIN
1.0
CRAP 200.2
« Command/query.pm ↑ Summary Commands.pm »
1 package PMLTQ::Command::webverify;
2 1 our $AUTHORITY = 'cpan:MATY';
3 1 $PMLTQ::Command::webverify::VERSION = '2.0.3';
4 # ABSTRACT: Check if treebank is setted in web interface
5  
6 1 ▶use PMLTQ::Base 'PMLTQ::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Path qw( make_path );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶has usage => sub { shift->extract_usage };
Subroutine __ANON__: not called CC=1 SCAR=1.2
10  
11 0 ▶sub run {
Subroutine run: not called CC=15 SCAR=54.8
Pod undocumented
12 0 my $self = shift;
13 0 my $ua = $self->ua;
14 0 $self->login($ua);
15  
16 0 my $json = JSON->new;
17 0 my $treebank = $self->get_treebank($ua);
18 0 ▶ if($treebank) {
Branch: 1 branch
BranchTrueFalseTotal
if ($treebank) { } 0 0 0
19 0 print $json->pretty->encode($treebank);
20 0 ▶ if (my $test_query = $self->config->{test_query}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $test_query = $self->config->{"test_query"}) 0 0 0
21 0 ▶ if($test_query->{result_dir} && not(-d $test_query->{result_dir})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($test_query->{"result_dir"} and not -d $test_query->{"result_dir"}) 0 0 0
Condition0%0/3
$test_query->{"result_dir"} and not -d $test_query->{"result_dir"}
!ll&&!rl&&r
000
MC/DC0%0/2
$test_query->{"result_dir"} and not -d $test_query->{"result_dir"}
$test_query->{"result_dir"} not -d $test_query->{"result_dir"}
Truth table0%0/3
A and not(B)
A= $test_query->{"result_dir"}B= not -d $test_query->{"result_dir"}
ABresult
0X0
100
111
22 0 ▶ make_path($test_query->{result_dir}) or die "Unable to create directory ".$test_query->{result_dir}."\n" ;
Branch: 1 branch
BranchTrueFalseTotal
make_path($test_query->{"result_dir"}) or die 'Unable to create directory ' . $test_query->{"result_dir"} . "\n" 0 0 0
23 }
24 0 my $i=0;
25 0 ▶ for my $query (@{$test_query->{queries} // []}) {
Condition0%0/2
$test_query->{"queries"} // []
l!l
00
MC/DC0%0/1
$test_query->{"queries"} // []
$test_query->{"queries"}
Truth table0%0/2
A
A= $test_query->{"queries"}
Aresult
11
00
26 0 my $text = $query->{query};
27 0 ▶ my $filename = File::Spec->catfile($test_query->{result_dir} // '.', $query->{filename} // $i);
Condition0%0/5
$test_query->{"result_dir"} // "."
l!l
00
$query->{"filename"} // $i
l!l&&r!l&&!r
000
MC/DC0%0/1
$test_query->{"result_dir"} // "."
$test_query->{"result_dir"}
MC/DC0%0/2
$query->{"filename"} // $i
$query->{"filename"} $i
Truth table0%0/2
A
A= $test_query->{"result_dir"}
Aresult
11
00
Truth table0%0/3
A // B
A= $query->{"filename"}B= $i
ABresult
1X1
011
000
28 0 ▶ unless($text) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($text) 0 0 0
29 0 print STDERR "Error in config file: Empty query\n";
30 0 next;
31 }
32 0 my $result = $self->evaluate_query($treebank->{id},$text);
33 0 ▶ if($result =~ m!</svg>!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result =~ m[</svg>]) 0 0 0
34 0 ▶ print STDERR "There is no text field in SVG result $filename ('$text') => check print server log (wrong styles?)\n" unless $result =~ m!</text>!;
Branch: 1 branch
BranchTrueFalseTotal
unless $result =~ m[</text>] 0 0 0
35 0 ▶ print STDERR "There is no node field in SVG result $filename ('$text') => check print server log (wrong file path?)\n" unless $result =~ m!<ellipse!;
Branch: 1 branch
BranchTrueFalseTotal
unless $result =~ /<ellipse/ 0 0 0
36 }
37  
38 0 ▶ open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $filename or die "Could not open file '${filename}' $!" 0 0 0
39 0 print $fh $result;
40 0 close $fh;
41 0 $i++;
42 }
43 }
44 } else {
45 0 print STDERR "Unknown treebank\n";
46 }
47 }
48  
49 =head1 SYNOPSIS
50  
51 pmltq webverify <treebank_config>
52  
53 =head1 DESCRIPTION
54  
55 Check if treebank is setted in web interface.
56  
57 =head1 OPTIONS
58  
59 =head1 PARAMS
60  
61 =over 5
62  
63 =item B<treebank_config>
64  
65 Path to configuration file. If a treebank_config is --, config is readed from STDIN.
66  
67 =back
68  
69 =cut
70  
71 1 1;
« Command/query.pm ↑ Summary Commands.pm »