lib/HTML/Object/DOM/File.pm

filter: Statementstmt 95.1% 59 / 62 Branchbran 43.7% 7 / 16 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 18 / 18 Podpod 100% 9 / 9 totaltotal 87.0% 94 / 108 CC 10 SCAR 17.8
CC
10
Cov
84%
slice
14.3
BEGIN
1.0
BEGIN
1.0
CRAP 5.9
« lib/HTML/Object/Declaration.pm ↑ Summary lib/HTML/Object/DOM/Element/Template.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/File.pm
3 ## Version v0.2.1
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/25
7 ## Modified 2026/07/04
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::DOM::File;
15 BEGIN
16 {
17 2 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶ use parent qw( Module::Generic::File );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶ use DateTime::Format::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶ use Module::Generic::Scalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 our $VERSION = 'v0.2.1';
25 };
26  
27 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 sub arrayBuffer
31 {
32 1 ▶ my $self = shift( @_ );
Subroutine arrayBuffer: called CC=1 SCAR=0.0
Pod documented
33 1 my $data = $self->load({ binmode => 'raw' });
34 1 return( Module::Generic::Scalar->new( \$data ) );
35 }
36  
37 sub lastModified
38 {
39 1 ▶ my $self = shift( @_ );
Subroutine lastModified: called CC=1 SCAR=0.0
Pod documented
40 1 my $dt = $self->mtime;
41 1 my $fmt = DateTime::Format::Lite->new( pattern => '%s' );
42 1 $dt->set_formatter( $fmt );
43 1 return( $dt );
44 }
45  
46 1 ▶sub lastModifiedDate { return( shift->mtime ); }
Subroutine lastModifiedDate: called CC=1 SCAR=0.0
Pod documented
47  
48 1 ▶sub name { return( shift->basename ); }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
49  
50 # Note: sub size is inherited
51  
52 sub slice
53 {
54 1 ▶ my $self = shift( @_ );
Subroutine slice: called CC=10 SCAR=26.6
Pod documented
55 1 my( $start, $end ) = @_;
56 1 ▶ return( $self->error( "start value provided is not an integer." ) ) if( !$self->_is_integer( $start ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_integer($start) 0 1 1
57 1 ▶ $end = $self->size if( !$self->_is_integer( $end ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_integer($end) 0 1 1
58 1 ▶ return( Module::Generic::Scalar->new ) if( $end <= $start );
Branch: 1 branch
BranchTrueFalseTotal
if $end <= $start 0 1 1
59 1 my $len = $end - $start;
60 1 my $opened = $self->opened;
61 1 my $io;
62 my $pos;
63 1 ▶ if( $opened )
Branch: 1 branch
BranchTrueFalseTotal
if ($opened) { } 0 1 1
64 {
65 0 $io = $opened;
66 0 $pos = $io->seek(0,1);
67 }
68 else
69 {
70 1 ▶ $io = $self->open({ binmode => 'utf-8' }) || return( $self->pass_error );
Condition50%1/2
$self->open({'binmode', 'utf-8'}) || (return $self->pass_error)
l!l
10
MC/DC0%0/1
$self->open({'binmode', 'utf-8'}) || (return $self->pass_error)
$self->open({'binmode', 'utf-8'})
Truth table50%1/2
A
A= $self->open({'binmode', 'utf-8'})
Aresult
11
00
71 }
72 1 ▶ $io->seek( $start, 0 ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$io->seek($start, 0) or return $self->pass_error 0 1 1
73 1 my $data;
74 1 ▶ $self->read( $data, $len ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->read($data, $len) or return $self->pass_error 0 1 1
75 1 ▶ if( $opened )
Branch: 1 branch
BranchTrueFalseTotal
if ($opened) { } 0 1 1
76 {
77 0 ▶ $io->seek( $pos, 0 ) if( defined( $pos ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $pos 0 0 0
78 }
79 else
80 {
81 1 $self->close;
82 }
83 1 return( Module::Generic::Scalar->new( \$data ) );
84 }
85  
86 1 ▶sub stream { return( shift->open( @_ ) ); }
Subroutine stream: called CC=1 SCAR=0.0
Pod documented
87  
88 sub text
89 {
90 1 ▶ my $self = shift( @_ );
Subroutine text: called CC=1 SCAR=0.0
Pod documented
91 1 my $data = $self->load_utf8;
92 1 return( Module::Generic::Scalar->new( \$data ) );
93 }
94  
95 1 ▶sub type { return( shift->finfo->mime_type ); }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
96  
97 1 ▶sub webkitRelativePath { return( shift->relative ); }
Subroutine webkitRelativePath: called CC=1 SCAR=0.0
Pod documented
98  
99 2 1;
100 # NOTE: POD
101 __END__
« lib/HTML/Object/Declaration.pm ↑ Summary lib/HTML/Object/DOM/Element/Template.pm »