blib/lib/DDC/PP/CQueryOptions.pm

filter: Statementstmt 66.6% 44 / 66 Branchbran 55.8% 19 / 34 Conditioncond 44.0% 11 / 25 MC/DCmcdc 13.3% 2 / 15 Subroutinesub 70.5% 12 / 17 Podpod 0.0% 0 / 11 totaltotal 52.3% 88 / 168 CC 28 SCAR 26.9
CC
28
Cov
59%
toString
26.1
jsonData
22.5
Children
6.0
CRAP 14.7
« blib/lib/DDC/Any.pm ↑ Summary blib/lib/DDC/Format.pm »
1 ##-*- Mode: CPerl -*-
2  
3 ##======================================================================
4 ## top-level
5 package DDC::PP::CQueryOptions;
6 20 ▶use DDC::PP::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use DDC::PP::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 20 ▶use DDC::Utils qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 20 ▶use Carp qw(carp confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 ##======================================================================
13 ## CQueryOptions
14 package DDC::PP::CQueryOptions;
15 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 20 our @ISA = qw(DDC::PP::Object);
17  
18 __PACKAGE__->defprop($_)
19 20 foreach (qw(ContextSentencesCount EnableBibliography DebugRank SeparateHits Filters Subcorpora Comments LexerComments)); #Within
20 4 ▶sub getWithin { return $_[0]{Within}; }
Subroutine getWithin: called CC=1 SCAR=0.0
Pod undocumented
21 2 ▶sub setWithin { return $_[0]{Within} = UNIVERSAL::isa($_[1],'ARRAY') ? $_[1] : [$_[1]]; }
Subroutine setWithin: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[1], 'ARRAY') ? : 2 0 2
22 20 __PACKAGE__->defalias('ContextCount'=>'ContextSentencesCount',0,1);
23  
24 452 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
25 452 my ($that,%opts) = @_;
26 452 return $that->SUPER::new(EnableBibliography=>1,Filters=>[],Subcorpora=>[],Within=>[],Comments=>[],LexerComments=>[],%opts);
27 }
28  
29 0 ▶sub swap {
Subroutine swap: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my ($a,$b) = @_;
31 0 my %tmp = %$b;
32 0 %$b = %$a;
33 0 %$a = %tmp;
34 0 return $a;
35 }
36  
37 0 ▶sub Clear {
Subroutine Clear: not called CC=1 SCAR=6.9
Pod undocumented
38 0 @{$_[0]{Filters}} = @{$_[0]{Subcorpora}} = @{$_[0]{Comments}} = @{$_[0]{LexerComments}} = qw();
39 }
40 0 ▶sub ClearComments {
Subroutine ClearComments: not called CC=1 SCAR=6.9
Pod undocumented
41 0 @{$_[0]{Comments}} = @{$_[0]{LexerComments}} = qw();
42 }
43  
44 20 __PACKAGE__->nomethod('CanFilterByFile');
45  
46 0 ▶sub Children { return [ @{$_[0]{Filters}||[]} ]; }
Subroutine Children: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/2
$_[0]{'Filters'} || []
l!l
00
MC/DC0%0/1
$_[0]{'Filters'} || []
$_[0]{'Filters'}
Truth table0%0/2
A
A= $_[0]{'Filters'}
Aresult
11
00
47  
48 0 ▶sub sqString { return DDC::Utils::escapeq(defined($_[1]) ? $_[1] : ''); }
Subroutine sqString: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 0 0 0
49 2 ▶sub toString {
Subroutine toString: called CC=11 SCAR=32.6
Pod undocumented
50 2 my $qo = shift;
51 return (
52 0 ▶ ($qo->{Within} ? join('', map {" #WITHIN ".$qo->sqString($_)} @{$qo->{Within}}) : '')
Branch: 4 branches
BranchTrueFalseTotal
$qo->{'ContextSentencesCount'} ? : 0 2 2
$qo->{'SeparateHits'} ? : 0 2 2
!$qo->{'EnableBibliography'} ? : 0 2 2
$qo->{'DebugRank'} ? : 0 2 2
53 .($qo->{ContextSentencesCount} ? " #CNTXT $qo->{ContextSentencesCount}" : '')
54 .($qo->{SeparateHits} ? " #SEPARATE" : '')
55 .(!$qo->{EnableBibliography} ? " #FILENAMES" : '')
56 .($qo->{DebugRank} ? " #DEBUG_RANK" : '')
57 0 ▶ .join('', map {" ".$_->toString} @{$qo->{Filters}||[]})
Condition50%1/2
$qo->{'Filters'} || []
l!l
20
MC/DC0%0/1
$qo->{'Filters'} || []
$qo->{'Filters'}
Truth table50%1/2
A
A= $qo->{'Filters'}
Aresult
11
00
58 0 ▶ .join('', map {" #CMT ".$qo->sqString($_)} @{$qo->{Comments}||[]})
Condition50%1/2
$qo->{'Comments'} || []
l!l
20
MC/DC0%0/1
$qo->{'Comments'} || []
$qo->{'Comments'}
Truth table50%1/2
A
A= $qo->{'Comments'}
Aresult
11
00
59 0 ▶ .join('', map {" $_"} @{$qo->{LexerComments}//[]})
Branch: 1 branch
BranchTrueFalseTotal
$qo->{'Subcorpora'} && @{$qo->{'Subcorpora'};} ? : 0 2 2
Condition40%2/5
$qo->{"LexerComments"} // []
l!l
20
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
!ll&&!rl&&r
020
MC/DC0%0/1
$qo->{"LexerComments"} // []
$qo->{"LexerComments"}
MC/DC0%0/2
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
$qo->{"Subcorpora"} @{$qo->{"Subcorpora"};}
Truth table50%1/2
A
A= $qo->{"LexerComments"}
Aresult
11
00
Truth table33%1/3
A and B
A= $qo->{"Subcorpora"}B= @{$qo->{"Subcorpora"};}
ABresult
0X0
100
111
60 0 ▶ .($qo->{Subcorpora} && @{$qo->{Subcorpora}} ? (" :".join(',', map {$qo->sqString($_)} @{$qo->{Subcorpora}})) : '')
Branch: 1 branch
BranchTrueFalseTotal
$qo->{'Within'} ? : 2 0 2
61 );
62 }
63  
64 ##-- ddc-compatible hash-conversion (for toJson())
65 198 ▶sub toHash {
Subroutine toHash: called CC=2 SCAR=6.9
Pod undocumented
66 198 my ($obj,%opts) = @_;
67 198 ▶ return $obj->SUPER::toHash(%opts) if (!$opts{json});
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"json"} 2 196 198
68 196 return { class=>$obj->jsonClass, $obj->jsonData };
69 }
70 196 ▶sub jsonData {
Subroutine jsonData: called CC=14 SCAR=31.1
Pod undocumented
71 196 my $qo = shift;
72 return (($qo->{Within} && $qo->{Within} ? (Within=>$qo->{Within}) : qw()),
73 ($qo->{ContextSentencesCount} ? (ContextCount=>$qo->{ContextSentencesCount}) : qw()),
74 ($qo->{SeparateHits} ? (SeparateHits=>$qo->{SeparateHits}) : qw()),
75 ($qo->{EnableBibliography} ? (EnableBibliography=>$qo->{EnableBibliography}) : qw()),
76 ($qo->{DebugRank} ? (DebugRank=>$qo->{DebugRank}) : qw()),
77 16 ▶ (Filters=>[map {($_->toHash(json=>1))} @{$qo->{Filters}||[]}]),
Branch: 1 branch
BranchTrueFalseTotal
$qo->{'Subcorpora'} && @{$qo->{'Subcorpora'};} ? : 28 168 196
Condition60%3/5
$qo->{'Filters'} || []
l!l
1960
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
!ll&&!rl&&r
016828
MC/DC0%0/1
$qo->{'Filters'} || []
$qo->{'Filters'}
MC/DC50%1/2
$qo->{"Subcorpora"} and @{$qo->{"Subcorpora"};}
$qo->{"Subcorpora"} @{$qo->{"Subcorpora"};}
Truth table50%1/2
A
A= $qo->{'Filters'}
Aresult
11
00
Truth table66%2/3
A and B
A= $qo->{"Subcorpora"}B= @{$qo->{"Subcorpora"};}
ABresult
0X0
100
111
78 196 ▶ ($qo->{Subcorpora} && @{$qo->{Subcorpora}} ? (Subcorpora=>$qo->{Subcorpora}) : qw()),
Branch: 1 branch
BranchTrueFalseTotal
$qo->{'Comments'} && @{$qo->{'Comments'};} ? : 16 180 196
Condition66%2/3
$qo->{"Comments"} and @{$qo->{"Comments"};}
!ll&&!rl&&r
018016
MC/DC50%1/2
$qo->{"Comments"} and @{$qo->{"Comments"};}
$qo->{"Comments"} @{$qo->{"Comments"};}
Truth table66%2/3
A and B
A= $qo->{"Comments"}B= @{$qo->{"Comments"};}
ABresult
0X0
100
111
79 196 ▶ ($qo->{Comments} && @{$qo->{Comments}} ? (Comments=>$qo->{Comments}) : qw()),
Branch: 1 branch
BranchTrueFalseTotal
$qo->{'LexerComments'} && @{$qo->{'LexerComments'};} ? : 0 196 196
Condition33%1/3
$qo->{"LexerComments"} and @{$qo->{"LexerComments"};}
!ll&&!rl&&r
01960
MC/DC0%0/2
$qo->{"LexerComments"} and @{$qo->{"LexerComments"};}
$qo->{"LexerComments"} @{$qo->{"LexerComments"};}
Truth table33%1/3
A and B
A= $qo->{"LexerComments"}B= @{$qo->{"LexerComments"};}
ABresult
0X0
100
111
80 196 ▶ ($qo->{LexerComments} && @{$qo->{LexerComments}} ? (LexerComments=>$qo->{LexerComments}) : qw()),
Branch: 5 branches
BranchTrueFalseTotal
$qo->{'Within'} && $qo->{'Within'} ? : 196 0 196
$qo->{'ContextSentencesCount'} ? : 0 196 196
$qo->{'SeparateHits'} ? : 0 196 196
$qo->{'EnableBibliography'} ? : 196 0 196
$qo->{'DebugRank'} ? : 0 196 196
Condition33%1/3
$qo->{"Within"} and $qo->{"Within"}
!ll&&!rl&&r
00196
MC/DC0%0/2
$qo->{"Within"} and $qo->{"Within"}
$qo->{"Within"} $qo->{"Within"}
Truth table33%1/3
A and B
A= $qo->{"Within"}B= $qo->{"Within"}
ABresult
0X0
100
111
81 );
82 }
83  
84  
85 20 1; ##-- be happy
86  
87 =pod
88  
89 =head1 NAME
90  
91 DDC::PP::CQueryOptions - pure-perl implementation of DDC::XS::CQueryOptions
92  
93 =head1 SYNOPSIS
94  
95 use DDC::PP::CQueryOptions;
96 #... stuff happens ...
97  
98  
99 =head1 DESCRIPTION
100  
101 The DDC::PP::CQueryOptions class is a pure-perl fork of the L<DDC::XS::CQueryOptions|DDC::XS::CQueryOptions> class,
102 which see for details.
103  
104 =head1 SEE ALSO
105  
106 perl(1),
107 DDC::PP(3perl),
108 DDC::XS::CQueryOptions(3perl).
109  
110 =head1 AUTHOR
111  
112 Bryan Jurish E<lt>moocow@cpan.orgE<gt>
113  
114 =head1 COPYRIGHT AND LICENSE
115  
116 Copyright (C) 2016-2020 by Bryan Jurish
117  
118 This library is free software; you can redistribute it and/or modify
119 it under the same terms as Perl itself, either Perl version 5.14.2 or,
120 at your option, any later version of Perl 5 you may have available.
121  
122 =cut
123  
« blib/lib/DDC/Any.pm ↑ Summary blib/lib/DDC/Format.pm »