File Coverage

blib/lib/DNS/Config/Statement/Options.pm
Criterion Covered Total %
statement 35 50 70.0
branch 2 6 33.3
condition 1 6 16.6
subroutine 8 10 80.0
pod 0 4 0.0
total 46 76 60.5


line stmt bran cond sub pod time code
1             #!/usr/local/bin/perl -w
2             ######################################################################
3             #
4             # DNS/Config/Statement/Options.pm
5             #
6             # $Id: Options.pm,v 1.3 2003/02/16 10:15:33 awolf Exp $
7             # $Revision: 1.3 $
8             # $Author: awolf $
9             # $Date: 2003/02/16 10:15:33 $
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::Config::Statement::Options;
19              
20 2     2   647 no warnings 'portable';
  2         5  
  2         687  
21 2     2   24 use 5.6.0;
  2         7  
  2         79  
22 2     2   10 use strict;
  2         3  
  2         110  
23 2     2   10 use warnings;
  2         3  
  2         58  
24 2     2   9 use vars qw(@ISA);
  2         3  
  2         104  
25              
26 2     2   11 use DNS::Config::Statement;
  2         3  
  2         1134  
27              
28             @ISA = qw(DNS::Config::Statement);
29              
30             my $VERSION = '0.66';
31             my $REVISION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
32              
33             sub new {
34 1     1 0 3 my($pkg) = @_;
35 1   33     10 my $class = ref($pkg) || $pkg;
36              
37 1         2 my $self = {};
38            
39 1         3 bless $self, $class;
40              
41 1         4 return $self;
42             }
43              
44             sub parse_tree {
45 1     1 0 2 my($self, @array) = @_;
46              
47 1         1 my $data = shift @array;
48 1         2 my @data = @$data;
49              
50 1         2 foreach my $stmt (@data) {
51 3         8 my @stmt = @$stmt;
52            
53 3         5 my $key = uc shift @stmt;
54            
55 3 100       7 if(scalar(@stmt) == 1) {
56 2         12 $self->{$key} = shift @stmt;
57 2         5 $self->{$key} =~ s/^\"//g;
58 2         6 $self->{$key} =~ s/\"$//g;
59             }
60             else {
61 1         4 $self->{$key} = \@stmt;
62             }
63             }
64            
65 1         4 return $self
66             }
67              
68             sub dump {
69 0     0 0   my($self) = @_;
70 0           my @array;
71              
72             my @array2;
73 0           foreach my $key (keys %$self) {
74 0 0 0       if(($key =~ /FILE/) || ($key =~ /DIRECTORY/)) {
75 0           push @array2, ([ lc $key, q(") . $self->{$key} . q(")]);
76             }
77             else {
78 0           push @array2, ([ lc $key, $self->{$key}]);
79             }
80             }
81            
82 0           push @array, ('options', \@array2 );
83            
84 0           my $string = $self->substatement(@array);
85 0           print $string, "\n";
86              
87 0           return $self;
88             }
89              
90             sub directory {
91 0     0 0   my($self) = @_;
92            
93 0           my $directory;
94 0 0         if(exists $self->{'DIRECTORY'}) {
95 0           $directory = $self->{'DIRECTORY'};
96             }
97            
98 0           return $directory;
99             }
100              
101             1;
102              
103             __END__