| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use HTML::Manipulator; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package HTML::Manipulator::Document; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.07'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 13 | ▶ | sub from_string { | ||||||||||||||||||||||||||
|
Subroutine
from_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 13 | my ( $class, $html ) = @_; | |||||||||||||||||||||||||||
| 12 | 13 | my $self = bless { html => $html }, $class; | |||||||||||||||||||||||||||
| 13 | 13 | return $self; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | sub from_file { | ||||||||||||||||||||||||||
|
Subroutine
from_file: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 2 | my ( $class, $file ) = @_; | |||||||||||||||||||||||||||
| 18 | 2 | my $html; | |||||||||||||||||||||||||||
| 19 | 2 | ▶ | if ( UNIVERSAL::isa( $file, 'GLOB' ) or UNIVERSAL::isa( \$file, 'GLOB' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
UNIVERSAL::isa($file, "GLOB") or UNIVERSAL::isa(\$file, "GLOB")
MC/DC50%1/2
UNIVERSAL::isa($file, "GLOB") or UNIVERSAL::isa(\$file, "GLOB")
UNIVERSAL::isa($file, "GLOB")
UNIVERSAL::isa(\$file, "GLOB")
Truth table66%2/3
A or B
A= UNIVERSAL::isa($file, "GLOB")B= UNIVERSAL::isa(\$file, "GLOB")
| |||||||||||||||||||||||||||||
| 20 | 1 | $html = join '', <$file>; | |||||||||||||||||||||||||||
| 21 | } else { | ||||||||||||||||||||||||||||
| 22 | 1 | require FileHandle; | |||||||||||||||||||||||||||
| 23 | 1 | my $fh = new FileHandle( $file, 'r' ); | |||||||||||||||||||||||||||
| 24 | 1 | ▶ | croak "could not open the file $file for reading: $!" unless $fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 1 | $html = join '', <$fh>; | |||||||||||||||||||||||||||
| 26 | 1 | $fh->close; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 2 | return $class->from_string($html); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 33 | 2 | return $self->{html}; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 2 | ▶ | sub replace { | ||||||||||||||||||||||||||
|
Subroutine
replace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 38 | 2 | $self->{html} = HTML::Manipulator::replace( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub replace_title { | ||||||||||||||||||||||||||
|
Subroutine
replace_title: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 43 | 1 | $self->{html} = HTML::Manipulator::replace_title( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 1 | ▶ | sub extract { | ||||||||||||||||||||||||||
|
Subroutine
extract: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 48 | 1 | HTML::Manipulator::extract( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub extract_content { | ||||||||||||||||||||||||||
|
Subroutine
extract_content: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 53 | 1 | HTML::Manipulator::extract_content( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub extract_all { | ||||||||||||||||||||||||||
|
Subroutine
extract_all: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 58 | 0 | HTML::Manipulator::extract_all( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 3 | ▶ | sub extract_all_content { | ||||||||||||||||||||||||||
|
Subroutine
extract_all_content: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 3 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 63 | 3 | HTML::Manipulator::extract_all_content( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | sub extract_all_ids { | ||||||||||||||||||||||||||
|
Subroutine
extract_all_ids: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 68 | 1 | HTML::Manipulator::extract_all_ids( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | ▶ | sub extract_title { | ||||||||||||||||||||||||||
|
Subroutine
extract_title: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 73 | 1 | HTML::Manipulator::extract_title( $self->{html} ); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | sub extract_all_comments { | ||||||||||||||||||||||||||
|
Subroutine
extract_all_comments: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 1 | my ( $self, @filter ) = @_; | |||||||||||||||||||||||||||
| 78 | 1 | HTML::Manipulator::extract_all_comments( $self->{html}, @filter ); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 1 | ▶ | sub insert_before_begin { | ||||||||||||||||||||||||||
|
Subroutine
insert_before_begin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 83 | $self->{html} = | ||||||||||||||||||||||||||||
| 84 | 1 | HTML::Manipulator::insert_before_begin( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1 | ▶ | sub insert_after_begin { | ||||||||||||||||||||||||||
|
Subroutine
insert_after_begin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 89 | $self->{html} = | ||||||||||||||||||||||||||||
| 90 | 1 | HTML::Manipulator::insert_after_begin( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 1 | ▶ | sub insert_before_end { | ||||||||||||||||||||||||||
|
Subroutine
insert_before_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 94 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 95 | $self->{html} = | ||||||||||||||||||||||||||||
| 96 | 1 | HTML::Manipulator::insert_before_end( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | ▶ | sub insert_after_end { | ||||||||||||||||||||||||||
|
Subroutine
insert_after_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 100 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 101 | 1 | $self->{html} = HTML::Manipulator::insert_after_end( $self->{html}, @args ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 1 | ▶ | sub save_as { | ||||||||||||||||||||||||||
|
Subroutine
save_as: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 1 | my ( $self, $filename ) = @_; | |||||||||||||||||||||||||||
| 106 | 1 | require File::Spec; | |||||||||||||||||||||||||||
| 107 | 1 | my (@path) = File::Spec->splitdir($filename); | |||||||||||||||||||||||||||
| 108 | 1 | pop @path; | |||||||||||||||||||||||||||
| 109 | 1 | my $mkdir = ''; | |||||||||||||||||||||||||||
| 110 | 1 | ▶ | while (@path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 3 | $mkdir = File::Spec->catfile( $mkdir, shift @path ); | |||||||||||||||||||||||||||
| 112 | 3 | ▶ | mkdir $mkdir unless -e $mkdir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 1 | require FileHandle; | |||||||||||||||||||||||||||
| 115 | 1 | ▶ | my $fh = new FileHandle( $filename, 'w' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | or croak "failed to open the file $filename for saving HTML: $!"; | ||||||||||||||||||||||||||||
| 117 | 1 | print $fh $self->as_string; | |||||||||||||||||||||||||||
| 118 | 1 | $fh->close; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 1 | 1; | |||||||||||||||||||||||||||
| 122 | __END__ | ||||||||||||||||||||||||||||