File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/Tabular/ListCompTypes.pm
Criterion Covered Total %
statement 24 25 96.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 31 34 91.1


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::Tabular::ListCompTypes;
2 7     7   8462 use Moose;
  7         218612  
  7         47  
3 7     7   34313 use namespace::autoclean;
  7         1106  
  7         49  
4              
5             =pod
6              
7             =head1 NAME
8              
9             Siebel::Srvrmgr::ListParser::Output::Tabular::ListCompTypes - subclass to parse list comp types command
10              
11             =cut
12              
13             extends 'Siebel::Srvrmgr::ListParser::Output::Tabular';
14              
15             =pod
16              
17             =head1 SYNOPSIS
18              
19             See L<Siebel::Srvrmgr::ListParser::Output::Tabular> for examples.
20              
21             =head1 DESCRIPTION
22              
23             This subclass of L<Siebel::Srvrmgr::ListParser::Output::Tabular> parses the output of the command C<list comp types>.
24              
25             This is the list configuration of the C<srvrmgr> expected by the module:
26              
27             srvrmgr> configure list comp type
28             CT_NAME (76): Component type name
29             CT_RUNMODE (31): Supported run mode
30             CT_ALIAS (31): Component type alias
31             CT_DESC_TEXT (251): Description of component type
32              
33             If the configuration is not setup as this, the parsing will fail and the module may raise exceptions.
34              
35             =head1 ATTRIBUTES
36              
37             All from superclass.
38              
39             =head1 METHODS
40              
41             =head2 get_attribs
42              
43             Returns the array reference stored in the C<types_attribs> attribute.
44              
45             =head2 set_attribs
46              
47             Sets the attribute C<types_attribs>. Expects an array reference as parameter.
48              
49             =cut
50              
51             sub _build_expected {
52              
53 15     15   21 my $self = shift;
54              
55 15         577 $self->_set_expected_fields(
56             [ 'CT_NAME', 'CT_RUNMODE', 'CT_ALIAS', 'CT_DESC_TEXT' ] );
57              
58             }
59              
60             sub _consume_data {
61              
62 3482     3482   2583 my $self = shift;
63 3482         2225 my $fields_ref = shift;
64 3482         2229 my $parsed_ref = shift;
65              
66 3482         2974 my $ct_name = $fields_ref->[0];
67              
68 3482         2216 my $list_len = scalar( @{$fields_ref} );
  3482         2714  
69              
70 3482         112347 my $columns_ref = $self->get_expected_fields();
71              
72 3482 50       4374 confess "Could not retrieve the name of the fields"
73             unless ( defined($columns_ref) );
74              
75 3482 50       2156 if ( @{$fields_ref} ) {
  3482         4310  
76              
77 3482         4775 for ( my $i = 0 ; $i < $list_len ; $i++ ) {
78              
79 13928         27656 $parsed_ref->{$ct_name}->{ $columns_ref->[$i] } =
80             $fields_ref->[$i];
81              
82             }
83              
84 3482         10622 return 1;
85              
86             }
87             else {
88              
89 0           return 0;
90              
91             }
92              
93             }
94              
95             =pod
96              
97             =head1 SEE ALSO
98              
99             =over
100              
101             =item *
102              
103             L<Siebel::Srvrmgr::ListParser::Output::Tabular>
104              
105             =item *
106              
107             L<Moose>
108              
109             =item *
110              
111             L<Siebel::Srvrmgr::ListParser::Output::ToString>
112              
113             =back
114              
115             =head1 AUTHOR
116              
117             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
118              
119             =head1 COPYRIGHT AND LICENSE
120              
121             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
122              
123             This file is part of Siebel Monitoring Tools.
124              
125             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
126             it under the terms of the GNU General Public License as published by
127             the Free Software Foundation, either version 3 of the License, or
128             (at your option) any later version.
129              
130             Siebel Monitoring Tools is distributed in the hope that it will be useful,
131             but WITHOUT ANY WARRANTY; without even the implied warranty of
132             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133             GNU General Public License for more details.
134              
135             You should have received a copy of the GNU General Public License
136             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
137              
138             =cut
139              
140 7     7   1504 no Moose;
  7         12  
  7         33  
141             __PACKAGE__->meta->make_immutable;