File Coverage

blib/lib/Tags/HTML.pm
Criterion Covered Total %
statement 40 54 74.0
branch 10 10 100.0
condition 13 15 86.6
subroutine 10 14 71.4
pod 5 5 100.0
total 78 98 79.5


line stmt bran cond sub pod time code
1             package Tags::HTML;
2              
3 5     5   135318 use strict;
  5         44  
  5         146  
4 5     5   26 use warnings;
  5         9  
  5         143  
5              
6 5     5   1886 use Class::Utils qw(set_params);
  5         98995  
  5         120  
7 5     5   309 use Error::Pure qw(err);
  5         10  
  5         212  
8 5     5   29 use Scalar::Util qw(blessed);
  5         8  
  5         2962  
9              
10             our $VERSION = 0.06;
11              
12             # Constructor.
13             sub new {
14 10     10 1 14039 my ($class, @params) = @_;
15              
16             # Create object.
17 10         27 my $self = bless {}, $class;
18              
19             # 'CSS::Struct::Output' object.
20 10         32 $self->{'css'} = undef;
21              
22             # No CSS support.
23 10         20 $self->{'no_css'} = 0;
24              
25             # 'Tags::Output' object.
26 10         17 $self->{'tags'} = undef;
27              
28             # Process params.
29 10         42 set_params($self, @params);
30              
31             # Check to 'CSS::Struct::Output' object.
32 10 100 100     183 if (! $self->{'no_css'} && defined $self->{'css'}
      66        
      100        
33             && (! blessed($self->{'css'}) || ! $self->{'css'}->isa('CSS::Struct::Output'))) {
34              
35 2         6 err "Parameter 'css' must be a 'CSS::Struct::Output::*' class.";
36             }
37              
38             # Check to 'Tags' object.
39 8 100 66     50 if (defined $self->{'tags'}
      100        
40             && (! blessed($self->{'tags'}) || ! $self->{'tags'}->isa('Tags::Output'))) {
41              
42 2         11 err "Parameter 'tags' must be a 'Tags::Output::*' class.";
43             }
44              
45             # Object.
46 6         32 return $self;
47             }
48              
49             # Cleanup after dynamic part.
50             sub cleanup {
51 0     0 1 0 my ($self, @params) = @_;
52              
53 0         0 $self->_cleanup(@params);
54              
55 0         0 return;
56             }
57              
58             # Initialize before dynamic part.
59             sub init {
60 0     0 1 0 my ($self, @params) = @_;
61              
62 0         0 $self->_init(@params);
63              
64 0         0 return;
65             }
66              
67             # Process 'Tags'.
68             sub process {
69 2     2 1 14 my ($self, @params) = @_;
70              
71 2 100       7 if (! defined $self->{'tags'}) {
72 1         3 err "Parameter 'tags' isn't defined.";
73             }
74              
75 1         4 $self->_process(@params);
76              
77 0         0 return;
78             }
79              
80             # Process 'CSS::Struct'.
81             sub process_css {
82 3     3 1 17 my ($self, @params) = @_;
83              
84             # No CSS support.
85 3 100       8 if ($self->{'no_css'}) {
86 1         4 return;
87             }
88              
89 2 100       8 if (! defined $self->{'css'}) {
90 1         6 err "Parameter 'css' isn't defined.";
91             }
92              
93 1         3 $self->_process_css(@params);
94              
95 0         0 return;
96             }
97              
98             sub _cleanup {
99 0     0   0 my ($self, @params) = @_;
100              
101             # Default is no special code.
102              
103 0         0 return;
104             }
105              
106             sub _init {
107 0     0   0 my ($self, @params) = @_;
108              
109             # Default is no special code.
110              
111 0         0 return;
112             }
113              
114             sub _process {
115 1     1   3 my ($self, @params) = @_;
116              
117 1         5 err "Need to be implemented in inherited class in _process() method.";
118              
119 0         0 return;
120             }
121              
122             sub _process_css {
123 1     1   3 my ($self, @params) = @_;
124              
125 1         5 err "Need to be implemented in inherited class in _process_css() method.";
126              
127 0           return;
128             }
129              
130             1;
131              
132             __END__