blib/lib/Tags/HTML/GradientIndicator.pm

filter: Statementstmt 91.6% 33 / 36 Branchbran 100% 4 / 4 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 85.7% 6 / 7 Podpod 100% 3 / 3 totaltotal 93.3% 56 / 60 SCAR 16.1
CC
5
Cov
93%
new
5.0
process_css
2.0
BEGIN
1.0
CRAP 5.0
↑ Summary
1 package Tags::HTML::GradientIndicator;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = 0.02;
10  
11 # Constructor.
12 sub new {
13 7 ▶ my ($class, @params) = @_;
Subroutine new: called CC=5 SCAR=16.1
Pod documented
14  
15 # Create object.
16 7 my $self = bless {}, $class;
17  
18 # 'CSS::Struct::Output' object.
19 7 $self->{'css'} = undef;
20  
21 # Default gradient is left-right direction from red to violet.
22 7 $self->{'css_background_image'} = 'linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)';
23  
24 # Gradient CSS class.
25 7 $self->{'css_gradient_class'} = 'gradient';
26  
27 # Height.
28 7 $self->{'height'} = 30;
29  
30 # Unit.
31 7 $self->{'unit'} = 'px';
32  
33 # Width.
34 7 $self->{'width'} = 500;
35  
36 # 'Tags::Output' object.
37 7 $self->{'tags'} = undef;
38  
39 # Process params.
40 7 set_params($self, @params);
41  
42 # Check to 'CSS::Struct::Output' object.
43 7 ▶ if ($self->{'css'} && ! $self->{'css'}->isa('CSS::Struct::Output')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")) 1 6 7
Condition100%3/3
$self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")
!ll&&!rl&&r
511
MC/DC100%2/2
$self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")
$self->{"css"} not $self->{"css"}->isa("CSS::Struct::Output")
Truth table100%3/3
A and not(B)
A= $self->{"css"}B= not $self->{"css"}->isa("CSS::Struct::Output")
ABresult
0X0
100
111
44 1 err "Parameter 'css' must be a 'CSS::Struct::Output::*' class.";
45 }
46  
47 # Check to 'Tags' object.
48 6 ▶ if (! $self->{'tags'} || ! $self->{'tags'}->isa('Tags::Output')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tags"} and $self->{"tags"}->isa("Tags::Output")) 2 4 6
Condition100%3/3
$self->{"tags"} and $self->{"tags"}->isa("Tags::Output")
!ll&&!rl&&r
114
MC/DC100%2/2
$self->{"tags"} and $self->{"tags"}->isa("Tags::Output")
$self->{"tags"} $self->{"tags"}->isa("Tags::Output")
Truth table100%3/3
A and B
A= $self->{"tags"}B= $self->{"tags"}->isa("Tags::Output")
ABresult
0X0
100
111
49 2 err "Parameter 'tags' must be a 'Tags::Output::*' class.";
50 }
51  
52 # Object.
53 4 return $self;
54 }
55  
56 # Process 'Tags'.
57 sub process {
58 3 ▶ my ($self, $percent_value) = @_;
Subroutine process: called CC=1 SCAR=0.0
Pod documented
59  
60 # Value.
61 3 my $value = $percent_value * ($self->{'width'} / 100);
62  
63 # Main stars.
64 $self->{'tags'}->put(
65 ['b', 'div'],
66 ['a', 'style', 'width: '.$value.$self->{'unit'}.';overflow: hidden;'],
67  
68 ['b', 'div'],
69 3 ['a', 'class', $self->{'css_gradient_class'}],
70 ['e', 'div'],
71  
72 ['e', 'div'],
73 );
74  
75 3 return;
76 }
77  
78 # Process 'CSS::Struct'.
79 sub process_css {
80 0 ▶ my $self = shift;
Subroutine process_css: not called CC=1 SCAR=6.9
Pod documented
81  
82 $self->{'css'}->put(
83 ['s', '.'.$self->{'css_gradient_class'}],
84 ['d', 'height', $self->{'height'}.$self->{'unit'}],
85 ['d', 'width', $self->{'width'}.$self->{'unit'}],
86 ['d', 'background-color', 'red'],
87 0 ['d', 'background-image', $self->{'css_background_image'}],
88 ['e'],
89 );
90  
91 0 return;
92 }
93  
94 4 1;
95  
96 __END__
↑ Summary