blib/lib/HTML/Object/Declaration.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 8 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 78 CC 5 SCAR 15.5
CC
5
Cov
0%
as_string
12.0
init
6.0
name
6.0
CRAP 4.7
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/Declaration.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/04/19
7 ## Modified 2022/09/18
8 ## All rights reserved
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::Declaration;
15 BEGIN
16 {
17 use strict;
18 use warnings;
19 warnings::register_categories( 'HTML::Object' );
20 use parent qw( HTML::Object::Element );
21 use vars qw( $VERSION );
22 our $VERSION = 'v0.2.0';
23 };
24  
25 use strict;
26 use warnings;
27  
28 sub init
29 {
30 my $self = shift( @_ );
31 $self->{is_empty} = 1;
32 $self->{name} = 'html' unless( CORE::exists( $self->{name} ) && CORE::length( $self->{name} ) );
33 $self->{_init_strict_use_sub} = 1;
34 $self->{_exception_class} = 'HTML::Object::Exception';
35 $self->SUPER::init( @_ ) || return( $self->pass_error );
36 $self->{tag} = '_declaration';
37 return( $self );
38 }
39  
40 sub as_string
41 {
42 my $self = shift( @_ );
43 if( !$self->original->is_empty )
44 {
45 return( $self->original );
46 }
47 else
48 {
49 my $name = $self->name;
50 return( $self->new_scalar( "<!DOCTYPE" . ( ( defined( $name ) && CORE::length( "$name" ) ) ? " ${name}" : '' ) . '>' ) );
51 }
52 }
53  
54 sub as_xml { return( shift->as_string( @_ ) ); }
55  
56 sub checksum { return( '' ); }
57  
58 sub name
59 {
60 my $self = shift( @_ );
61 if( my $rv = $self->original->match( qr/^<!DOCTYPE[[:blank:]\h]+(\w+)/ ) )
62 {
63 return( lc( $rv->capture->first ) );
64 }
65 return( '' );
66 }
67  
68 sub set_checksum {}
69  
70 1;
71 # NOTE: POD
72 __END__
73  
74 =encoding utf-8
75  
76 =head1 NAME
77  
78 HTML::Object::Declaration - HTML Object
79  
80 =head1 SYNOPSIS
81  
82 use HTML::Object::Declaration;
83 my $this = HTML::Object::Declaration->new || die( HTML::Object::Declaration->error, "\n" );
84  
85 =head1 VERSION
86  
87 v0.2.0
88  
89 =head1 DESCRIPTION
90  
91 This module represents a document declaration element.
92  
93 =head1 INHERITANCE
94  
95 +-----------------------+ +---------------------------+
96 | HTML::Object::Element | --> | HTML::Object::Declaration |
97 +-----------------------+ +---------------------------+
98  
99 =head1 PROPERTIES
100  
101 =head2 internalSubset
102  
103 Read-only.
104  
105 Returns an empty L<string object|Module::Generic::Scalar>
106  
107 =head2 name
108  
109 Read-only.
110  
111 A DOMString, eg C<html> for <!DOCTYPE HTML>.
112  
113 =head2 notations
114  
115 Read-only.
116  
117 A NamedNodeMap with notations declared in the DTD.
118  
119 =head2 publicId
120  
121 Read-only.
122  
123 A DOMString, eg "-//W3C//DTD HTML 4.01//EN", empty string for HTML5.
124  
125 For example, with a doctype such as:
126  
127 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
128 "http://www.w3.org/TR/html4/strict.dtd">
129  
130 or
131  
132 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
133 "http://www.w3.org/TR/html4/loose.dtd">
134  
135 =head2 systemId
136  
137 Read-only.
138  
139 A DOMString, eg "http://www.w3.org/TR/html4/strict.dtd", empty string for HTML5.
140  
141 =head1 METHODS
142  
143 =head2 after
144  
145 This method is listed here for standard compliance, but actually does nothing.
146  
147 Normally, in JavaScript, it would insert a set of Node or DOMString objects in the children list of the DocumentType's parent, just after the DocumentType object.
148  
149 =head2 as_string
150  
151 Returns a string representation of this element.
152  
153 =head2 as_xml
154  
155 Returns a xml representation of this element. This is actually an alias for L</as_string>
156  
157 =head2 before
158  
159 This method is listed here for standard compliance, but actually does nothing.
160  
161 Normally, in JavaScript, it would insert a set of Node or DOMString objects in the children list of the DocumentType's parent, just before the DocumentType object.
162  
163 =head2 checksum
164  
165 Returns an empty string.
166  
167 =head2 set_checksum
168  
169 Returns nothing.
170  
171 =head1 AUTHOR
172  
173 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
174  
175 =head1 SEE ALSO
176  
177 L<https://html.spec.whatwg.org/multipage/syntax.html#the-doctype>
178  
179 L<https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode>
180  
181 L<https://developer.mozilla.org/en-US/docs/Web/API/DocumentType>
182  
183 L<HTML::Object>, L<HTML::Object::Attribute>, L<HTML::Object::Boolean>, L<HTML::Object::Closing>, L<HTML::Object::Collection>, L<HTML::Object::Comment>, L<HTML::Object::Declaration>, L<HTML::Object::Document>, L<HTML::Object::Element>, L<HTML::Object::Exception>, L<HTML::Object::Literal>, L<HTML::Object::Number>, L<HTML::Object::Root>, L<HTML::Object::Space>, L<HTML::Object::Text>, L<HTML::Object::XQuery>
184  
185 =head1 COPYRIGHT & LICENSE
186  
187 Copyright (c) 2021 DEGUEST Pte. Ltd.
188  
189 All rights reserved
190  
191 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
192  
193 =cut