File Coverage

blib/lib/DNS/Zone/File.pm
Criterion Covered Total %
statement 41 51 80.3
branch 2 4 50.0
condition 2 5 40.0
subroutine 10 13 76.9
pod 0 5 0.0
total 55 78 70.5


line stmt bran cond sub pod time code
1             #!/usr/local/bin/perl -w
2             ######################################################################
3             #
4             # DNS/Zone/File.pm
5             #
6             # $Id: File.pm,v 1.8 2003/02/04 15:37:34 awolf Exp $
7             # $Revision: 1.8 $
8             # $Author: awolf $
9             # $Date: 2003/02/04 15:37:34 $
10             #
11             # Copyright (C)2001-2003 Andy Wolf. All rights reserved.
12             #
13             # This library is free software; you can redistribute it and/or
14             # modify it under the same terms as Perl itself.
15             #
16             ######################################################################
17              
18             package DNS::Zone::File;
19              
20 2     2   1311 no warnings 'portable';
  2         5  
  2         72  
21 2     2   20 use 5.6.0;
  2         6  
  2         72  
22 2     2   9 use strict;
  2         3  
  2         54  
23 2     2   25 use warnings;
  2         3  
  2         43  
24              
25 2     2   467 use DNS::Zone;
  2         3  
  2         67  
26 2     2   544 use DNS::Zone::Label;
  2         4  
  2         67  
27 2     2   532 use DNS::Zone::Record;
  2         6  
  2         800  
28              
29             my $VERSION = '0.85';
30             my $REVISION = sprintf("%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/);
31              
32             my $map = {
33             'default' => 'DNS::Zone::File::Default'
34             };
35              
36             sub new {
37 1     1 0 29 my($pkg, %hash) = @_;
38 1         3 my $ref;
39              
40 1   50     5 my $type = $hash{'type'} || 'default';
41 1         4 my $zone = $hash{'zone'};
42 1         3 my $file = $hash{'file'};
43              
44 1         1219 eval "require $map->{$type}";
45            
46 1 50       10 if(!$@) {
47 1         12 $ref = $map->{$type}->new($zone, $file);
48             }
49             else {
50 0         0 warn $@;
51             }
52              
53 1         8 return $ref;
54             }
55              
56             sub read {
57 1     1 0 8 my($self, $file) = @_;
58 1         2 my @lines;
59              
60 1   33     7 $file = $file || $self->{'FILE'};
61            
62 1 50       1230 if(open(FILE, $file)) {
63 1         39 @lines = ;
64 1         7 chomp @lines;
65 1         16 close FILE;
66             }
67 0         0 else { warn "Cannot read file $file !"; }
68              
69 1         14 return @lines;
70             }
71            
72             sub parse {
73 0     0 0   my($self, $file) = @_;
74              
75             # Overwrite in sub classes !
76              
77 0           return $self;
78             }
79              
80             sub dump {
81 0     0 0   my($self, $file) = @_;
82              
83             # Overwrite in sub classes !
84            
85 0           return $self;
86             }
87              
88             sub debug {
89 0     0 0   my($self) = @_;
90            
91 0           eval {
92 2     2   16 use Data::Dumper;
  2         3  
  2         312  
93            
94 0           print Dumper($self);
95             };
96            
97 0           return $self;
98             }
99              
100             1;
101              
102             __END__