File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/Tabular/ListCompDef.pm
Criterion Covered Total %
statement 21 22 95.4
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 27 30 90.0


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::Tabular::ListCompDef;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Siebel::Srvrmgr::ListParser::Output::Tabular::ListCompDef - subclass to parse component definitions
8              
9             =cut
10              
11 9     9   11651 use Moose;
  9         342207  
  9         78  
12 9     9   63300 use namespace::autoclean;
  9         8367  
  9         90  
13              
14             extends 'Siebel::Srvrmgr::ListParser::Output::Tabular';
15              
16             =pod
17              
18             =head1 SYNOPSIS
19              
20             use Siebel::Srvrmgr::ListParser::Output::ListCompDef;
21              
22             my $comp_defs = Siebel::Srvrmgr::ListParser::Output::Tabular::ListCompDef->new({});
23              
24             =head1 DESCRIPTION
25              
26             This subclass of L<SiebeL::Srvrmgr::ListParser::Output::Tabular> parses the output of the command C<list comp def COMPONENT_NAME>.
27              
28             The order of the fields and their configuration must follow the pattern defined below:
29              
30             srvrmgr> configure list comp def
31             CC_NAME (76): Component name
32             CT_NAME (76): Component type name
33             CC_RUNMODE (31): Component run mode (enum)
34             CC_ALIAS (31): Component alias
35             CC_DISP_ENABLE_ST (61): Display enablement state (translatable)
36             CC_DESC_TEXT (115): Component description
37             CG_NAME (76): Component group
38             CG_ALIAS (31): Component Group Alias
39             CC_INCARN_NO (23): Incarnation Number
40              
41             =head1 ATTRIBUTES
42              
43             All attributes of L<SiebeL::Srvrmgr::ListParser::Output::Tabular>.
44              
45             =head1 METHODS
46              
47             All methods of L<SiebeL::Srvrmgr::ListParser::Output::Tabular> plus the ones explaned below.
48              
49             =head2 get_comp_defs
50              
51             Returns the content of C<comp_params> attribute.
52              
53             =head2 set_comp_defs
54              
55             Set the content of the C<comp_defs> attribute. Expects an array reference as parameter.
56              
57             =head2 parse
58              
59             Parses the content of C<raw_data> attribute, setting the result on C<parsed_data> attribute.
60              
61             The contents of C<raw_data> is changed to an empty array reference at the end of the process.
62              
63             It raises an exception when the parser is not able to define the C<fields_pattern> attribute.
64              
65             =cut
66              
67             sub _build_expected {
68              
69 27     27   55 my $self = shift;
70              
71 27         1499 $self->_set_expected_fields(
72             [
73             'CC_NAME', 'CT_NAME',
74             'CC_RUNMODE', 'CC_ALIAS',
75             'CC_DISP_ENABLE_ST', 'CC_DESC_TEXT',
76             'CG_NAME', 'CG_ALIAS',
77             'CC_INCARN_NO'
78             ]
79             );
80              
81             }
82              
83             sub _consume_data {
84              
85 1133     1133   1555 my $self = shift;
86 1133         1376 my $fields_ref = shift;
87 1133         1298 my $parsed_ref = shift;
88              
89 1133         1716 my $cc_name = $fields_ref->[0];
90              
91 1133         1237 my $list_len = scalar( @{$fields_ref} );
  1133         1643  
92              
93 1133         56648 my $columns_ref = $self->get_expected_fields();
94              
95 1133 50       2469 die "Cannot continue without defining fields names"
96             unless ( defined($columns_ref) );
97              
98 1133 50       1216 if ( @{$fields_ref} ) {
  1133         2265  
99              
100 1133         2699 for ( my $i = 0 ; $i < $list_len ; $i++ ) {
101              
102 10197         34025 $parsed_ref->{$cc_name}->{ $columns_ref->[$i] } =
103             $fields_ref->[$i];
104              
105             }
106              
107 1133         6308 return 1;
108              
109             }
110             else {
111              
112 0           return 0;
113              
114             }
115              
116             }
117              
118             =pod
119              
120             =head1 SEE ALSO
121              
122             =over
123              
124             =item *
125              
126             L<Siebel::Srvrmgr::ListParser::Output::Tabular>
127              
128             =item *
129              
130             L<Moose>
131              
132             =back
133              
134             =head1 AUTHOR
135              
136             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
137              
138             =head1 COPYRIGHT AND LICENSE
139              
140             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
141              
142             This file is part of Siebel Monitoring Tools.
143              
144             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
145             it under the terms of the GNU General Public License as published by
146             the Free Software Foundation, either version 3 of the License, or
147             (at your option) any later version.
148              
149             Siebel Monitoring Tools is distributed in the hope that it will be useful,
150             but WITHOUT ANY WARRANTY; without even the implied warranty of
151             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152             GNU General Public License for more details.
153              
154             You should have received a copy of the GNU General Public License
155             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
156              
157             =cut
158              
159             __PACKAGE__->meta->make_immutable;
160              
161             1;