Chart/GGPlot/Util/Pod.pm

filter: Statementstmt 100% 32 / 32 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 88.0% 44 / 50 CC 5 SCAR 7.4
CC
5
Cov
95%
__ANON__
3.0
unindent
3.0
x_pod
1.0
CRAP 2.1
« Chart/GGPlot/Position/Identity.pm ↑ Summary Chart/GGPlot/Backend/Plotly/Geom/Blank.pm »
1 package Chart::GGPlot::Util::Pod;
2  
3 # ABSTRACT: Dev utilities for pod-related tasks of Chart::GGPlot
4  
5 10 ▶use Chart::GGPlot::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 our $VERSION = '0.002003'; # VERSION
8  
9 10 ▶use List::AllUtils qw(min);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 ▶use parent qw(Exporter::Tiny);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 10 our @EXPORT_OK = qw(unindent layer_func_pod);
14  
15 10 my $TMPL_COMMON_ARGS = unindent(<<'EOT');
16  
17 =item * $mapping
18  
19 Set of aesthetic mappings created by C<aes()>. If specified and
20 C<$inherit_aes> is true (the default), it is combined with the default
21 mapping at the top level of the plot.
22 You must supply mapping if there is no plot mapping.
23  
24 =item * $data
25  
26 The data to be displayed in this layer.
27 If C<undef>, the default, the data is inherited from the plot data as
28 specified in the call to C<ggplot()>.
29  
30 =item * $stat
31  
32 The statistical transformation to use on the data for this layer, as a
33 string.
34  
35 =item * $position
36  
37 Position adjustment, either as a string, or the result of a call to a
38 position adjustment function.
39  
40 =item * $na_rm
41  
42 If false, the default, missing values are removed with a warning.
43 If true, missing values are silently removed.
44  
45 =item * $show_legend
46  
47 Should this layer be included in the legends?
48 C<undef>, the default, includes if any aesthetics are mapped.
49 A true scalar for never includes, and a defined false scalar for always
50 includes.
51  
52 =item * $inherit_aes
53  
54 If false, overrides the default aesthetics, rather than combining with them.
55 This is most useful for helper functions that define both data and
56 aesthetics and shouldn't inherit behaviour from the default plot
57 specification.
58  
59 =item * %rest
60  
61 Other arguments passed to C<Chart::GGPlot::Layer-E<gt>new()>.
62 These are often aesthetics, used to set an aesthetic to a fixed value,
63 like C<color =E<gt> "red", size =E<gt> 3>.
64 They may also be parameters to the paired geom/stat.
65  
66 EOT
67  
68 10 my %templates = (
69 # common args used by the geom_* and stat_* functions
70 TMPL_COMMON_ARGS => $TMPL_COMMON_ARGS,
71 );
72  
73 10 ▶sub x_pod {
Subroutine x_pod: called CC=1 SCAR=0.0
Pod undocumented
74 10 my ($tmpl_names) = @_;
75  
76 101 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
77 # For why unindent is needed, see
78 # https://github.com/perl-pod/pod-simple/issues/95 for why
79 101 my $text = unindent(shift);
80  
81 101 for my $tmpl_name (@$tmpl_names) {
82 101 my $tmpl_text = $templates{$tmpl_name};
83 101 ▶ die "Invalid template name $tmpl_name" unless defined $tmpl_text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tmpl_text 0 101 101
84  
85 10 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
86 101 $text =~ s/\%$tmpl_name\%/$tmpl_text/g;
87 }
88 101 return $text;
89 10 };
90 }
91  
92 10 *layer_func_pod = x_pod([qw(TMPL_COMMON_ARGS)]);
93  
94 # got from Mojo::Util
95 115 ▶sub unindent {
Subroutine unindent: called CC=3 SCAR=11.0
Pod undocumented
96 115 my $str = shift;
97 115 ▶ my $min = min map { m/^([ \t]*)/; length $1 || () } split "\n", $str;
Condition66%2/3
length $1 || ()
l!l&&r!l&&!r
204811370
MC/DC0%0/2
length $1 || ()
length $1 ()
Truth table66%2/3
A || B
A= length $1B= ()
ABresult
1X1
011
000
98 115 ▶ $str =~ s/^[ \t]{0,$min}//gm if $min;
Branch: 1 branch
BranchTrueFalseTotal
if $min 114 1 115
99 115 return $str;
100 }
101  
102 10 1;
103  
104 __END__
« Chart/GGPlot/Position/Identity.pm ↑ Summary Chart/GGPlot/Backend/Plotly/Geom/Blank.pm »