| 1 | package Dallycot::Value::HTML; | ||||||||||||||||||||||||||||||||||
| 2 | 30 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: A string with an associated language | ||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 30 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 30 | ▶ | use parent 'Dallycot::Value::Any'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | 30 | ▶ | use Promises qw(deferred); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | my ( $class, $value ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | $class = ref $class || $class; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ( !blessed($value) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 20 | 0 | my $parser = HTML::Parser->new( api_version => 3 ); | |||||||||||||||||||||||||||||||||
| 21 | 0 | $parser->parse($value); | |||||||||||||||||||||||||||||||||
| 22 | 0 | $parser->eof; | |||||||||||||||||||||||||||||||||
| 23 | 0 | $value = HTML::Parser->new->parse($value); | |||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | return bless [ $value // '' ] => $class; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$value // ""
MC/DC0%0/1
$value // ""
$value
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub lang { return shift->[1] } | ||||||||||||||||||||||||||||||||
|
Subroutine
lang: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | sub id { | ||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 0 | return $self->[0] . "@" . $self->[1] . "^^String"; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | sub calculate_length { | ||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my ( $self, $engine ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
calculate_length: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | 0 | $d->resolve( Dallycot::Value::Numeric->new( length $self->[0] ) ); | |||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||
| 44 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | sub calculate_reverse { | ||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my ( $self, $engine ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
calculate_reverse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | 0 | $d->resolve( $self->new( reverse( $self->value ), $self->lang ) ); | |||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | sub take_range { | ||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my ( $self, $engine, $offset, $length ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
take_range: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( abs($offset) > length( $self->[0] ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 63 | 0 | $d->resolve( $self->new( '', $self->lang ) ); | |||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||||||||||||||||
| 66 | 0 | $d->resolve( $self->new( substr( $self->value, $offset - 1, $length - $offset + 1 ), $self->lang ) ); | |||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | sub drop { | ||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | my ( $self, $engine, $offset ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
drop: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ( abs($offset) > length( $self->value ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 78 | 0 | $d->resolve( $self->new( '', $self->lang ) ); | |||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||
| 81 | 0 | $d->resolve( $self->new( substr( $self->value, $offset ), $self->lang ) ); | |||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | sub value_at { | ||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | my ( $self, $engine, $index ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
value_at: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ( !$index || abs($index) > length( $self->[0] ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $index or abs $index > length $self->[0]
MC/DC0%0/2
not $index or abs $index > length $self->[0]
not $index
abs $index > length $self->[0]
Truth table0%0/3
not(A) or B
A= not $indexB= abs $index > length $self->[0]
| |||||||||||||||||||||||||||||||||||
| 93 | 0 | $d->resolve( $self->new( '', $self->[1] ) ); | |||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||
| 95 | else { | ||||||||||||||||||||||||||||||||||
| 96 | 0 | $d->resolve( $self->new( substr( $self->[0], $index - 1, 1 ), $self->[1] ) ); | |||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | sub is_equal { | ||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
is_equal: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $d->resolve( $self->lang eq $other->lang && $self->value eq $other->value ); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->lang eq $other->lang && $self->value eq $other->value
MC/DC0%0/2
$self->lang eq $other->lang && $self->value eq $other->value
$self->lang eq $other->lang
$self->value eq $other->value
Truth table0%0/3
A && B
A= $self->lang eq $other->langB= $self->value eq $other->value
| |||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | sub is_less { | ||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
is_less: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $d->resolve( $self->lang lt $other->lang | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->lang lt $other->lang || $self->lang eq $other->lang && $self->value lt $other->value
$self->lang eq $other->lang and $self->value lt $other->value
MC/DC0%0/3
$self->lang lt $other->lang || $self->lang eq $other->lang && $self->value lt $other->value
$self->lang lt $other->lang
$self->lang eq $other->lang
$self->value lt $other->value
Truth table0%0/4
A || B and C
A= $self->lang lt $other->langB= $self->lang eq $other->langC= $self->value lt $other->value
| |||||||||||||||||||||||||||||||||||
| 118 | || $self->lang eq $other->lang && $self->value lt $other->value ); | ||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||
| 123 | sub is_less_or_equal { | ||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
is_less_or_equal: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $d->resolve( $self->lang lt $other->lang | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->lang lt $other->lang || $self->lang eq $other->lang && $self->value le $other->value
$self->lang eq $other->lang and $self->value le $other->value
MC/DC0%0/3
$self->lang lt $other->lang || $self->lang eq $other->lang && $self->value le $other->value
$self->lang lt $other->lang
$self->lang eq $other->lang
$self->value le $other->value
Truth table0%0/4
A || B and C
A= $self->lang lt $other->langB= $self->lang eq $other->langC= $self->value le $other->value
| |||||||||||||||||||||||||||||||||||
| 129 | || $self->lang eq $other->lang && $self->value le $other->value ); | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||
| 134 | sub is_greater { | ||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
is_greater: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $d->resolve( $self->lang gt $other->lang | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->lang gt $other->lang || $self->lang eq $other->lang && $self->value gt $other->value
$self->lang eq $other->lang and $self->value gt $other->value
MC/DC0%0/3
$self->lang gt $other->lang || $self->lang eq $other->lang && $self->value gt $other->value
$self->lang gt $other->lang
$self->lang eq $other->lang
$self->value gt $other->value
Truth table0%0/4
A || B and C
A= $self->lang gt $other->langB= $self->lang eq $other->langC= $self->value gt $other->value
| |||||||||||||||||||||||||||||||||||
| 140 | || $self->lang eq $other->lang && $self->value gt $other->value ); | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | sub is_greater_or_equal { | ||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
is_greater_or_equal: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||
| 148 | 0 | my $d = deferred; | |||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $d->resolve( $self->lang gt $other->lang | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->lang gt $other->lang || $self->lang eq $other->lang && $self->value ge $other->value
$self->lang eq $other->lang and $self->value ge $other->value
MC/DC0%0/3
$self->lang gt $other->lang || $self->lang eq $other->lang && $self->value ge $other->value
$self->lang gt $other->lang
$self->lang eq $other->lang
$self->value ge $other->value
Truth table0%0/4
A || B and C
A= $self->lang gt $other->langB= $self->lang eq $other->langC= $self->value ge $other->value
| |||||||||||||||||||||||||||||||||||
| 151 | || $self->lang eq $other->lang && $self->value ge $other->value ); | ||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | 0 | return $d->promise; | |||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | 30 | 1; | |||||||||||||||||||||||||||||||||