| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/Comment.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::Comment; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | 36 | ▶ | { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 36 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 36 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 36 | warnings::register_categories( 'HTML::Object' ); | |||||||||
| 20 | 36 | ▶ | use parent qw( HTML::Object::Element ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 36 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 36 | our $VERSION = 'v0.2.0'; | |||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | 36 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 36 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | sub init | ||||||||||
| 29 | 8 | ▶ | { | ||||||||
|
Subroutine
init: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 8 | my $self = shift( @_ ); | |||||||||
| 31 | 8 | $self->{open_seq} = '<!--'; | |||||||||
| 32 | 8 | $self->{close_seq} = '-->'; | |||||||||
| 33 | 8 | $self->{tag} = '_comment'; | |||||||||
| 34 | 8 | $self->{value} = ''; | |||||||||
| 35 | 8 | $self->{is_empty} = 1; | |||||||||
| 36 | 8 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 37 | 8 | $self->{_exception_class} = 'HTML::Object::Exception'; | |||||||||
| 38 | 8 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 8 | return( $self ); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub as_string | ||||||||||
| 43 | 1 | ▶ | { | ||||||||
|
Subroutine
as_string: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 44 | 1 | my $self = shift( @_ ); | |||||||||
| 45 | # We need to remove the reset flag, otherwise if there are any subsequent change that need to be propagated to this comment parent, HTML::Object::Element::reset will not propagate it | ||||||||||
| 46 | 1 | $self->_remove_reset; | |||||||||
| 47 | return( | ||||||||||
| 48 | 1 | ▶ | $self->value->length | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | ? $self->new_scalar( join( '', '<!--', $self->value->scalar, '-->' ) ) | ||||||||||
| 50 | : $self->original | ||||||||||
| 51 | ); | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | sub as_xml | ||||||||||
| 55 | 0 | ▶ | { | ||||||||
|
Subroutine
as_xml: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 56 | 0 | my $self = shift( @_ ); | |||||||||
| 57 | 0 | ▶ | my $txt = $self->value->length | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | ? $self->new_scalar( join( '', '<!--', $self->value->scalar, '-->' ) ) | ||||||||||
| 59 | : $self->original; | ||||||||||
| 60 | # HTML::Element says there cannot be double --'s in XML comments | ||||||||||
| 61 | 0 | $txt->replace( qr/--/, '--' ); | |||||||||
| 62 | 0 | return( $txt ); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub close_seq { return( shift->_set_get_scalar_as_object( 'close_seq', @_ ) ); } | ||||||||
|
Subroutine
close_seq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub open_seq { return( shift->_set_get_scalar_as_object( 'open_seq', @_ ) ); } | ||||||||
|
Subroutine
open_seq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 68 | |||||||||||
| 69 | sub set_checksum | ||||||||||
| 70 | 8 | ▶ | { | ||||||||
|
Subroutine
set_checksum: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 71 | 8 | my $self = shift( @_ ); | |||||||||
| 72 | 8 | return( $self->_get_md5_hash( $self->value->scalar ) ); | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 19 | ▶ | sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); } | ||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 76 | |||||||||||
| 77 | 36 | 1; | |||||||||
| 78 | # NOTE: POD | ||||||||||
| 79 | __END__ | ||||||||||