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

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 63 CC 2 SCAR 9.4
CC
2
Cov
0%
as_string
6.0
BEGIN
2.0
init
2.0
CRAP 2.6
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/Text.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/04/22
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::Text;
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->{tag} = '_text';
32 $self->{value} = '';
33 $self->{is_empty} = 1;
34 $self->{_init_strict_use_sub} = 1;
35 $self->{_exception_class} = 'HTML::Object::Exception';
36 $self->SUPER::init( @_ ) || return( $self->pass_error );
37 return( $self );
38 }
39  
40 sub as_string
41 {
42 my $self = shift( @_ );
43 # We need to remove the reset flag, otherwise if there are any subsequent change that need to be propagated to this text parent, HTML::Object::Element::reset will not propagate it
44 $self->_remove_reset;
45 return( $self->value->length ? $self->value : $self->original );
46 }
47  
48 # There is nothing to encode because we have not touched the text in the first place.
49 # Especially in the script tag section !
50 # If the user wants to, he can and should go ahead, but it is way too dangerous for us to make assumptions
51 sub as_xml { return( shift->as_string( @_ ) ); }
52  
53 # added to provide element-like methods to text nodes, for use by cmp
54 sub lineage
55 {
56 my $node = shift( @_ );
57 my $parent = $node->parent;
58 return( $parent, $parent->lineage );
59 }
60  
61 sub set_checksum
62 {
63 my $self = shift( @_ );
64 return( $self->_get_md5_hash( $self->value->scalar ) );
65 }
66  
67 sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); }
68  
69 1;
70 # NOTE: POD
71 __END__