line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::MobileJp::Filter::Content; |
2
|
6
|
|
|
6
|
|
1997
|
use Any::Moose; |
|
6
|
|
|
|
|
38625
|
|
|
6
|
|
|
|
|
38
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
has _current => ( |
5
|
|
|
|
|
|
|
is => 'rw', |
6
|
|
|
|
|
|
|
isa => 'Any', |
7
|
|
|
|
|
|
|
); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has html => ( |
10
|
|
|
|
|
|
|
is => 'rw', |
11
|
|
|
|
|
|
|
isa => 'Str', |
12
|
|
|
|
|
|
|
trigger => sub { |
13
|
|
|
|
|
|
|
shift->_current('html'); |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has xml => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'XML::LibXML::Document', |
20
|
|
|
|
|
|
|
trigger => sub { |
21
|
|
|
|
|
|
|
shift->_current('xml'); |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
6
|
|
26033
|
use overload '""' => 'stringfy', fallback => 1; |
|
6
|
|
|
|
|
4546
|
|
|
6
|
|
|
|
|
71
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
*stringfy = \&as_html; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
6
|
|
7186
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub update { |
32
|
|
|
|
|
|
|
my ($self, $content) = @_; |
33
|
|
|
|
|
|
|
if (ref($content) and $content->isa(__PACKAGE__)) { |
34
|
|
|
|
|
|
|
$self->{$_} = $content->{$_} for qw( html xml ); |
35
|
|
|
|
|
|
|
} elsif (ref($content) and $content->isa('XML::LibXML::Document')) { |
36
|
|
|
|
|
|
|
$self->xml($content); |
37
|
|
|
|
|
|
|
} else { |
38
|
|
|
|
|
|
|
$self->html($content); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub as_html { |
43
|
|
|
|
|
|
|
my ($self) = @_; |
44
|
|
|
|
|
|
|
if ($self->_current ne 'html') { |
45
|
|
|
|
|
|
|
$self->html( $self->xml->toString ) if $self->_current ne 'html'; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
$self->html; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub as_xml { |
51
|
|
|
|
|
|
|
my ($self) = @_; |
52
|
|
|
|
|
|
|
if ($self->_current ne 'xml') { |
53
|
|
|
|
|
|
|
$self->xml( XML::LibXML->new->parse_string($self->html) ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
$self->xml; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
59
|
|
|
|
|
|
|
1; |