File Coverage

blib/lib/Data/Plist/Reader.pm
Criterion Covered Total %
statement 22 24 91.6
branch 1 2 50.0
condition n/a
subroutine 6 7 85.7
pod 4 4 100.0
total 33 37 89.1


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Data::Plist::Reader - Abstract superclass for BinaryReader
4              
5             =head1 SYNOPSIS
6              
7             # Create new
8             $read = Data::Plist::BinaryReader->new;
9              
10             # Reading from a string C<$str>
11             my $plist = $read->open_string($str);
12              
13             # Writing from file C<$filename>
14             $plist = $read->read($filename);
15              
16             =head1 DESCRIPTION
17              
18             C is an abstract superclass of
19             BinaryReader. Takes either a string or a filehandle containing data
20             formatted as an Apple property list and returns it as a
21             C.
22              
23             =cut
24              
25             package Data::Plist::Reader;
26              
27 4     4   23 use strict;
  4         8  
  4         156  
28 4     4   20 use warnings;
  4         8  
  4         940  
29              
30             =head1 METHODS
31              
32             =head2 new
33              
34             Create a new reader.
35              
36             =cut
37              
38             sub new {
39 28     28 1 246 my $class = shift;
40 28         106 return bless {} => $class;
41             }
42              
43             =head2 open_string $content
44              
45             Takes binary data C<$content> and reads it into a
46             filehandle. Then passes that filehandle to L.
47              
48             =cut
49              
50             sub open_string {
51 45     45 1 62 my $self = shift;
52 45         69 my ($content) = @_;
53              
54 45         55 my $fh;
55 45     1   494 open( $fh, "<", \$content );
  1         12  
  1         1  
  1         7  
56 45         1706 return $self->open_fh($fh);
57             }
58              
59             =head2 open_file $filename
60              
61             Takes a filename C<$filename> and reads its data into a
62             filehandle. Then passes the filehandle to L.
63              
64             =cut
65              
66             sub open_file {
67 3     3 1 1666 my $self = shift;
68 3         5 my ($filename) = @_;
69              
70 3         4 my $fh;
71 3 50       109 open( $fh, "<", $filename ) or die "can't open $filename for conversion";
72 3         7 binmode($fh);
73 3         9 return $self->open_fh($fh);
74             }
75              
76             =head2 open_fh
77              
78             Place-holder method for Reader's subclass. Currently
79             unimplemented.
80              
81             =cut
82              
83             sub open_fh {
84 0     0 1 0 my $self = shift;
85              
86 0         0 die "Unimplemented!";
87             }
88              
89             1;