File Coverage

blib/lib/Net/Cisco/ObjectGroup/Network.pm
Criterion Covered Total %
statement 21 21 100.0
branch 10 10 100.0
condition 8 9 88.8
subroutine 5 5 100.0
pod 0 1 0.0
total 44 46 95.6


line stmt bran cond sub pod time code
1             package Net::Cisco::ObjectGroup::Network;
2 2     2   16 use base qw(Net::Cisco::ObjectGroup::Base);
  2         4  
  2         755  
3              
4 2     2   14 use strict;
  2         4  
  2         85  
5 2     2   11 use warnings FATAL => qw(all);
  2         4  
  2         81  
6              
7 2     2   31 use Carp;
  2         8  
  2         642  
8              
9             sub push {
10 6     6 0 2815 my $self = shift;
11 6         9 my $arg_ref = shift;
12              
13 6 100 66     248 croak 'must specify either group-object or IP network'
14             if !defined $arg_ref->{group_object}
15             and !defined $arg_ref->{net_addr};
16              
17 5 100 100     204 croak 'cannot specify both group-object and IP network'
18             if defined $arg_ref->{group_object}
19             and defined $arg_ref->{net_addr};
20              
21 4 100 100     181 croak 'bad group-object'
22             if defined $arg_ref->{group_object}
23             and ! UNIVERSAL::isa( $arg_ref->{group_object}, __PACKAGE__ );
24              
25 3 100       24 my $line = defined $arg_ref->{group_object}
    100          
26             ? 'group-object '. $arg_ref->{group_object}->get_name
27             : defined $arg_ref->{netmask}
28             ? "network-object $arg_ref->{net_addr} $arg_ref->{netmask}"
29             : "network-object host $arg_ref->{net_addr}";
30              
31 3         8 push @{$self->get_objs}, $line;
  3         14  
32              
33 3         29 return $self;
34             }
35              
36             1;
37              
38             # Copyright (c) The University of Oxford 2006. All Rights Reserved.
39             #
40             # This program is free software; you can redistribute it and/or modify it
41             # under the terms of version 2 of the GNU General Public License as published
42             # by the Free Software Foundation.
43             #
44             # This program is distributed in the hope that it will be useful, but WITHOUT
45             # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46             # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
47             # more details.
48             #
49             # You should have received a copy of the GNU General Public License along with
50             # this program; if not, write to the Free Software Foundation, Inc., 51
51             # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA