| 1 | package Gnuplot::Builder::Template; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Exporter 5.57 qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Gnuplot::Builder::JoinDict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | our @EXPORT_OK = qw(gusing gevery); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub _create_hyphen_validator { | ||||||||||||||||||||||||||||
| 11 | 6 | ▶ | my ($allowed_keys_arrayref) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_create_hyphen_validator: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | my %allowed_keys = map { $_ => 1 } @$allowed_keys_arrayref; | |||||||||||||||||||||||||||
| 13 | return sub { | ||||||||||||||||||||||||||||
| 14 | 121 | ▶ | my ($dict) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 15 | 121 | foreach my $hyphen_key (grep { substr($_, 0, 1) eq "-" } $dict->get_all_keys) { | |||||||||||||||||||||||||||
| 16 | 4294 | ▶ | croak "Unknown key: $hyphen_key" if !$allowed_keys{$hyphen_key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | 6 | }; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | our $USING; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||
| 24 | 3 | my @using_keys = grep { substr($_, 0, 1) eq "-" } | |||||||||||||||||||||||||||
| 25 | qw( | ||||||||||||||||||||||||||||
| 26 | USE CASES | KEYS | ||||||||||||||||||||||||||||
| 27 | ================+============================================== | ||||||||||||||||||||||||||||
| 28 | | -x -y | ||||||||||||||||||||||||||||
| 29 | filledcurves | -y1 -y2 | ||||||||||||||||||||||||||||
| 30 | | -z | ||||||||||||||||||||||||||||
| 31 | polar | -t | ||||||||||||||||||||||||||||
| 32 | image | -value | ||||||||||||||||||||||||||||
| 33 | smooth kdensity | -weight -bandwidth | ||||||||||||||||||||||||||||
| 34 | rgbalpha | -r -g -b -a | ||||||||||||||||||||||||||||
| 35 | labels | -string -label | ||||||||||||||||||||||||||||
| 36 | vectors | -xdelta -ydelta -zdelta | ||||||||||||||||||||||||||||
| 37 | xerrorbars | -xlow -xhigh | ||||||||||||||||||||||||||||
| 38 | yerrorbars | -ylow -yhigh | ||||||||||||||||||||||||||||
| 39 | financebars | -date -open -low -high -close | ||||||||||||||||||||||||||||
| 40 | candlesticks | -box_min -whisker_min -whisker_high -box_high | ||||||||||||||||||||||||||||
| 41 | boxes | -x_width | ||||||||||||||||||||||||||||
| 42 | boxplot | -boxplot_factor | ||||||||||||||||||||||||||||
| 43 | circles | -radius -start_angle -end_angle | ||||||||||||||||||||||||||||
| 44 | ellipses | -major_diam -minor_diam -angle | ||||||||||||||||||||||||||||
| 45 | variable style | -pointsize -arrowstyle -linecolor | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | $USING = Gnuplot::Builder::JoinDict->new( | ||||||||||||||||||||||||||||
| 49 | separator => ":", | ||||||||||||||||||||||||||||
| 50 | 3 | content => [map { $_ => undef } @using_keys], | |||||||||||||||||||||||||||
| 51 | validator => _create_hyphen_validator(\@using_keys), | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 3 | our $EVERY; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||
| 58 | 3 | my @every_keys = | |||||||||||||||||||||||||||
| 59 | qw( | ||||||||||||||||||||||||||||
| 60 | -point_incr | ||||||||||||||||||||||||||||
| 61 | -block_incr | ||||||||||||||||||||||||||||
| 62 | -start_point | ||||||||||||||||||||||||||||
| 63 | -start_block | ||||||||||||||||||||||||||||
| 64 | -end_point | ||||||||||||||||||||||||||||
| 65 | -end_block | ||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||
| 67 | $EVERY = Gnuplot::Builder::JoinDict->new( | ||||||||||||||||||||||||||||
| 68 | separator => ":", | ||||||||||||||||||||||||||||
| 69 | 15 | content => [$every_keys[0] => 1, map { $_ => undef } @every_keys[1 .. $#every_keys]], | |||||||||||||||||||||||||||
| 70 | validator => _create_hyphen_validator(\@every_keys), | ||||||||||||||||||||||||||||
| 71 | filter => sub { | ||||||||||||||||||||||||||||
| 72 | 18 | ▶ | my ($dict) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||
| 73 | 18 | my @values = $dict->get_all_values; | |||||||||||||||||||||||||||
| 74 | 18 | my ($first_def_index, $last_def_index); | |||||||||||||||||||||||||||
| 75 | 18 | foreach my $front_i (0 .. $#values) { | |||||||||||||||||||||||||||
| 76 | 68 | my $rear_i = $#values - $front_i; | |||||||||||||||||||||||||||
| 77 | 68 | ▶ | if(!defined($first_def_index) && defined($values[$front_i])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $first_def_index and defined $values[$front_i]
MC/DC100%2/2
not defined $first_def_index and defined $values[$front_i]
not defined $first_def_index
defined $values[$front_i]
Truth table100%3/3
not(A) and B
A= not defined $first_def_indexB= defined $values[$front_i]
| |||||||||||||||||||||||||||||
| 78 | 17 | $first_def_index = $front_i; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 68 | ▶ | if(!defined($last_def_index) && defined($values[$rear_i])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $last_def_index and defined $values[$rear_i]
MC/DC100%2/2
not defined $last_def_index and defined $values[$rear_i]
not defined $last_def_index
defined $values[$rear_i]
Truth table100%3/3
not(A) and B
A= not defined $last_def_indexB= defined $values[$rear_i]
| |||||||||||||||||||||||||||||
| 81 | 17 | $last_def_index = $rear_i; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | 68 | ▶ | if(defined($first_def_index) && defined($last_def_index)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $first_def_index and defined $last_def_index
MC/DC100%2/2
defined $first_def_index and defined $last_def_index
defined $first_def_index
defined $last_def_index
Truth table100%3/3
A and B
A= defined $first_def_indexB= defined $last_def_index
| |||||||||||||||||||||||||||||
| 84 | 17 | last; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 18 | ▶ | return () if !defined($first_def_index) || !defined($last_def_index); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $first_def_index and defined $last_def_index
MC/DC50%1/2
defined $first_def_index and defined $last_def_index
defined $first_def_index
defined $last_def_index
Truth table66%2/3
A and B
A= defined $first_def_indexB= defined $last_def_index
| |||||||||||||||||||||||||||||
| 88 | return map { | ||||||||||||||||||||||||||||
| 89 | 17 | ▶ | defined($_) ? $_ : "" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | } @values[$first_def_index .. $last_def_index]; | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 3 | ); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | sub gusing { | ||||||||||||||||||||||||||||
| 96 | 96 | ▶ | return $USING->set(@_); | ||||||||||||||||||||||||||
|
Subroutine
gusing: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | sub gevery { | ||||||||||||||||||||||||||||
| 100 | 18 | ▶ | return $EVERY->set(@_); | ||||||||||||||||||||||||||
|
Subroutine
gevery: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 3 | 1; | |||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||