blib/lib/CXC/Gnuplot/V0/AxisTics.pm

filter: Statementstmt 44.8% 48 / 107 Branchbran 0.0% 0 / 98 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 55.0% 11 / 20 Podpod 100% 4 / 4 totaltotal 23.9% 63 / 263 CC 57 SCAR 53.0
CC
57
Cov
21%
opts
420.0
to_hash
240.0
__ANON__
210.0
CRAP 201.2
« blib/lib/CXC/Gnuplot/V0/Key.pm ↑ Summary blib/lib/CXC/Gnuplot/V0/Label.pm »
1 package CXC::Gnuplot::V0::AxisTics;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental 'builtin', 'declared_refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Feature::Compat::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = 'v0.29.3';
8  
9 class CXC::Gnuplot::V0::AxisTics;
10  
11 1 ▶use builtin 'is_bool', 'true', 'false';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶no namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Ref::Util 'is_plain_hashref', 'is_plain_arrayref', 'is_ref';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use List::Util 'none';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 use CXC::Gnuplot::V0::Types -lexical, qw(
21 Enum
22 is_Num
23 is_NonEmptyStr
24 PerlBoolFalse
25 TicList
26 TicSeries
27 CoordOffset3D
28 1 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 use CXC::Gnuplot::V0::Util -lexical, 'maybe_quote', 'assert_coerce_object', 'clone_object',
30 1 ▶ 'pvalidate', 'to_hash_r', 'render_opts';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use CXC::Gnuplot::V0::AxisFormat;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33  
34 my sub croak {
35 0 ▶ require Carp;
Subroutine croak: not called CC=1 SCAR=6.9
36 0 goto \&Carp::croak;
37 }
38  
39 #<<< no tidy
40 1 field $where :param :reader = undef; # {axis | border}
41 1 field $mirror :param :reader = undef; # {{no}mirror}
42 1 field $direction :param :reader = undef; # {in |out}
43 1 field $scale :param :reader = undef; # {scale {default | <major> {,<minor>}}}
44 1 field $rotate :param :reader = undef; # {{no}rotate {by <ang>}}
45 1 field $offset :param :reader = undef; # {offset <offset> | nooffset}
46 1 field $justify :param :reader = undef; # {left | right | center | autojustify}
47 1 field $positions :param :reader = undef; # { autofreq
48 # | <incr>
49 # | <start>, <incr> {,<end>}
50 # | ({"<label>"} <pos> {<level>} {,{"<label>"}...) }
51 1 field $format :param :reader = undef;
52 1 field $font :param :reader = undef; # {"name{,<size>}"}
53 1 field $enhanced :param :reader = undef; # {{no}enhanced}
54 1 field $logscale :param :reader = undef; #{{no}logscale}
55 1 field $rangelimited :param :reader = undef; # {rangelimited}
56 1 field $textcolor :param :reader = undef; # {colorspec}
57 #>>>
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96 ADJUST {
97  
98 0 ▶ pvalidate( where => Enum->of( 'axis', 'border' ), \$where );
Subroutine __ANON__: not called CC=14 SCAR=53.5
99  
100 0 ▶ defined $mirror
Branch: 1 branch
BranchTrueFalseTotal
defined $mirror and not builtin::is_bool($mirror) and croak "invalid value for \"mirror\" parameter: must be bool" 0 0 0
Condition0%0/3
defined $mirror and not builtin::is_bool($mirror)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $mirror and not builtin::is_bool($mirror)
defined $mirror not builtin::is_bool($mirror)
Truth table0%0/3
A and not(B)
A= defined $mirrorB= not builtin::is_bool($mirror)
ABresult
0X0
100
111
101 and !is_bool( $mirror )
102 and croak( q{invalid value for "mirror" parameter: must be bool} );
103  
104 0 pvalidate( direction => Enum->of( 'axis', 'border' ), \$direction );
105  
106 # for now, just store this as a string
107 0 ▶ defined $scale
Branch: 1 branch
BranchTrueFalseTotal
defined $scale and not is_NonEmptyStr($scale) and croak "\"scale\" must be non-empty" 0 0 0
Condition0%0/3
defined $scale and not is_NonEmptyStr($scale)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $scale and not is_NonEmptyStr($scale)
defined $scale not is_NonEmptyStr($scale)
Truth table0%0/3
A and not(B)
A= defined $scaleB= not is_NonEmptyStr($scale)
ABresult
0X0
100
111
108 and !is_NonEmptyStr( $scale )
109 and croak( q{"scale" must be non-empty} );
110  
111 0 ▶ defined $rotate
Branch: 1 branch
BranchTrueFalseTotal
defined $rotate and not builtin::is_bool($rotate) and not is_Num $rotate and croak "\"rotate\" must be a float or a boolean" 0 0 0
Condition0%0/6
defined $rotate and not builtin::is_bool($rotate) and not is_Num $rotate
!ll&&!rl&&r
000
defined $rotate and not builtin::is_bool($rotate)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $rotate and not builtin::is_bool($rotate) and not is_Num $rotate
defined $rotate not builtin::is_bool($rotate) not is_Num $rotate
Truth table0%0/4
A and not(B) and not(C)
A= defined $rotateB= not builtin::is_bool($rotate)C= not is_Num $rotate
ABCresult
0XX0
10X0
1100
1111
112 and !is_bool( $rotate )
113 and !is_Num( $rotate )
114 and croak( '"rotate" must be a float or a boolean' );
115  
116 # offset is either a false boolean or an expression
117 0 pvalidate( offset => PerlBoolFalse | CoordOffset3D, \$offset );
118  
119 0 pvalidate( justify => Enum->of( 'left', 'right', 'center', 'autojustify' ), \$justify );
120  
121 0 pvalidate( positions => Enum->of( 'autofreq' ) | TicSeries | TicList, \$positions );
122  
123 0 pvalidate( format => AxisFormat => \$format );
124 0 pvalidate( font => Font => \$font );
125  
126 0 ▶ defined $enhanced
Branch: 1 branch
BranchTrueFalseTotal
defined $enhanced and not builtin::is_bool($enhanced) and croak "invalid value for \"enhanced\" parameter: must be bool" 0 0 0
Condition0%0/3
defined $enhanced and not builtin::is_bool($enhanced)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $enhanced and not builtin::is_bool($enhanced)
defined $enhanced not builtin::is_bool($enhanced)
Truth table0%0/3
A and not(B)
A= defined $enhancedB= not builtin::is_bool($enhanced)
ABresult
0X0
100
111
127 and !is_bool( $enhanced )
128 and croak( q{invalid value for "enhanced" parameter: must be bool} );
129  
130 0 ▶ defined $logscale
Branch: 1 branch
BranchTrueFalseTotal
defined $logscale and not builtin::is_bool($enhanced) and croak "invalid value for \"logscale\" parameter: must be bool" 0 0 0
Condition0%0/3
defined $logscale and not builtin::is_bool($enhanced)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $logscale and not builtin::is_bool($enhanced)
defined $logscale not builtin::is_bool($enhanced)
Truth table0%0/3
A and not(B)
A= defined $logscaleB= not builtin::is_bool($enhanced)
ABresult
0X0
100
111
131 and !is_bool( $enhanced )
132 and croak( q{invalid value for "logscale" parameter: must be bool} );
133  
134 0 ▶ defined $rangelimited
Branch: 1 branch
BranchTrueFalseTotal
defined $rangelimited and not builtin::is_bool($rangelimited) and croak "invalid value for \"rangelimited\" parameter: must be bool" 0 0 0
Condition0%0/3
defined $rangelimited and not builtin::is_bool($rangelimited)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rangelimited and not builtin::is_bool($rangelimited)
defined $rangelimited not builtin::is_bool($rangelimited)
Truth table0%0/3
A and not(B)
A= defined $rangelimitedB= not builtin::is_bool($rangelimited)
ABresult
0X0
100
111
135 and !is_bool( $rangelimited )
136 and croak( q{invalid value for "rangelimited" parameter: must be bool} );
137  
138 0 pvalidate( textcolor => ColorSpec => \$textcolor );
139 }
140  
141  
142  
143  
144  
145 method to_hash {
146  
147 0 ▶ to_hash_r( {
Subroutine to_hash: not called CC=15 SCAR=54.8
Pod documented
Branch: 14 branches
BranchTrueFalseTotal
defined $where ? : 0 0 0
defined $mirror ? : 0 0 0
defined $direction ? : 0 0 0
defined $scale ? : 0 0 0
defined $rotate ? : 0 0 0
defined $offset ? : 0 0 0
defined $justify ? : 0 0 0
defined $positions ? : 0 0 0
defined $enhanced ? : 0 0 0
defined $logscale ? : 0 0 0
defined $rangelimited ? : 0 0 0
defined $textcolor ? : 0 0 0
defined $format ? : 0 0 0
defined $font ? : 0 0 0
148 ( defined $where ? ( where => $where ) : () ),
149 ( defined $mirror ? ( mirror => $mirror ) : () ),
150 ( defined $direction ? ( direction => $direction ) : () ),
151 ( defined $scale ? ( scale => $scale ) : () ),
152 ( defined $rotate ? ( rotate => $rotate ) : () ),
153 ( defined $offset ? ( offset => $offset ) : () ),
154 ( defined $justify ? ( justify => $justify ) : () ),
155 ( defined $positions ? ( positions => $positions ) : () ),
156 ( defined $enhanced ? ( enhanced => $enhanced ) : () ),
157 ( defined $logscale ? ( logscale => $logscale ) : () ),
158 ( defined $rangelimited ? ( rangelimited => $rangelimited ) : () ),
159 ( defined $textcolor ? ( textcolor => $textcolor ) : () ),
160 ( defined $format ? ( format => $format ) : () ),
161 ( defined $font ? ( font => $font ) : () ),
162 } );
163 }
164  
165  
166  
167  
168  
169 ▶sub assert_coerce( $class, $args ) {
Subroutine assert_coerce: not called CC=1 SCAR=6.9
Pod documented
170 0 assert_coerce_object( $class, $args );
171 }
172  
173  
174  
175  
176  
177 ▶method clone ( %args ) {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
178 0 return clone_object( $self, \%args );
179 }
180  
181 ▶my sub opts_tic_series( $series ) {
Subroutine opts_tic_series: not called CC=5 SCAR=34.0
182  
183 0 my \%series = $series;
184 0 my @position;
185  
186 push @position, $series{start}
187 0 ▶ if defined $series{start};
Branch: 1 branch
BranchTrueFalseTotal
if defined $series{"start"} 0 0 0
188  
189 0 ▶ if ( defined( my $incr = $series{incr} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $incr = $series{"incr"})) 0 0 0
190 push @position,
191 is_plain_hashref( $incr )
192 0 ▶ ? join( q{ }, grep defined, $incr->@{ 'multiple', 'unit' } )
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_plain_hashref($incr) ? : 0 0 0
193 : $incr;
194 }
195  
196 push @position, $series{end}
197 0 ▶ if defined $series{end};
Branch: 1 branch
BranchTrueFalseTotal
if defined $series{"end"} 0 0 0
198  
199 0 return join( ', ', @position );
200 }
201  
202 ▶my sub opts_tic_entry ( $entry ) {
Subroutine opts_tic_entry: not called CC=3 SCAR=24.8
203  
204 0 my \%entry = $entry;
205  
206 0 my @pos;
207  
208 defined $entry{label}
209 0 ▶ and push @pos, maybe_quote( $entry{label} );
Branch: 1 branch
BranchTrueFalseTotal
defined $entry{"label"} and push @pos, maybe_quote($entry{"label"}) 0 0 0
210  
211 0 push @pos, $entry{pos};
212  
213 defined $entry{level}
214 0 ▶ and push @pos, $entry{level};
Branch: 1 branch
BranchTrueFalseTotal
defined $entry{"level"} and push @pos, $entry{"level"} 0 0 0
215  
216 0 return join q{ }, @pos;
217 }
218  
219 ▶my sub opts_positions ( $positions ) {
Subroutine opts_positions: not called CC=5 SCAR=34.0
220  
221 0 ▶ return () if !defined $positions;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $positions 0 0 0
222  
223 # start, incr, end
224 0 ▶ return opts_tic_series( $positions )
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_hashref($positions) 0 0 0
225 if is_plain_hashref( $positions );
226  
227 # autofreq
228 0 ▶ return $positions if !is_plain_arrayref( $positions );
Branch: 1 branch
BranchTrueFalseTotal
unless Ref::Util::XS::is_plain_arrayref($positions) 0 0 0
229  
230 0 my \@positions = $positions;
231  
232 # add
233 0 ▶ my @add = is_ref( $positions[0] ) ? () : shift @positions;
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_ref($positions[0]) ? : 0 0 0
234 0 my $tics = join q{, }, map { opts_tic_entry( $_ ) } @positions;
235 0 return join q{ }, @add, "( $tics )";
236 }
237  
238  
239  
240  
241  
242 method opts {
243 0 ▶ my @opts;
Subroutine opts: not called CC=20 SCAR=60.4
Pod documented
244  
245 0 ▶ defined $where
Branch: 1 branch
BranchTrueFalseTotal
defined $where and push @opts, $where 0 0 0
246 and push @opts, $where;
247  
248 0 ▶ defined $mirror
Branch: 2 branches
BranchTrueFalseTotal
defined $mirror and push @opts, $mirror ? "mirror" : "nomirror" 0 0 0
$mirror ? : 0 0 0
249 and push @opts, $mirror ? 'mirror' : 'nomirror';
250  
251 0 ▶ defined $direction
Branch: 1 branch
BranchTrueFalseTotal
defined $direction and push @opts, $direction 0 0 0
252 and push @opts, $direction;
253  
254 0 ▶ defined $scale
Branch: 1 branch
BranchTrueFalseTotal
defined $scale and push @opts, ["scale", $scale] 0 0 0
255 and push @opts, [ scale => $scale ];
256  
257 0 ▶ defined $rotate
Branch: 3 branches
BranchTrueFalseTotal
defined $rotate and push @opts, builtin::is_bool($rotate) ? $rotate ? "rotate" : "norotate" : ["rotate by", $rotate] 0 0 0
builtin::is_bool($rotate) ? : 0 0 0
$rotate ? : 0 0 0
258 and push @opts, is_bool( $rotate )
259 ? ( $rotate ? 'rotate' : 'norotate' )
260 : [ 'rotate by' => $rotate ];
261  
262 0 ▶ if ( defined $offset ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $offset) 0 0 0
263 0 ▶ if ( is_bool( $offset ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::is_bool($offset)) { } 0 0 0
264 0 ▶ push @opts, ( $offset ? 'offset' : 'nooffset' );
Branch: 1 branch
BranchTrueFalseTotal
$offset ? : 0 0 0
265 }
266 else {
267 0 push @opts, render_opts( offset => $offset );
268 }
269  
270 }
271  
272 0 ▶ defined $justify
Branch: 1 branch
BranchTrueFalseTotal
defined $justify and push @opts, $justify 0 0 0
273 and push @opts, $justify;
274  
275 0 ▶ defined $positions
Branch: 1 branch
BranchTrueFalseTotal
defined $positions and push @opts, opts_positions($positions) 0 0 0
276 and push @opts, opts_positions( $positions );
277  
278 0 push @opts, render_opts( format => $format );
279  
280 0 push @opts, render_opts( font => $font );
281  
282 0 ▶ defined $enhanced
Branch: 2 branches
BranchTrueFalseTotal
defined $enhanced and push @opts, $enhanced ? "enhanced" : "noenhanced" 0 0 0
$enhanced ? : 0 0 0
283 and push @opts, ( $enhanced ? 'enhanced' : 'noenhanced' );
284  
285 0 ▶ defined $logscale
Branch: 2 branches
BranchTrueFalseTotal
defined $logscale and push @opts, $logscale ? "logscale" : "nologscale" 0 0 0
$logscale ? : 0 0 0
286 and push @opts, ( $logscale ? 'logscale' : 'nologscale' );
287  
288 0 ▶ defined $rangelimited
Branch: 2 branches
BranchTrueFalseTotal
defined $rangelimited and push @opts, $rangelimited ? "rangelimited" : () 0 0 0
$rangelimited ? : 0 0 0
289 and push @opts, ( $rangelimited ? 'rangelimited' : () );
290  
291 0 push @opts, render_opts( textcolor => $textcolor );
292  
293 0 return @opts;
294 }
295  
296 #
297 # This file is part of CXC-Gnuplot
298 #
299 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
300 #
301 # This is free software, licensed under:
302 #
303 # The GNU General Public License, Version 3, June 2007
304 #
305  
306 1 1;
307  
308 __END__
« blib/lib/CXC/Gnuplot/V0/Key.pm ↑ Summary blib/lib/CXC/Gnuplot/V0/Label.pm »