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