Status.pm

filter: Statementstmt 100% 40 / 40 Branchbran 100% 10 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 5 / 5 totaltotal 94.2% 66 / 70 CC 7 SCAR 11.0
CC
7
Cov
96%
_init
6.0
new
2.1
BEGIN
1.0
CRAP 3.0
↑ Summary Status/Factory.pm »
1 package D64::Disk::Status;
2  
3 =head1 NAME
4  
5 D64::Disk::Status - CBM floppy error messages and disk drive status details of miscellaneous Commodore (D64/D71/D81) disk image operations
6  
7 =head1 SYNOPSIS
8  
9 use D64::Disk::Status;
10  
11 # Create a new disk status object instance:
12 my $status = D64::Disk::Status->new(
13 code => $code,
14 error => $error,
15 message => $message,
16 description => $description,
17 );
18  
19 # Get error code from status object:
20 my $code = $status->code();
21  
22 # Get error text from status object:
23 my $error = $status->error();
24  
25 # Get error message from status object:
26 my $message = $status->message();
27  
28 # Get error description from status object:
29 my $describe = $status->description();
30  
31 =head1 DESCRIPTION
32  
33 C<D64::Disk::Status> provides a helper class for C<D64::Disk::Layout> module that lets users easily identify CBM floppy error messages and disk drive status details (like error codes, and descriptive diagnostic messages) signalled as a result of miscellaneous Commodore (D64/D71/D81) disk image operations.
34  
35 =head1 METHODS
36  
37 =cut
38  
39 3 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 3 our $VERSION = '0.03';
45  
46 =head2 new
47  
48 Create a new disk status instance:
49  
50 my $status = D64::Disk::Status->new(
51 code => $code,
52 error => $error,
53 message => $message,
54 description => $description,
55 );
56  
57 =cut
58  
59 18 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod documented
60 18 my ($this, %args) = @_;
61 18 ▶ my $class = ref ($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0180
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
62 18 my $object = $class->_init(%args);
63 12 my $self = bless $object, $class;
64 12 return $self;
65 }
66  
67 18 ▶sub _init {
Subroutine _init: called CC=6 SCAR=17.9
68 18 my ($class, %args) = @_;
69  
70 18 ▶ unless (exists $args{code}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"code"}) 2 16 18
71 2 die q{Failed to instantiate status object: Missing error "code" parameter};
72 }
73 16 ▶ unless (exists $args{error}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"error"}) 1 15 16
74 1 die q{Failed to instantiate status object: Missing "error" text parameter};
75 }
76 15 ▶ unless (exists $args{message}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"message"}) 1 14 15
77 1 die q{Failed to instantiate status object: Missing error "message" parameter};
78 }
79 14 ▶ unless (exists $args{description}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"description"}) 1 13 14
80 1 die q{Failed to instantiate status object: Missing error "description" parameter};
81 }
82  
83 13 ▶ unless ($args{code} =~ m/^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"code"} =~ /^\d+$/) 1 12 13
84 1 die q{Failed to instantiate status object: Invalid error "code" parameter};
85 }
86  
87 my %object = (
88 code => $args{code},
89 error => $args{error},
90 message => $args{message},
91 description => $args{description},
92 12 );
93  
94 12 return \%object;
95 }
96  
97 =head2 code
98  
99 Get error code from status object:
100  
101 my $code = $status->code();
102  
103 =cut
104  
105 5 ▶sub code {
Subroutine code: called CC=1 SCAR=0.0
Pod documented
106 5 my ($self) = @_;
107  
108 5 return $self->{code};
109 }
110  
111 =head2 error
112  
113 Get error text from status object:
114  
115 my $error = $status->error();
116  
117 =cut
118  
119 5 ▶sub error {
Subroutine error: called CC=1 SCAR=0.0
Pod documented
120 5 my ($self) = @_;
121  
122 5 return $self->{error};
123 }
124  
125 =head2 message
126  
127 Get error message from status object:
128  
129 my $message = $status->message();
130  
131 =cut
132  
133 5 ▶sub message {
Subroutine message: called CC=1 SCAR=0.0
Pod documented
134 5 my ($self) = @_;
135  
136 5 return $self->{message};
137 }
138  
139 =head2 description
140  
141 Get error description from status object:
142  
143 my $describe = $status->description();
144  
145 =cut
146  
147 5 ▶sub description {
Subroutine description: called CC=1 SCAR=0.0
Pod documented
148 5 my ($self) = @_;
149  
150 5 return $self->{description};
151 }
152  
153 =head1 BUGS
154  
155 There are no known bugs at the moment. Please report any bugs or feature requests.
156  
157 =head1 EXPORT
158  
159 None. No method is exported into the caller's namespace neither by default nor explicitly.
160  
161 =head1 SEE ALSO
162  
163 L<D64::Disk::Layout>, L<D64::Disk::Layout::Dir>, L<D64::Disk::Status::Factory>.
164  
165 =head1 AUTHOR
166  
167 Pawel Krol, E<lt>pawelkrol@cpan.orgE<gt>.
168  
169 =head1 VERSION
170  
171 Version 0.03 (2013-03-09)
172  
173 =head1 COPYRIGHT AND LICENSE
174  
175 Copyright 2013 by Pawel Krol E<lt>pawelkrol@cpan.orgE<gt>.
176  
177 This library is free open source software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
178  
179 PLEASE NOTE THAT IT COMES WITHOUT A WARRANTY OF ANY KIND!
180  
181 =cut
182  
183 3 1;
184  
185 __END__
↑ Summary Status/Factory.pm »