line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Appliance::Phrasebook; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
4
|
|
|
4
|
|
123754
|
$Net::Appliance::Phrasebook::VERSION = '2.103642'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
38
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
722
|
|
7
|
4
|
|
|
4
|
|
25
|
use warnings FATAL => qw(all); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
514
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
32
|
use base qw(Class::Data::Inheritable); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
4942
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
6083
|
use Data::Phrasebook; |
|
4
|
|
|
|
|
9154
|
|
|
4
|
|
|
|
|
183
|
|
12
|
4
|
|
|
4
|
|
36
|
use List::Util qw(first); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
497
|
|
13
|
4
|
|
|
4
|
|
4110
|
use List::MoreUtils qw(after_incl); |
|
4
|
|
|
|
|
15851
|
|
|
4
|
|
|
|
|
418
|
|
14
|
4
|
|
|
4
|
|
36
|
use File::Basename; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
399
|
|
15
|
4
|
|
|
4
|
|
4356
|
use Symbol; |
|
4
|
|
|
|
|
4771
|
|
|
4
|
|
|
|
|
308
|
|
16
|
4
|
|
|
4
|
|
28
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
12179
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('__phrasebook_file'); |
19
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('__families' => [ |
20
|
|
|
|
|
|
|
['FWSM3', 'FWSM', 'PIXOS', 'Cisco'], |
21
|
|
|
|
|
|
|
['ASA', 'PIXOS7', 'PIXOS', 'Cisco'], |
22
|
|
|
|
|
|
|
['Aironet', 'IOS', 'Cisco'], |
23
|
|
|
|
|
|
|
['CATOS', 'Cisco'], |
24
|
|
|
|
|
|
|
['JUNOS', 'Cisco'], |
25
|
|
|
|
|
|
|
['HP', 'Cisco'], |
26
|
|
|
|
|
|
|
['Nortel', 'Cisco'], |
27
|
|
|
|
|
|
|
['ExtremeXOS', 'Cisco'], |
28
|
|
|
|
|
|
|
]); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
31
|
12
|
|
|
12
|
1
|
14608
|
my $class = shift; |
32
|
12
|
|
|
|
|
54
|
my %args = @_; |
33
|
|
|
|
|
|
|
|
34
|
12
|
100
|
|
|
|
272
|
croak "missing argument to Net::Appliance::Phrasebook::new" |
35
|
|
|
|
|
|
|
if not defined $args{platform}; |
36
|
|
|
|
|
|
|
|
37
|
11
|
|
|
|
|
24
|
my ($data, $dict); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# user's own phrasebook |
40
|
11
|
100
|
|
|
|
49
|
if (exists $args{source}) { |
41
|
3
|
|
|
|
|
7
|
$data = $args{source}; |
42
|
3
|
|
|
|
|
7
|
$dict = $args{platform}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
# our internal phrasebook |
46
|
|
|
|
|
|
|
else { |
47
|
|
|
|
|
|
|
# find and prune down dictionary list |
48
|
|
|
|
|
|
|
# NOTE: nested func's from List::* have bad scope, hence using inner grep |
49
|
8
|
|
|
19
|
|
38
|
my $family = first { grep { $_ eq $args{platform} } @{$_} } @{__PACKAGE__->__families}; |
|
19
|
|
|
|
|
121
|
|
|
63
|
|
|
|
|
126
|
|
|
19
|
|
|
|
|
41
|
|
|
8
|
|
|
|
|
43
|
|
50
|
8
|
|
|
12
|
|
51
|
$dict = [ after_incl { $_ eq $args{platform} } @{$family} ]; |
|
12
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
43
|
|
51
|
|
|
|
|
|
|
|
52
|
8
|
|
|
|
|
279
|
croak "unknown platform: $args{platform}, could not find dictionary" |
53
|
8
|
100
|
66
|
|
|
26
|
if scalar @{$dict} == 0 or ! defined $dict->[0]; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# find our phrasebook file on the filesystem |
56
|
7
|
|
|
|
|
41
|
(my $pkg_path = __PACKAGE__) =~ s{::}{/}g; |
57
|
7
|
|
|
|
|
219
|
my (undef, $directory, undef) = fileparse( |
58
|
|
|
|
|
|
|
$INC{ $pkg_path .'.pm' } |
59
|
|
|
|
|
|
|
); |
60
|
7
|
50
|
|
|
|
28
|
croak "couldn't find the NAS Phrasebook home directory" |
61
|
|
|
|
|
|
|
if !defined $directory; |
62
|
|
|
|
|
|
|
|
63
|
7
|
|
|
|
|
13
|
$data = $directory . 'Phrasebook/nas-pb.yml'; |
64
|
7
|
50
|
|
|
|
437
|
croak "NAS Phrasebook file at $data does not seem to exist" |
65
|
|
|
|
|
|
|
if ! -e $data; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
10
|
|
|
|
|
95
|
my $self = Data::Phrasebook->new( |
69
|
|
|
|
|
|
|
class => 'Plain', |
70
|
|
|
|
|
|
|
loader => 'YAML', |
71
|
|
|
|
|
|
|
file => $data, |
72
|
|
|
|
|
|
|
dict => $dict, |
73
|
|
|
|
|
|
|
); |
74
|
10
|
|
|
|
|
35267
|
$self->delimiters(qr{^!}); # it objects to colons |
75
|
10
|
|
|
|
|
134
|
$self->data('0 but true'); # force load on Phrasebook (a bug in D::P) |
76
|
|
|
|
|
|
|
|
77
|
10
|
|
|
|
|
521557
|
return $self; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
*{Symbol::qualify_to_ref('load')} = \&new; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# ABSTRACT: Network appliance command-line phrasebook |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |