Parse.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 4 totaltotal 77.5% 45 / 58 CC 7 SCAR 10.1
CC
7
Cov
86%
new
5.2
handle
2.0
filename
2.0
CRAP 2.7
« Parse/Register.pm ↑ Summary Parse/Exceptions.pm »
1 #===============================================================================
2 # FILE: Games::Go::AGA::Parse
3 # ABSTRACT: parsers for various AGA format files
4 # AUTHOR: Reid Augustin (REID), <reid@lucidport.com>
5 # COMPANY: LucidPort Technology, Inc.
6 # CREATED: 12/02/2010 08:51:22 AM PST
7 #===============================================================================
8  
9 3 ▶use 5.002;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package Games::Go::AGA::Parse;
14  
15 3 our $VERSION = '0.042'; # VERSION
16  
17 3 ▶sub new {
Subroutine new: called CC=5 SCAR=16.6
Pod undocumented
18 3 my ($proto, %opts) = @_;
19  
20 3 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
21 3 my $self = bless {}, $class;
22 3 foreach my $key (qw(
23 filename
24 handle
25 )) {
26 6 ▶ if ($opts{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{$key}) 1 5 6
27 3 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 $self->$key(delete $opts{$key});
29 }
30 }
31 3 ▶ if (%opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%opts) 0 3 3
32 0 die "unknown option(s): ", join("\n", %opts);
33 }
34  
35 3 return $self;
36 }
37  
38 6 ▶sub filename {
Subroutine filename: called CC=2 SCAR=6.9
Pod undocumented
39 6 my $self = shift;
40  
41 6 ▶ $self->{filename} = $_[0] if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 5 6
42 6 return $self->{filename};
43 }
44  
45 5 ▶sub handle {
Subroutine handle: called CC=2 SCAR=7.1
Pod undocumented
46 5 my $self = shift;
47  
48 5 ▶ $self->{handle} = $_[0] if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 5 5
49 5 return $self->{handle};
50 }
51  
52 3 *parse = \&parse_line; # alias parse to parse_line
53 0 ▶sub parse_line {
Subroutine parse_line: not called CC=1 SCAR=6.9
Pod undocumented
54  
55 0 Games::Go::AGA::Parse::Exception->throw(
56 error => "Don't use Games::Go::AGA::Parse directly, use Games::Go::AGA::Parse::SOMETHING",
57 );
58 }
59  
60 5 ▶sub _parse_error {
Subroutine _parse_error: called CC=1 SCAR=0.0
61 5 my $self = shift;
62  
63 5 Games::Go::AGA::Parse::Exception->throw(
64 @_,
65 filename => $self->filename,
66 handle => $self->handle,
67 );
68 }
69  
70 3 1;
71  
72 __END__
« Parse/Register.pm ↑ Summary Parse/Exceptions.pm »