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