Dir/Iterator.pm

filter: Statementstmt 100% 30 / 30 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 81.6% 40 / 49 CC 4 SCAR 9.4
CC
4
Cov
87%
new
4.5
BEGIN
1.0
BEGIN
1.0
CRAP 2.6
« Dir/Entry.pm ↑ Summary
1 package D64::Disk::Dir::Iterator;
2  
3 =head1 NAME
4  
5 D64::Disk::Dir::Iterator - Iterating through Commodore (D64/D71/D81) disk image directory entries
6  
7 =head1 SYNOPSIS
8  
9 use D64::Disk::Dir::Iterator;
10  
11 # Create an iterator with a directory object instance:
12 my $iter = D64::Disk::Dir::Iterator->new($d64DiskDirObj);
13  
14 # Perlish style iterator:
15 while (my $entry = $iter->getNext()) {
16 # ...do something with $entry...
17 }
18  
19 # C++-ish style iterator:
20 for (my $iter = D64::Disk::Dir::Iterator->new($d64DiskDirObj); $iter->hasNext(); $iter->next()) {
21 my $entry = $iter->current();
22 # ...do something with $entry...
23 }
24  
25 =head1 DESCRIPTION
26  
27 This package provides an iterative method of accessing individual directory entries available within D64::Disk::Dir object instance based on a simple class for iterating over Perl arrays. See the description of L<Array::Iterator> package for a complete list of available methods and iteration process examples.
28  
29 =head1 METHODS
30  
31 =cut
32  
33 2 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 2 ▶use base qw( Exporter Array::Iterator );
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 our %EXPORT_TAGS = ();
39 2 $EXPORT_TAGS{'all'} = [];
40 2 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
41 2 our @EXPORT = qw();
42  
43 2 our $VERSION = '0.06';
44  
45 2 ▶use Carp qw/carp croak verbose/;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 =head2 new
48  
49 Create an iterator with a D64::Disk::Dir object instance:
50  
51 my $iter = D64::Disk::Dir::Iterator->new($d64DiskDirObj);
52  
53 =cut
54  
55 3 ▶sub new {
Subroutine new: called CC=4 SCAR=15.0
Pod documented
56 3 my $this = shift;
57 3 my $d64DiskDirObj = shift;
58 3 ▶ croak "Not a D64::Disk::Dir object: \"$d64DiskDirObj\"" unless defined $d64DiskDirObj and $d64DiskDirObj->can("_get_dir_entries");
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d64DiskDirObj and $d64DiskDirObj->can("_get_dir_entries") 0 3 3
Condition33%1/3
defined $d64DiskDirObj and $d64DiskDirObj->can("_get_dir_entries")
!ll&&!rl&&r
003
MC/DC0%0/2
defined $d64DiskDirObj and $d64DiskDirObj->can("_get_dir_entries")
defined $d64DiskDirObj $d64DiskDirObj->can("_get_dir_entries")
Truth table33%1/3
A and B
A= defined $d64DiskDirObjB= $d64DiskDirObj->can("_get_dir_entries")
ABresult
0X0
100
111
59 3 my $entries = $d64DiskDirObj->_get_dir_entries();
60 3 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
61 3 my $self = $class->SUPER::new($entries);
62 3 bless $self, $class;
63 3 return $self;
64 }
65  
66 =head1 BUGS
67  
68 There are no known bugs at the moment. Please report any bugs or feature requests.
69  
70 =head1 EXPORT
71  
72 None. No method is exported into the caller's namespace either by default or explicitly.
73  
74 =head1 SEE ALSO
75  
76 L<Array::Iterator>, L<D64::Disk::Dir>, L<D64::Disk::Dir::Entry>, L<D64::Disk::Image>
77  
78 =head1 AUTHOR
79  
80 Pawel Krol, E<lt>pawelkrol@cpan.orgE<gt>.
81  
82 =head1 VERSION
83  
84 Version 0.06 (2023-08-28)
85  
86 =head1 COPYRIGHT AND LICENSE
87  
88 This module is licensed under a slightly modified BSD license, the same terms as Per Olofsson's "diskimage.c" library and L<D64::Disk::Image> Perl package it is based on, license contents are repeated below.
89  
90 Copyright (c) 2003-2006, Per Olofsson
91 All rights reserved.
92  
93 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
94  
95 =over
96  
97 =item *
98  
99 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
100  
101 =item *
102  
103 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
104  
105 =back
106  
107 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108  
109 diskimage.c website: L<https://paradroid.automac.se/diskimage/>
110  
111 =cut
112  
113 2 1;
« Dir/Entry.pm ↑ Summary