Clicker/Data/DataSet.pm

filter: Statementstmt 87.6% 57 / 65 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 91.6% 11 / 12 Podpod 83.3% 5 / 6 totaltotal 85.1% 86 / 101 CC 13 SCAR 16.0
CC
13
Cov
86%
get_all_series_keys
12.0
largest_value_slice
7.1
prepare
5.0
CRAP 5.0
« Clicker/Data/Range.pm ↑ Summary Clicker/Axis/DivisionType/LinearRounded.pm »
1 package Chart::Clicker::Data::DataSet;
2 8 $Chart::Clicker::Data::DataSet::VERSION = '2.90';
3 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: A collection of series
6  
7 8 ▶use Chart::Clicker::Data::Range;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 8 has 'context' => (
11 is => 'rw',
12 isa => 'Str',
13 default => 'default'
14 );
15  
16  
17 has 'domain' => (
18 is => 'rw',
19 isa => 'Chart::Clicker::Data::Range',
20 9 ▶ default => sub { Chart::Clicker::Data::Range->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
21 8 );
22  
23  
24 8 has 'max_key_count' => ( is => 'rw', isa => 'Int', default => 0 );
25  
26  
27 has 'range' => (
28 is => 'rw',
29 isa => 'Chart::Clicker::Data::Range',
30 9 ▶ default => sub { Chart::Clicker::Data::Range->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
31 8 );
32  
33  
34 has 'series' => (
35 traits => [ 'Array' ],
36 is => 'rw',
37 isa => 'ArrayRef',
38 2 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
39 8 handles => {
40 'count' => 'count',
41 'add_to_series' => 'push',
42 'get_series' => 'get'
43 }
44 );
45  
46  
47 0 ▶sub get_all_series_keys {
Subroutine get_all_series_keys: not called CC=3 SCAR=24.8
Pod documented
48 0 my ($self) = @_;
49  
50 0 my %keys;
51 0 for my $series (@{$self->series}) {
52 0 foreach (@{$series->keys}) { $keys{$_} = 1};
53 }
54 0 return keys %keys;
55 }
56  
57  
58 1 ▶sub get_series_keys {
Subroutine get_series_keys: called CC=1 SCAR=0.0
Pod documented
59 1 my ($self, $position) = @_;
60  
61 1 return map({ $_->keys->[$position] } @{ $self->series });
62 }
63  
64  
65 5 ▶sub get_series_values {
Subroutine get_series_values: called CC=1 SCAR=0.0
Pod documented
66 5 my ($self, $position) = @_;
67  
68 5 return [ map({ $_->values->[$position] } @{ $self->series }) ];
69 }
70  
71  
72 2 ▶sub get_series_values_for_key {
Subroutine get_series_values_for_key: called CC=1 SCAR=0.0
Pod documented
73 2 my ($self, $key) = @_;
74  
75 2 return [ map({ $_->get_value_for_key($key) } @{ $self->series }) ];
76 }
77  
78  
79 1 ▶sub largest_value_slice {
Subroutine largest_value_slice: called CC=7 SCAR=19.5
Pod documented
80 1 my ($self) = @_;
81  
82 # Prime out big variable with the value of the first slice
83 1 my $big;
84 1 foreach (@{ $self->get_series_values(0) }) { $big += $_; }
85  
86 # Check that value against all the remaining slices
87 1 for my $i (0 .. $self->max_key_count - 1) {
88 3 my $t;
89 3 ▶ foreach (@{ $self->get_series_values($i) }) { $t += $_ if defined($_); }
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 6 0 6
90 3 ▶ $big = $t if(($t > $big) || !defined($big));
Branch: 1 branch
BranchTrueFalseTotal
if $t > $big or not defined $big 1 2 3
Condition66%2/3
$t > $big or not defined $big
l!l&&r!l&&!r
102
MC/DC50%1/2
$t > $big or not defined $big
$t > $big not defined $big
Truth table66%2/3
A or not(B)
A= $t > $bigB= not defined $big
ABresult
1X1
011
000
91 }
92 1 return $big;
93 }
94  
95 2 ▶sub prepare {
Subroutine prepare: called CC=5 SCAR=16.1
Pod undocumented
96 2 my ($self) = @_;
97  
98 2 ▶ unless($self->count && $self->count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->count and $self->count > 0) 1 1 2
Condition66%2/3
$self->count and $self->count > 0
!ll&&!rl&&r
101
MC/DC50%1/2
$self->count and $self->count > 0
$self->count $self->count > 0
Truth table66%2/3
A and B
A= $self->countB= $self->count > 0
ABresult
0X0
100
111
99 1 die('Dataset has no series.');
100 }
101  
102 1 foreach my $series (@{ $self->series }) {
103 2 $series->prepare;
104  
105 2 $self->range->combine($series->range);
106  
107 2 my @keys = @{ $series->keys };
108  
109 2 $self->domain->combine(
110 Chart::Clicker::Data::Range->new({
111 lower => $keys[0], upper => $keys[ $#keys ]
112 })
113 );
114  
115 2 ▶ if($series->key_count > $self->max_key_count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($series->key_count > $self->max_key_count) 1 1 2
116 1 $self->max_key_count($series->key_count);
117 }
118 }
119  
120 1 return 1;
121 }
122  
123 8 __PACKAGE__->meta->make_immutable;
124  
125 8 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 8 1;
128  
129 __END__
« Clicker/Data/Range.pm ↑ Summary Clicker/Axis/DivisionType/LinearRounded.pm »