Chart/WithRangeMarker.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 56 CC 1 SCAR 6.9
CC
1
Cov
0%
_build_range_markers
2.0
add_range_marker
2.0
BEGIN
2.0
CRAP 2.0
1 package Google::Chart::WithRangeMarker;
2 use Moose::Role;
3 use namespace::clean -except => qw(meta);
4  
5 has range_markers => (
6 is => 'ro',
7 isa => 'ArrayRef',
8 lazy_build => 1,
9 );
10  
11 sub _build_range_markers { [] }
12  
13 sub add_range_marker {
14 my ($self, @args) = @_;
15 push @{ $self->range_markers },
16 Google::Chart::RangeMarker->new(@args);
17 return $self;
18 }
19  
20 around prepare_query => sub {
21 my ($next, $self, @args) = @_;
22  
23 my @query = $next->($self, @args);
24 my $markers = $self->range_markers;
25 my $max = scalar @$markers - 1;
26  
27 my @chm;
28 for my $i (0..$max) {
29 my $marker = $markers->[$i];
30 push @chm, join(',',
31 ($marker->orientation || '') eq 'vertical' ? 'R' : 'r',
32 $marker->color,
33 0,
34 $marker->start,
35 $marker->end,
36 );
37 }
38  
39 if (@chm) {
40 push @query, (chm => join('|', @chm));
41 }
42  
43 return @query;
44 };
45  
46 package Google::Chart::RangeMarker;
47 use Moose;
48 use Moose::Util::TypeConstraints;
49 use namespace::clean -except => qw(meta);
50  
51 has orientation => (
52 is => 'ro',
53 isa => enum([ qw(horizontal vertical) ]),
54 predicate => 'has_orientation',
55 );
56  
57 has color => (
58 is => 'ro',
59 isa => 'Str',
60 predicate => 'has_color',
61 );
62  
63 has start => (
64 is => 'ro',
65 isa => 'Num',
66 predicate => 'has_start',
67 );
68  
69 has end => (
70 is => 'ro',
71 isa => 'Num',
72 predicate => 'has_end',
73 );
74  
75 __PACKAGE__->meta->make_immutable();
76  
77 1;