Chart/GGPlot/Aes.pm

filter: Statementstmt 92.3% 60 / 65 Branchbran 50.0% 13 / 26 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 92.3% 12 / 13 Podpod 80.0% 4 / 5 totaltotal 77.3% 92 / 119 CC 16 SCAR 13.4
CC
16
Cov
78%
check_aesthetics
8.4
transform_key
4.2
string
3.1
CRAP 3.8
« Chart/GGPlot/Params.pm ↑ Summary Chart/GGPlot/Geom/Point.pm »
1 package Chart::GGPlot::Aes;
2  
3 # ABSTRACT: Aesthetic mappings
4  
5 14 ▶use Chart::GGPlot::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use Function::Parameters qw(classmethod);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 14 our $VERSION = '0.002003'; # VERSION
10  
11 14 ▶use parent qw(Chart::GGPlot::Params);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 14 ▶use List::AllUtils qw(pairmap);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 14 my @all_aesthetics = (
16 "adj", "alpha", "angle", "bg",
17 "cex", "col", "color", "colour",
18 "fg", "fill", "group", "hjust",
19 "label", "linetype", "lower", "lty",
20 "lwd", "max", "middle", "min",
21 "pch", "radius", "sample", "shape",
22 "size", "srt", "upper", "vjust",
23 "weight", "width", "x", "xend",
24 "xmax", "xmin", "xintercept", "y",
25 "yend", "ymax", "ymin", "yintercept",
26 "z"
27 );
28  
29 14 my %base_to_ggplot = (
30 "col" => "color",
31 "colour" => "color",
32 "pch" => "shape",
33 "cex" => "size",
34 "lty" => "linetype",
35 "lwd" => "size",
36 "srt" => "angle",
37 "adj" => "hjust",
38 "bg" => "fill",
39 "fg" => "color",
40 "min" => "ymin",
41 "max" => "ymax"
42 );
43  
44 # Overrides the same method in Chart::GGPlot::Params.
45 405 ▶classmethod transform_key ($key) {
Subroutine transform_key: called CC=4 SCAR=14.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for classmethod transform_key (expected 2, got ' . @_ . ')') 0 405 405
@_ > 2 and Function::Parameters::_croak('Too many arguments for classmethod transform_key (expected 2, got ' . @_ . ')') 0 405 405
46 405 ▶ return ( $base_to_ggplot{$key} // $key );
Condition66%2/3
$base_to_ggplot{$key} // $key
l!l&&r!l&&!r
34020
MC/DC0%0/2
$base_to_ggplot{$key} // $key
$base_to_ggplot{$key} $key
Truth table66%2/3
A // B
A= $base_to_ggplot{$key}B= $key
ABresult
1X1
011
000
47 14 }
48  
49 1 ▶classmethod all_aesthetics () { \@all_aesthetics; }
Subroutine all_aesthetics: called CC=3 SCAR=11.2
Pod undocumented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for classmethod all_aesthetics (expected 1, got ' . @_ . ')') 0 1 1
@_ > 1 and Function::Parameters::_croak('Too many arguments for classmethod all_aesthetics (expected 1, got ' . @_ . ')') 0 1 1
50  
51 217 ▶method keys () { [ sort( @{ $self->SUPER::keys() } ) ]; }
Subroutine keys: called CC=3 SCAR=11.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method keys (expected 1, got ' . @_ . ')') 0 217 217
@_ > 1 and Function::Parameters::_croak('Too many arguments for method keys (expected 1, got ' . @_ . ')') 0 217 217
52  
53  
54 12 ▶classmethod check_aesthetics ($aes, $n=undef) {
Subroutine check_aesthetics: called CC=6 SCAR=21.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 2 and Function::Parameters::_croak('Too few arguments for classmethod check_aesthetics (expected 2, got ' . @_ . ')') 0 12 12
@_ > 3 and Function::Parameters::_croak('Too many arguments for classmethod check_aesthetics (expected 3, got ' . @_ . ')') 0 12 12
55 12 ▶ unless ( defined $n ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $n) 0 12 12
56 $n = List::AllUtils::max(
57 0 ▶ @{ $aes->names->map( sub { $aes->at($_)->length } ) } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 }
59  
60 my @bad_keys = grep {
61 14 my $length = $aes->at($_)->length();
62 14 ▶ !( $length == 1 or $length == $n )
Condition33%1/3
$length == 1 || $length == $n
l!l&&r!l&&!r
0140
MC/DC0%0/2
$length == 1 || $length == $n
$length == 1 $length == $n
Truth table33%1/3
A || B
A= $length == 1B= $length == $n
ABresult
1X1
011
000
63 12 } @{ $aes->names };
64  
65 12 ▶ return unless @bad_keys;
Branch: 1 branch
BranchTrueFalseTotal
unless @bad_keys 12 0 12
66  
67 die(
68 sprintf(
69 "Aesthetics must be either length 1 or the same as the data (%s): %s.",
70 0 $n, join( ', ', map { qq{"$_"} } @bad_keys )
71 )
72 );
73 14 }
74  
75  
76 1 ▶method string () {
Subroutine string: called CC=3 SCAR=11.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
@_ < 1 and Function::Parameters::_croak('Too few arguments for method string (expected 1, got ' . @_ . ')') 0 1 1
@_ > 1 and Function::Parameters::_croak('Too many arguments for method string (expected 1, got ' . @_ . ')') 0 1 1
77 2 ▶ my @assoc = pairmap {
Subroutine __ANON__: called CC=2 SCAR=7.6
78 2 ▶ $a => $b->$_DOES('Eval::Quosure') ? $b->expr : $b;
Branch: 1 branch
BranchTrueFalseTotal
$b->$Chart::GGPlot::Aes::_DOES('Eval::Quosure') ? : 2 0 2
79 1 } $self->flatten;
80 1 ▶ return join(", ", pairmap { qq{$a => $b} } @assoc);
Subroutine __ANON__: called CC=1 SCAR=0.0
81 14 }
82  
83 14 1;
84  
85 __END__
« Chart/GGPlot/Params.pm ↑ Summary Chart/GGPlot/Geom/Point.pm »