Khonsu/Ra.pm

filter: Statementstmt 98.3% 177 / 180 Branchbran 72.7% 16 / 22 Conditioncond 83.3% 5 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 96.8% 62 / 64 Podpod 0.0% 0 / 5 totaltotal 93.2% 262 / 281 CC 15 SCAR 7.9
CC
15
Cov
95%
new
9.2
AUTOLOAD
3.1
set_attributes
3.0
CRAP 2.2
« Khonsu/Page.pm ↑ Summary Khonsu/Text/Subtitle.pm »
1 package Khonsu::Ra;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Khonsu::Shape::Line;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Khonsu::Shape::Box;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Khonsu::Shape::Circle;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Khonsu::Shape::Pie;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Khonsu::Shape::Ellipse;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Khonsu::Font;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Khonsu::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Khonsu::Text::H1;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Khonsu::Text::H2;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use Khonsu::Text::H3;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Khonsu::Text::H4;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use Khonsu::Text::H5;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Khonsu::Text::H6;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶use Types::Standard qw/Str Object ArrayRef HashRef Num Bool/;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 ▶use constant RW => (is => 'rw');
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use constant REQ => (required => 1);
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use constant STR => (isa => Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use constant OBJ => (isa => Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use constant BOOL => (isa => Bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶use constant AR => (isa => ArrayRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 2 ▶use constant HR => (isa => HashRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 2 ▶use constant DAR => (isa => ArrayRef, default => sub { [ ] });
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
32 2 ▶use constant DHR => (isa => HashRef, default => sub { { } });
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
33 2 ▶use constant NUM => (isa => Num);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 2 use constant POINTS => (
35 x => {is => 'rw', isa => Num},
36 y => {is => 'rw', isa => Num},
37 w => {is => 'rw', isa => Num},
38 h => {is => 'rw', isa => Num},
39 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
40 use constant LINE => (
41 1 ▶ line => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Line->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
42 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
43 use constant BOX => (
44 3 ▶ box => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Box->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
45 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
46 use constant CIRCLE => (
47 1 ▶ circle => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Circle->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
48 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
49 use constant PIE => (
50 1 ▶ pie => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Pie->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
51 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
52 use constant ELLIPSE => (
53 1 ▶ ellipse => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Ellipse->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
54 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
55 use constant FONT => (
56 8 ▶ font => {is => 'rw', isa => Object, default => sub { Khonsu::Font->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
57 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
58 use constant TEXT => (
59 1 ▶ text => {is => 'rw', isa => Object, default => sub { Khonsu::Text->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
60 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
61 use constant H1 => (
62 1 ▶ h1 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H1->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
63 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
64 use constant H2 => (
65 1 ▶ h2 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H2->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
66 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
67 use constant H3 => (
68 1 ▶ h3 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H3->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
69 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
70 use constant H4 => (
71 1 ▶ h4 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H4->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
72 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
73 use constant H5 => (
74 1 ▶ h5 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H5->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
75 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
76 use constant H6 => (
77 1 ▶ h6 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H6->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
78 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 sub new {
81 25 ▶ my ($pkg, %params) = @_;
Subroutine new: called CC=9 SCAR=22.2
Pod undocumented
82  
83 25 my $self = bless {
84 attributes => {}
85 }, $pkg;
86  
87 25 my @attributes = $self->attributes();
88  
89 25 ▶ for (my $i = 0; $i < $#attributes; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#attributes) 148 25 173
90 148 my ($key, $value) = ($attributes[$i], $attributes[$i + 1]);
91 0 ▶ $self->{attributes}->{$key} = $value->{is} eq 'ro' ? sub { $_[0]->{$key}; } : sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 436 ▶ my ($self, $val) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
93 436 ▶ if (defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val) 97 339 436
94 97 ▶ if ($value->{isa}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"isa"}) 85 12 97
95 85 $val = $value->{isa}->($val);
96 }
97 97 $self->{$key} = $val;
98 }
99 436 return $self->{$key};
100 148 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$value->{'is'} eq 'ro' ? : 0 148 148
101  
102 148 ▶ if ($value->{required} && ! defined $params{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"required"} and not defined $params{$key}) 0 148 148
Condition66%2/3
$value->{"required"} and not defined $params{$key}
!ll&&!rl&&r
14170
MC/DC0%0/2
$value->{"required"} and not defined $params{$key}
$value->{"required"} not defined $params{$key}
Truth table66%2/3
A and not(B)
A= $value->{"required"}B= not defined $params{$key}
ABresult
0X0
100
111
103 0 die "$key is required";
104 }
105
106 148 ▶ if ($value->{default} && !$params{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"default"} and not $params{$key}) 78 70 148
Condition100%3/3
$value->{"default"} and not $params{$key}
!ll&&!rl&&r
69178
MC/DC100%2/2
$value->{"default"} and not $params{$key}
$value->{"default"} not $params{$key}
Truth table100%3/3
A and not(B)
A= $value->{"default"}B= not $params{$key}
ABresult
0X0
100
111
107 78 $params{$key} = $value->{default}->($self);
108 }
109  
110 148 ▶ if ($params{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params{$key}) 80 68 148
111 80 ▶ if ($value->{isa}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"isa"}) 80 0 80
112 80 $params{$key} = $value->{isa}->($params{$key});
113 }
114 80 $self->{$key} = $params{$key};
115 }
116 }
117
118 25 return $self;
119 }
120  
121 sub set_points {
122 2 ▶ my ($self, $mx, $my, $mw, $mh) = @_;
Subroutine set_points: called CC=1 SCAR=0.0
Pod undocumented
123 2 $self->x($mx);
124 2 $self->y($my);
125 2 $self->w($mw);
126 2 $self->h($mh);
127 2 return $self;
128 }
129  
130 sub get_points {
131 14 ▶ my ($self) = shift;
Subroutine get_points: called CC=1 SCAR=0.0
Pod undocumented
132 return (
133 14 x => $self->x,
134 y => $self->y,
135 w => $self->w,
136 h => $self->h
137 );
138 }
139  
140 7 ▶sub attributes { return (); }
Subroutine attributes: called CC=1 SCAR=0.0
Pod undocumented
141  
142 sub set_attributes {
143 24 ▶ my ($self, %params) = @_;
Subroutine set_attributes: called CC=3 SCAR=11.1
Pod undocumented
144 24 for (keys %params) {
145 78 ▶ next unless $self->{attributes}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"attributes"}{$_} 0 78 78
146 78 $self->{attributes}->{$_}($self, $params{$_});
147 }
148 24 return $self;
149 }
150  
151 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
152  
153 sub AUTOLOAD {
154 358 ▶ my $classname = ref $_[0];
Subroutine AUTOLOAD: called CC=3 SCAR=11.4
155 358 my $validname = '[_a-zA-Z][\:a-zA-Z0-9_]*';
156 358 our $AUTOLOAD =~ /^${classname}::($validname)$/;
157 358 my $key = $1;
158 358 ▶ die "illegal key name, must be of $validname form\n$AUTOLOAD" unless $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 0 358 358
159 358 ▶ if ( $_[0]->{attributes}->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]{'attributes'}{$key}) { } 358 0 358
160 358 $_[0]->{attributes}->{$key}->(@_);
161 } else {
162 0 die "illegal use of AUTOLOAD $classname -> $key -";
163 }
164 }
165  
166 2 1;
« Khonsu/Page.pm ↑ Summary Khonsu/Text/Subtitle.pm »