Chart/Type/Pie.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 2 SCAR 12.0
CC
2
Cov
0%
_build_type
6.0
_build_labels
2.0
BEGIN
2.0
CRAP 3.3
1  
2 package Google::Chart::Type::Pie;
3 use Moose;
4 use Moose::Util::TypeConstraints;
5 use namespace::clean -except => qw(meta);
6  
7 extends 'Google::Chart';
8 with qw(
9 Google::Chart::WithData
10 Google::Chart::WithGrid
11 Google::Chart::WithSolidFill
12 );
13  
14 # NOTE: exists in en version, but not in ja
15 has orientation => (
16 is => 'ro',
17 isa => 'Num',
18 );
19  
20 # NOTE: pc does not exist in ja
21 has pie_type => ( # this *needs* the pie_ prefix cause it clashes
22 # with the parent class's type... but the rest shouldn't
23 is => 'ro',
24 isa => enum([ qw(2d 3d pc) ]),
25 required => 1,
26 default => '2d'
27 );
28  
29 # This option begs the question: can it be in the dataset?
30 has labels => (
31 traits => ['Array'],
32 is => 'ro',
33 isa => 'ArrayRef',
34 lazy_build => 1,
35 handles => {
36 add_labels => 'push',
37 }
38 );
39  
40 sub _build_labels { [] }
41  
42 sub _build_type {
43 my $self = shift;
44 return $self->pie_type eq '3d' ? 'p3' : 'p';
45 }
46  
47 around prepare_query => sub {
48 my ($next, $self, @args) = @_;
49 my @query = $next->($self, @args);
50  
51 my $labels = $self->labels();
52 if (@$labels > 0) {
53 push @query, (chl => join('|', map { defined $_ ? $_ : '' } @$labels));
54 }
55  
56 if ($self->orientation) {
57 push @query, (chp => $self->orientation);
58 }
59  
60 return @query;
61 };
62  
63 __PACKAGE__->meta->make_immutable;
64  
65 1;
66  
67 __END__