Chart/Types.pm

filter: Statementstmt 61.4% 35 / 57 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 100% 1 / 1 totaltotal 53.0% 43 / 81 CC 5 SCAR 18.9
CC
5
Cov
53%
__ANON__
20.0
__ANON__
6.0
__ANON__
2.0
CRAP 6.6
« Chart/Axis/Style.pm ↑ Summary Chart/Type/Bar.pm »
1 # $Id$
2  
3 package Google::Chart::Types;
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 exports => [ qw(hash_coercion) ]
10 1 };
11  
12 2 ▶sub hash_coercion {
Subroutine hash_coercion: called CC=1 SCAR=3.9
Pod documented
13 2 my (%args) = @_;
14  
15 2 my $default = $args{default};
16 2 my $prefix = $args{prefix};
17  
18 0 ▶ return sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
19 0 my $h = $_;
20 0 ▶ my $module = $h->{module} || $default ||
Condition0%0/5
$h->{'module'} || $default || Carp::confess('No module name provided for coercion')
l!l
00
$h->{"module"} or $default
l!l&&r!l&&!r
000
MC/DC0%0/2
$h->{'module'} || $default || Carp::confess('No module name provided for coercion')
$h->{"module"} $default
Truth table0%0/3
A or B
A= $h->{"module"}B= $default
ABresult
1X1
011
000
21 Carp::confess("No module name provided for coercion");
22 0 ▶ if ($module !~ s/^\+//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($module =~ s/^\+//) 0 0 0
23 0 $module = join('::', $prefix, $module);
24 }
25 0 Class::MOP::load_class( $module );
26 0 return $module->new(%{ $h->{args} });
27 }
28 2 }
29  
30 {
31 1 role_type 'Google::Chart::Type';
32 coerce 'Google::Chart::Type'
33 => from 'Str'
34 0 ▶ => via {
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 my $class = sprintf( 'Google::Chart::Type::%s', ucfirst $_ );
36 0 Class::MOP::load_class($class);
37  
38 0 return $class->new();
39 }
40 1 ;
41 1 coerce 'Google::Chart::Type'
42 => from 'HashRef'
43 => hash_coercion(prefix => "Google::Chart::Type")
44 ;
45 }
46  
47 {
48 1 role_type 'Google::Chart::Fill';
49 coerce 'Google::Chart::Fill'
50 => from 'Str'
51 0 ▶ => via {
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 my $class = sprintf( 'Google::Chart::Fill::%s', ucfirst $_ );
53 0 Class::MOP::load_class($class);
54  
55 0 return $class->new();
56 }
57 1 ;
58 1 coerce 'Google::Chart::Fill'
59 => from 'HashRef'
60 => hash_coercion(prefix => "Google::Chart::Fill")
61 ;
62 }
63  
64 {
65 1 role_type 'Google::Chart::Data';
66 coerce 'Google::Chart::Data'
67 => from 'ArrayRef'
68 0 ▶ => via {
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 0 my $class = 'Google::Chart::Data::Text';
70 0 Class::MOP::load_class($class);
71 0 $class->new(dataset => $_);
72 }
73 1 ;
74 coerce 'Google::Chart::Data'
75 => from 'HashRef'
76 0 ▶ => via {
Subroutine __ANON__: not called CC=2 SCAR=17.9
77 0 my $class = $_->{module};
78 0 ▶ if ($class !~ s/^\+//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class =~ s/^\+//) 0 0 0
79 0 $class = "Google::Chart::Data::$class";
80 }
81 0 Class::MOP::load_class($class);
82  
83 0 $class->new(%{$_->{args}});
84 }
85 1 ;
86 }
87  
88 1 ▶no Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
89  
90 1 1;
91  
92 __END__
« Chart/Axis/Style.pm ↑ Summary Chart/Type/Bar.pm »