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

filter: Statementstmt 88.2% 592 / 671 Branchbran 13.0% 12 / 92 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 89.7% 192 / 214 Podpod 100% 13 / 13 totaltotal 81.0% 810 / 1000 CC 49 SCAR 23.4
CC
49
Cov
79%
__ANON__
110.0
clone_or_create
90.0
__ANON__
30.0
CRAP 10.4
« blib/lib/CXC/Gnuplot/V0/CoordOffset3D.pm ↑ Summary blib/lib/CXC/Gnuplot/V0/Range.pm »
1 package CXC::Gnuplot::V0::Util;
2  
3 33 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 our $VERSION = 'v0.29.3';
5  
6 33 ▶use experimental 'declared_refs', 'for_list', 'builtin', 'try';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 use Exporter::Shiny
9 33 'assert_coerce_object',
10 'clone_object',
11 'flatten_array',
12 'render_set',
13 'gnuplot_color',
14 'gnuplot_color_names',
15 'maybe_quote',
16 'pvalidate',
17 'pvalidate_xy_pair',
18 'quote',
19 'render_opts',
20 'to_hash_r',
21 33 ▶ ;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # use namespace::autoclean;
24 33 ▶use Hash::Merge;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 33 ▶use Ref::Util 'is_plain_arrayref', 'is_plain_hashref', 'is_plain_ref', 'is_ref', 'is_blessed_ref';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 33 ▶use builtin::compat 'blessed', 'load_module', 'trim', 'is_bool', 'true', 'false';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 33 ▶use CXC::Data::Visitor 'visit', 'VISIT_ALL', 'RESULT_CONTINUE';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 33 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 33 ▶use constant BASE => __PACKAGE__ =~ s/[^:]+$//r;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 my sub croak {
33 0 ▶ require Carp;
Subroutine croak: not called CC=1 SCAR=6.9
34 0 goto \&Carp::croak;
35 }
36  
37 ▶my sub rewrite_prefix ( $module ) {
Subroutine rewrite_prefix: not called CC=3 SCAR=24.8
38 0 state $root = ( __PACKAGE__ =~ s/::Util//r ) . q{::};
39 return
40 0 ▶ defined $module
Branch: 2 branches
BranchTrueFalseTotal
defined $module ? : 0 0 0
substr($module, 0, 1) eq '+' ? : 0 0 0
41 ? substr( $module, 0, 1 ) eq q{+}
42 ? $module
43 : $root . $module
44 : undef;
45 }
46  
47 # not very efficient
48  
49  
50  
51  
52  
53 ▶sub flatten_array ( $array ) {
Subroutine flatten_array: not called CC=3 SCAR=24.8
Pod documented
54 return is_plain_arrayref( $array )
55 0 ▶ ? [ map { is_plain_arrayref( $_ ) ? __SUB__->( $_ )->@* : $_; } $array->@* ]
Branch: 2 branches
BranchTrueFalseTotal
is_plain_arrayref($array) ? : 0 0 0
is_plain_arrayref($_) ? : 0 0 0
56 : [$array];
57 }
58  
59  
60  
61  
62  
63 ▶sub render_set( $set, $format ) {
Subroutine render_set: not called CC=4 SCAR=30.0
Pod documented
64 ## no critic(NamingConventions::ProhibitAmbiguousNames)
65 0 my \@set = $set;
66 return
67 $format eq 'array' ? @set
68 0 ▶ : $format eq 'flatten_array' ? map { flatten_array( $_ ) } @set
Branch: 1 branch
BranchTrueFalseTotal
$format eq 'string' ? : 0 0 0
69 0 ▶ : $format eq 'string' ? map { join q{ }, flatten_array( $_ )->@* } @set
Branch: 2 branches
BranchTrueFalseTotal
$format eq 'array' ? : 0 0 0
$format eq 'flatten_array' ? : 0 0 0
70 : croak( 'unknown format: ' . $format );
71  
72 }
73  
74  
75  
76  
77  
78 ▶sub maybe_quote( $str ) {
Subroutine maybe_quote: not called CC=2 SCAR=17.9
Pod documented
79 0 ▶ return $str =~ /^(['"]).*(\1)$/ ? $str : B::cstring( $str );
Branch: 1 branch
BranchTrueFalseTotal
$str =~ /^(['"]).*(\1)$/u ? : 0 0 0
80 }
81  
82  
83  
84  
85  
86 ▶sub quote( $str ) {
Subroutine quote: not called CC=1 SCAR=6.9
Pod documented
87 0 return B::cstring( $str );
88 }
89  
90 ## no critic (NamingConventions::ProhibitAmbiguousNames )
91 ▶my sub merge ( $left, $right ) {
Subroutine merge: not called CC=1 SCAR=6.9
92 0 state $merger = do {
93 0 my $obj = Hash::Merge->new;
94 $obj->add_behavior_spec( {
95 'SCALAR' => {
96 0 ▶ 'SCALAR' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 ▶ 'ARRAY' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 0 ▶ 'HASH' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 },
100 'ARRAY' => {
101 0 ▶ 'SCALAR' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 ▶ 'ARRAY' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
103 0 ▶ 'HASH' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
104 },
105 'HASH' => {
106 0 ▶ 'SCALAR' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
107 0 ▶ 'ARRAY' => sub { $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 ▶ 'HASH' => sub ( $left, $right ) {
Subroutine __ANON__: not called CC=10 SCAR=47.0
109 0 my \%left = $left;
110 0 my \%right = $right;
111  
112 # delete the specified entries from $left
113 0 ▶ if ( defined( my $delete = delete $right{-delete} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $delete = delete $right{"-delete"})) 0 0 0
114 # delete everything
115 0 ▶ if ( is_bool( $delete ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::is_bool($delete)) { } 0 0 0
116 0 ▶ %left = () if $delete;
Branch: 1 branch
BranchTrueFalseTotal
if $delete 0 0 0
117 }
118 else {
119 # delete specific keys
120 0 ▶ delete @left{ is_plain_arrayref( $delete ) ? $delete->@* : $delete };
Branch: 1 branch
BranchTrueFalseTotal
is_plain_arrayref($delete) ? : 0 0 0
121 }
122 }
123  
124 0 ▶ if ( defined( my $overwrite = delete $right{-overwrite} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $overwrite = delete $right{"-overwrite"})) 0 0 0
125  
126 # overwrite keys in $left with keys in $right
127 # removing them from %right so they can't be merged
128 my @keys
129 0 ▶ = is_bool( $overwrite ) ? ( $overwrite ? keys %right : () )
Branch: 3 branches
BranchTrueFalseTotal
builtin::is_bool($overwrite) ? : 0 0 0
$overwrite ? : 0 0 0
is_plain_arrayref($overwrite) ? : 0 0 0
130 : is_plain_arrayref( $overwrite ) ? $overwrite->@*
131 : ( $overwrite );
132 0 @left{@keys} = delete @right{@keys};
133 }
134  
135  
136 0 ▶ return \%left unless keys %right;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %right 0 0 0
137  
138 # merge what's left
139 # _merge_hashes is part of the public API
140 ## no critic ( Subroutines::ProtectPrivateSubs )
141 0 Hash::Merge::_merge_hashes( \%left, \%right );
142 },
143 },
144 },
145 0 __PACKAGE__,
146 );
147 # this is on by default, but let's make it explicit
148 0 $obj->set_clone_behavior( true );
149 0 $obj;
150 };
151  
152 0 $merger->merge( $left, $right );
153 }
154  
155  
156  
157  
158  
159 ▶sub clone_object ( $object, $new_attr ) {
Subroutine clone_object: not called CC=1 SCAR=6.9
Pod documented
160  
161 0 my $class = blessed( $object );
162 0 my %new = $new_attr->%*;
163 0 my \%old = $object->to_hash;
164 0 my \%attr = merge( \%old, \%new );
165  
166 0 return $class->new( %attr );
167 }
168  
169  
170  
171  
172  
173 ▶sub clone_or_create( $class, $orig, $new ) {
Subroutine clone_or_create: not called CC=9 SCAR=45.0
Pod documented
174  
175 0 ▶ !defined $new
Branch: 2 branches
BranchTrueFalseTotal
defined $new or return defined $orig ? $orig->clone : undef 0 0 0
defined $orig ? : 0 0 0
176 and return defined( $orig ) ? $orig->clone : undef;
177  
178 0 ▶ $new isa $class
Branch: 1 branch
BranchTrueFalseTotal
$new isa $class and return $new 0 0 0
179 and return $new;
180  
181 0 ▶ if ( !defined $orig ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $orig) 0 0 0
182 0 ▶ return $class->can( 'assert_coerce' )
Branch: 1 branch
BranchTrueFalseTotal
$class->can('assert_coerce') ? : 0 0 0
183 ? $class->assert_coerce( $new )
184 : assert_coerce_object( $class, $new );
185 }
186  
187 0 my $attr;
188 0 ▶ $class->can( 'coerce_attrs' ) && defined( $attr = $class->coerce_attrs( $new ) )
Branch: 1 branch
BranchTrueFalseTotal
$class->can("coerce_attrs") and defined($attr = $class->coerce_attrs($new)) and return $orig->clone(%$attr) 0 0 0
Condition0%0/3
$class->can("coerce_attrs") and defined($attr = $class->coerce_attrs($new))
!ll&&!rl&&r
000
MC/DC0%0/2
$class->can("coerce_attrs") and defined($attr = $class->coerce_attrs($new))
$class->can("coerce_attrs") defined($attr = $class->coerce_attrs($new))
Truth table0%0/3
A and B
A= $class->can("coerce_attrs")B= defined($attr = $class->coerce_attrs($new))
ABresult
0X0
100
111
189 and return $orig->clone( $attr->%* );
190  
191 0 ▶ is_plain_hashref( $new )
Branch: 1 branch
BranchTrueFalseTotal
is_plain_hashref($new) and return $orig->clone(%$new) 0 0 0
192 and return $orig->clone( $new->%* );
193  
194 0 croak "cannot clone or create $class based upon input args";
195 }
196  
197  
198  
199  
200  
201 ▶sub assert_coerce_object ( $class, @iattrs ) {
Subroutine assert_coerce_object: called CC=8 SCAR=20.8
Pod documented
202  
203 # pass through if the argument is already an object
204 86 ▶ return $iattrs[0] if @iattrs == 1 && $iattrs[0] isa $class;
Branch: 1 branch
BranchTrueFalseTotal
if @iattrs == 1 and $iattrs[0] isa $class 0 86 86
Condition33%1/3
@iattrs == 1 and $iattrs[0] isa $class
!ll&&!rl&&r
0860
MC/DC0%0/2
@iattrs == 1 and $iattrs[0] isa $class
@iattrs == 1 $iattrs[0] isa $class
Truth table33%1/3
A and B
A= @iattrs == 1B= $iattrs[0] isa $class
ABresult
0X0
100
111
205  
206 86 ▶ load_module( $class );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
207  
208 86 ▶ my $attr = $class->can( 'coerce_attrs' ) ? $class->coerce_attrs( @iattrs ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$class->can('coerce_attrs') ? : 86 0 86
209 86 ▶ return $class->new( $attr->%* ) if defined $attr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $attr 86 0 86
210  
211 0 ▶ return $class->new( @iattrs ) if @iattrs > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @iattrs > 1 0 0 0
212  
213 0 $attr = $iattrs[0];
214  
215 0 ▶ is_plain_hashref( $attr )
Branch: 1 branch
BranchTrueFalseTotal
is_plain_hashref($attr) and return $class->new(%$attr) 0 0 0
216 and return $class->new( $attr->%* );
217  
218 0 ▶ is_ref( $attr )
Branch: 1 branch
BranchTrueFalseTotal
is_ref($attr) and croak "${class}: unable to extract attributes from non-hash reference" 0 0 0
219 and croak( "$class: unable to extract attributes from non-hash reference" );
220  
221 0 croak( "$class: unable to extract attributes from non-reference scalar" );
222 }
223  
224  
225  
226  
227  
228  
229  
230 ▶sub pvalidate ( $name, $type, $value_ref ) {
Subroutine pvalidate: called CC=7 SCAR=19.5
Pod documented
231  
232 266 ▶ return if !defined $value_ref->$*;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$value_ref 74 192 266
233  
234 192 try {
235 192 ▶ if ( $type isa Type::Tiny ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type isa 'Type::Tiny') { } 100 92 192
elsif (not is_ref($type)) { } 92 0 92
236 100 ▶ if ( $type->has_coercion ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->has_coercion) { } 76 24 100
237 76 $value_ref->$* = $type->assert_coerce( $value_ref->$* );
238 }
239 else {
240 24 $type->assert_valid( $value_ref->$* );
241 }
242 }
243  
244 elsif ( !is_ref $type ) {
245  
246 92 my $class = BASE . $type;
247 92 ▶ return if $value_ref->$* isa $class;
Branch: 1 branch
BranchTrueFalseTotal
if $$value_ref isa $class 0 92 92
248 92 ▶ load_module( $class );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
249 92 ▶ $value_ref->$*
Branch: 1 branch
BranchTrueFalseTotal
$class->can('assert_coerce') ? : 92 0 92
250 = $class->can( 'assert_coerce' )
251 ? $class->assert_coerce( $value_ref->$* )
252 : assert_coerce_object( $class, $value_ref->$* );
253 }
254 }
255 catch ( $e ) {
256 0 croak( qq{unable to validate or coerce "$name" parameter: $e} );
257 };
258 }
259  
260  
261  
262  
263  
264 ▶sub pvalidate_xy_pair ( $name, $type, $value_ref ) {
Subroutine pvalidate_xy_pair: not called CC=4 SCAR=30.0
Pod documented
265  
266 0 my $value = $value_ref->$*;
267  
268 0 ▶ return if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
269  
270 0 pvalidate( $name => $type, $value_ref );
271 0 ▶ $value_ref->$* = $value = { x => $value }
Branch: 1 branch
BranchTrueFalseTotal
unless is_plain_hashref($value) 0 0 0
272 unless is_plain_hashref( $value );
273  
274 defined $value->{x}
275 0 ▶ or croak( qq{must specify an "x" $name} );
Branch: 1 branch
BranchTrueFalseTotal
defined $value->{"x"} or croak qq[must specify an "x" $name] 0 0 0
276  
277 }
278  
279  
280 my sub _colors {
281  
282 2 ▶ state @colors = do {
Subroutine _colors: called CC=1 SCAR=0.0
283 1 require File::ShareDir::Tarball;
284 1 require Path::Tiny;
285 1 require CXC::Gnuplot::V0::Color;
286  
287 # the share/gnuplot_colors file is derived from the gnuplot 'show colors' command
288 1 my $file
289 = Path::Tiny::path( File::ShareDir::Tarball::dist_file( 'CXC-Gnuplot', 'gnuplot_colors' ) );
290  
291 ## no critic (BuiltinFunctions::ProhibitComplexMappings)
292 map {
293 1 my %color;
294 111 @color{ 'name', 'rgb', 'r', 'g', 'b' } = split /[\h=]+/;
295 111 CXC::Gnuplot::V0::Color->new( %color );
296 } grep length, map trim( $_ ), $file->lines;
297 };
298  
299 2 return @colors;
300  
301 }
302  
303  
304  
305  
306  
307 sub gnuplot_color_names {
308 1 ▶ state @names = map { $_->name } _colors;
Subroutine gnuplot_color_names: called CC=1 SCAR=0.0
Pod documented
309 1 return @names;
310 }
311  
312  
313  
314  
315  
316 ▶sub gnuplot_color ( $name ) {
Subroutine gnuplot_color: called CC=1 SCAR=0.0
Pod documented
317 1 state %color = map { $_->name => $_ } _colors;
318 1 return $color{$name};
319 }
320  
321  
322  
323  
324  
325 ▶sub to_hash_r ( $hash ) {
Subroutine to_hash_r: not called CC=1 SCAR=6.9
Pod documented
326  
327 ▶ visit(
Subroutine __ANON__: not called CC=5 SCAR=34.0
328 $hash,
329 sub ( $kydx, $vref, $context, $metadata ) {
330  
331 # make copies of containers.
332 0 ▶ if ( is_plain_arrayref $vref->$* ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_plain_arrayref($$vref)) 0 0 0
333 0 $vref->$* = [ $vref->$*->@* ];
334 0 return RESULT_CONTINUE;
335 }
336  
337 0 ▶ if ( is_plain_hashref $vref->$* ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_plain_hashref($$vref)) 0 0 0
338 0 $vref->$* = { $vref->$*->%* };
339 0 return RESULT_CONTINUE;
340 }
341  
342 0 ▶ return RESULT_CONTINUE
Branch: 1 branch
BranchTrueFalseTotal
unless is_blessed_ref($$vref) 0 0 0
343 unless is_blessed_ref $vref->$*;
344 0 my $obj = $vref->$*;
345 0 my $mth = $obj->can( 'to_hash' );
346  
347 0 ▶ croak( 'no means of converting object to hash at: ' . join( q{.}, $metadata->{path}->@* ) )
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mth 0 0 0
348 if !defined $mth;
349  
350 0 $vref->$* = $obj->$mth;
351 0 return RESULT_CONTINUE;
352 },
353 0 visit => VISIT_ALL,
354 );
355  
356 0 $hash;
357 }
358  
359  
360  
361  
362  
363 ▶sub render_opts ( $label, $value ) {
Subroutine render_opts: not called CC=4 SCAR=30.0
Pod documented
364  
365 0 ▶ !defined $value and return ();
Branch: 1 branch
BranchTrueFalseTotal
defined $value or return () 0 0 0
366  
367 0 ▶ !is_blessed_ref $value
Branch: 1 branch
BranchTrueFalseTotal
is_blessed_ref($value) or croak "value is not an object" 0 0 0
368 and croak( 'value is not an object' );
369  
370 0 ▶ my @opts = ( is_plain_arrayref( $label ) ? $label->@* : $label, $value->opts );
Branch: 1 branch
BranchTrueFalseTotal
is_plain_arrayref($label) ? : 0 0 0
371  
372 0 return \@opts;
373 }
374  
375 33 1;
376  
377 __END__
« blib/lib/CXC/Gnuplot/V0/CoordOffset3D.pm ↑ Summary blib/lib/CXC/Gnuplot/V0/Range.pm »