Khonsu/Ra.pm

filter: Statementstmt 98.6% 214 / 217 Branchbran 77.2% 17 / 22 Conditioncond 83.3% 5 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 97.4% 77 / 79 Podpod 0.0% 0 / 6 totaltotal 94.3% 315 / 334 CC 15 SCAR 6.9
CC
15
Cov
96%
new
9.2
AUTOLOAD
3.1
__ANON__
3.0
CRAP 2.0
« Khonsu/Font.pm ↑ Summary Khonsu.pm »
1 package Khonsu::Ra;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Clone;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Khonsu::Shape::Line;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Khonsu::Shape::Box;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Khonsu::Shape::Circle;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Khonsu::Shape::Pie;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Khonsu::Shape::Ellipse;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use Khonsu::Font;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 ▶use Khonsu::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Khonsu::Text::H1;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use Khonsu::Text::H2;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use Khonsu::Text::H3;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use Khonsu::Text::H4;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use Khonsu::Text::H5;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶use Khonsu::Text::H6;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 3 ▶use Khonsu::Image;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 3 ▶use Khonsu::Form;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 3 ▶use Khonsu::Form::Field::Input;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29  
30 3 ▶use Khonsu::TOC;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 3 ▶use Types::Standard qw/Str Object ArrayRef HashRef Num Bool CodeRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 3 ▶use constant RW => (is => 'rw');
Subroutine BEGIN: called CC=1 SCAR=0.0
35 3 ▶use constant REQ => (required => 1);
Subroutine BEGIN: called CC=1 SCAR=0.0
36 3 ▶use constant STR => (isa => Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
37 3 ▶use constant OBJ => (isa => Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
38 3 ▶use constant BOOL => (isa => Bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
39 3 ▶use constant AR => (isa => ArrayRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
40 3 ▶use constant HR => (isa => HashRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
41 3 ▶use constant DAR => (isa => ArrayRef, default => sub { [ ] });
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
42 3 ▶use constant DHR => (isa => HashRef, default => sub { { } });
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
43 3 ▶use constant NUM => (isa => Num);
Subroutine BEGIN: called CC=1 SCAR=0.0
44 3 ▶use constant CODE => (isa => CodeRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
45 3 use constant POINTS => (
46 x => {is => 'rw', isa => Num},
47 y => {is => 'rw', isa => Num},
48 w => {is => 'rw', isa => Num},
49 h => {is => 'rw', isa => Num},
50 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
51 use constant LINE => (
52 2 ▶ line => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Line->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
53 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
54 use constant BOX => (
55 124 ▶ box => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Box->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
56 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
57 use constant CIRCLE => (
58 2 ▶ circle => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Circle->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
59 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
60 use constant PIE => (
61 2 ▶ pie => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Pie->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
62 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
63 use constant ELLIPSE => (
64 2 ▶ ellipse => {is => 'rw', isa => Object, default => sub { Khonsu::Shape::Ellipse->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
65 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
66 use constant FONT => (
67 636 ▶ font => {is => 'rw', isa => Object, default => sub { Khonsu::Font->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
68 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
69 use constant TEXT => (
70 2 ▶ text => {is => 'rw', isa => Object, default => sub { Khonsu::Text->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
71 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
72 use constant H1 => (
73 2 ▶ h1 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H1->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
74 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
75 use constant H2 => (
76 2 ▶ h2 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H2->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
77 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
78 use constant H3 => (
79 2 ▶ h3 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H3->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
80 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
81 use constant H4 => (
82 2 ▶ h4 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H4->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
83 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
84 use constant H5 => (
85 2 ▶ h5 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H5->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
86 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
87 use constant H6 => (
88 2 ▶ h6 => {is => 'rw', isa => Object, default => sub { Khonsu::Text::H6->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
89 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
90 use constant IMAGE => (
91 2 ▶ image => {is => 'rw', isa => Object, default => sub { Khonsu::Image->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
92 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
93 use constant TOC => (
94 2 ▶ toc => {is => 'rw', isa => Object, default => sub { Khonsu::TOC->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
95 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
96 use constant FORM => (
97 2 ▶ form => {is => 'rw', isa => Object, default => sub { Khonsu::Form->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
98 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
99 use constant INPUT => (
100 2 ▶ input => {is => 'rw', isa => Object, default => sub { Khonsu::Form::Field::Input->new() }}
Subroutine __ANON__: called CC=1 SCAR=0.0
101 3 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
102  
103 sub new {
104 1530 ▶ my ($pkg, %params) = @_;
Subroutine new: called CC=9 SCAR=22.2
Pod undocumented
105  
106 1530 my $self = bless {
107 attributes => {}
108 }, $pkg;
109 1530 my @attributes = $self->attributes();
110 1530 ▶ for (my $i = 0; $i < $#attributes; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#attributes) 16894 1530 18424
111 16894 my ($key, $value) = ($attributes[$i], $attributes[$i + 1]);
112 0 ▶ $self->{attributes}->{$key} = $value->{is} eq 'ro' ? sub { $_[0]->{$key}; } : sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
113 99292 ▶ my ($self, $val) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
114 99292 ▶ if (defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val) 16807 82485 99292
115 16807 ▶ if ($value->{isa}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"isa"}) 16803 4 16807
116 16803 $val = $value->{isa}->($val);
117 }
118 16807 $self->{$key} = $val;
119 }
120 99292 return $self->{$key};
121 16894 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$value->{'is'} eq 'ro' ? : 0 16894 16894
122  
123 16894 ▶ if ($value->{required} && ! defined $params{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"required"} and not defined $params{$key}) 0 16894 16894
Condition66%2/3
$value->{"required"} and not defined $params{$key}
!ll&&!rl&&r
166442500
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
124 0 die "$key is required";
125 }
126
127 16894 ▶ if ($value->{default} && !$params{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"default"} and not $params{$key}) 6968 9926 16894
Condition100%3/3
$value->{"default"} and not $params{$key}
!ll&&!rl&&r
992246968
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
128 6968 $params{$key} = $value->{default}->($self);
129 }
130  
131 16894 ▶ if (defined $params{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $params{$key}) 12134 4760 16894
132 12134 ▶ if ($value->{isa}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->{"isa"}) 12134 0 12134
133 12134 $params{$key} = $value->{isa}->($params{$key});
134 }
135 12134 $self->{$key} = $params{$key};
136 }
137 }
138
139 1530 return $self;
140 }
141  
142 sub set_points {
143 122 ▶ my ($self, $mx, $my, $mw, $mh) = @_;
Subroutine set_points: called CC=1 SCAR=0.0
Pod undocumented
144 122 $self->x($mx);
145 122 $self->y($my);
146 122 $self->w($mw);
147 122 $self->h($mh);
148 122 return $self;
149 }
150  
151 sub get_points {
152 3073 ▶ my ($self) = shift;
Subroutine get_points: called CC=1 SCAR=0.0
Pod undocumented
153 return (
154 3073 x => $self->x,
155 y => $self->y,
156 w => $self->w,
157 h => $self->h
158 );
159 }
160  
161 132 ▶sub attributes { return (); }
Subroutine attributes: called CC=1 SCAR=0.0
Pod undocumented
162  
163 sub set_attributes {
164 4674 ▶ my ($self, %params) = @_;
Subroutine set_attributes: called CC=3 SCAR=11.0
Pod undocumented
165 4674 for (keys %params) {
166 13442 ▶ next unless $self->{attributes}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"attributes"}{$_} 3672 9770 13442
167 9770 $self->{attributes}->{$_}($self, $params{$_});
168 }
169 4674 return $self;
170 }
171  
172 sub clone {
173 238 ▶ my ($self) = @_;
Subroutine clone: called CC=1 SCAR=0.0
Pod undocumented
174 238 my $ref = ref $self;
175 238 return bless Clone::clone($self), $ref;
176 }
177  
178 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
179  
180 sub AUTOLOAD {
181 89522 ▶ my $classname = ref $_[0];
Subroutine AUTOLOAD: called CC=3 SCAR=11.4
182 89522 my $validname = '[_a-zA-Z][\:a-zA-Z0-9_]*';
183 89522 our $AUTOLOAD =~ /^${classname}::($validname)$/;
184 89522 my $key = $1;
185 89522 ▶ die "illegal key name, must be of $validname form\n$AUTOLOAD" unless $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 0 89522 89522
186 89522 ▶ if ( $_[0]->{attributes}->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]{'attributes'}{$key}) { } 89522 0 89522
187 89522 $_[0]->{attributes}->{$key}->(@_);
188 } else {
189 0 die "illegal use of AUTOLOAD $classname -> $key -";
190 }
191 }
192  
193 3 1;
« Khonsu/Font.pm ↑ Summary Khonsu.pm »