| 1 | package HTML::MobileJp::Filter::Content; | ||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 6 | has _current => ( | |||||||||||||||||||||||||||||||
| 5 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 6 | isa => 'Any', | ||||||||||||||||||||||||||||||||
| 7 | ); | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | has html => ( | ||||||||||||||||||||||||||||||||
| 10 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 11 | isa => 'Str', | ||||||||||||||||||||||||||||||||
| 12 | trigger => sub { | ||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | shift->_current('html'); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | }, | ||||||||||||||||||||||||||||||||
| 15 | 6 | ); | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | has xml => ( | ||||||||||||||||||||||||||||||||
| 18 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 19 | isa => 'XML::LibXML::Document', | ||||||||||||||||||||||||||||||||
| 20 | trigger => sub { | ||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | shift->_current('xml'); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||||||
| 23 | 6 | ); | |||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use overload '""' => 'stringfy', fallback => 1; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 6 | *stringfy = \&as_html; | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | sub update { | ||||||||||||||||||||||||||||||||
| 32 | 6 | ▶ | my ($self, $content) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=6 SCAR=19.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 33 | 6 | ▶ | if (ref($content) and $content->isa(__PACKAGE__)) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
ref $content and $content->isa(__PACKAGE__)
MC/DC0%0/2
ref $content and $content->isa(__PACKAGE__)
ref $content
$content->isa(__PACKAGE__)
Truth table66%2/3
A and B
A= ref $contentB= $content->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||
| 34 | 0 | $self->{$_} = $content->{$_} for qw( html xml ); | |||||||||||||||||||||||||||||||
| 35 | ▶ | } elsif (ref($content) and $content->isa('XML::LibXML::Document')) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $content and $content->isa("XML::LibXML::Document")
MC/DC50%1/2
ref $content and $content->isa("XML::LibXML::Document")
ref $content
$content->isa("XML::LibXML::Document")
Truth table66%2/3
A and B
A= ref $contentB= $content->isa("XML::LibXML::Document")
| |||||||||||||||||||||||||||||||||
| 36 | 1 | $self->xml($content); | |||||||||||||||||||||||||||||||
| 37 | } else { | ||||||||||||||||||||||||||||||||
| 38 | 5 | $self->html($content); | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | sub as_html { | ||||||||||||||||||||||||||||||||
| 43 | 12 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
as_html: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 44 | 12 | ▶ | if ($self->_current ne 'html') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | $self->html( $self->xml->toString ) if $self->_current ne 'html'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | 12 | $self->html; | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | sub as_xml { | ||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
as_xml: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | if ($self->_current ne 'xml') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | 1 | $self->xml( XML::LibXML->new->parse_string($self->html) ); | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | 1 | $self->xml; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 6 | 1; | |||||||||||||||||||||||||||||||