File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output.pm
Criterion Covered Total %
statement 14 15 93.3
branch n/a
condition n/a
subroutine 5 6 83.3
pod 2 2 100.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Siebel::Srvrmgr::ListParser::Output - base class of srvrmgr output
8              
9             =head1 SYNOPSIS
10              
11             use Siebel::Srvrmgr::ListParser::Output;
12             my $output = Siebel::Srvrmgr::ListParser::Output->new({
13             data_type => 'sometype',
14             raw_data => \@data,
15             cmd_line => 'list something from somewhere'
16             });
17             $output->store($complete_pathname);
18              
19             =cut
20              
21 31     31   19332 use Moose 2.0401;
  31         709  
  31         315  
22 31     31   252656 use namespace::autoclean 0.13;
  31         873  
  31         294  
23 31     31   3332 use Carp;
  31         85  
  31         2697  
24 31     31   243 use Siebel::Srvrmgr::Regexes qw(ROWS_RETURNED);
  31         92  
  31         7278  
25             our $VERSION = '0.29'; # VERSION
26              
27             =pod
28              
29             =head1 DESCRIPTION
30              
31             Siebel::Srvrmgr::ListParser::Output is a superclass of output types classes.
32              
33             It contains only basic attributes and methods that enable specific parsing and serializable methods.
34              
35             The C<parse> method must be overrided by subclasses or a exception will be raised during object creation.
36              
37             =head1 ATTRIBUTES
38              
39             =head2 data_type
40              
41             Identifies which kind of data is being given to the class. This is usually used by abstract factory class to identify which subclass of
42             Siebel::Srvrmgr::ListParser::Output must be created.
43              
44             This attribute is required during object creation.
45              
46             =cut
47              
48             has 'data_type' =>
49             ( is => 'ro', isa => 'Str', reader => 'get_data_type', required => 1 );
50              
51             =pod
52              
53             =head2 raw_data
54              
55             An array reference with the lines to be processed.
56              
57             This attribute is required during object creation.
58              
59             =cut
60              
61             has 'raw_data' => (
62             is => 'rw',
63             isa => 'ArrayRef',
64             reader => 'get_raw_data',
65             writer => 'set_raw_data',
66             required => 1
67              
68             );
69              
70             =pod
71              
72             =head2 data_parsed
73              
74             An hash reference with the data parsed from C<raw_data> attribute.
75              
76             =cut
77              
78             # :TODO:08-10-2013:arfreitas: should use an array reference to use less memory since each subclass will "know" the meaning of
79             # each field because of the expected header sequence
80              
81             has 'data_parsed' => (
82             is => 'rw',
83             isa => 'HashRef',
84             reader => 'get_data_parsed',
85             writer => 'set_data_parsed'
86             );
87              
88             =pod
89              
90             =head2 cmd_line
91              
92             A string of the command that originates from the output (the data of C<raw_data> attribute).
93              
94             This attribute is required during object creation.
95              
96             =cut
97              
98             has 'cmd_line' =>
99             ( isa => 'Str', is => 'ro', reader => 'get_cmd_line', required => 1 );
100              
101             =pod
102              
103             =head2 clear_raw
104              
105             A boolean attribute that defines if the raw data recovered from C<srvrmgr> should be kept or discarded as soon as possibly.
106              
107             Having a default value of true, it should help reducing memory usage or debugging, if set false.
108              
109             =cut
110              
111             has 'clear_raw' => (
112             is => 'rw',
113             isa => 'Bool',
114             reader => 'clear_raw',
115             writer => 'set_clear_raw',
116             default => 0
117             );
118              
119             =pod
120              
121             =head1 METHODS
122              
123             =head2 clear_raw
124              
125             Getter for the C<clear_raw> attribute.
126              
127             =head2 set_clear_raw
128              
129             Setter for the C<clear_raw> attribute.
130              
131             =head2 get_cmd_line
132              
133             Returns an string of the attribute C<get_cmd_line>.
134              
135             =head2 get_data_parsed
136              
137             Retuns an hash reference of C<data_parsed> attribute.
138              
139             =head2 set_data_parsed
140              
141             Sets the C<data_parsed> attribute. It is expected an hash reference as parameter of the method.
142              
143             =head2 get_raw_data
144              
145             Returns an array reference of the attribute C<raw_data>.
146              
147             =head2 set_raw_data
148              
149             Sets the C<raw_data> attribute. An array reference is expected as parameter of the method.
150              
151             =head2 BUILD
152              
153             All subclasses of Siebel::Srvrmgr::ListParser::Object will call the method C<parse> right after object instatiation.
154              
155             =cut
156              
157             sub BUILD {
158              
159 223     223 1 702 my $self = shift;
160              
161 223         2003 $self->parse();
162              
163             }
164              
165             =pod
166              
167             =head2 parse
168              
169             This method must be overrided by subclasses.
170              
171             =cut
172              
173             sub parse {
174              
175 0     0 1   confess
176             'parse method must be overrided by subclasses of Siebel::Srvrmgr::ListParser::Output';
177              
178             }
179              
180             =pod
181              
182             =head1 SEE ALSO
183              
184             =over
185              
186             =item *
187              
188             L<Moose>
189              
190             =item *
191              
192             L<namespace::autoclean>
193              
194             =back
195              
196             =head1 AUTHOR
197              
198             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
199              
200             =head1 COPYRIGHT AND LICENSE
201              
202             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
203              
204             This file is part of Siebel Monitoring Tools.
205              
206             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
207             it under the terms of the GNU General Public License as published by
208             the Free Software Foundation, either version 3 of the License, or
209             (at your option) any later version.
210              
211             Siebel Monitoring Tools is distributed in the hope that it will be useful,
212             but WITHOUT ANY WARRANTY; without even the implied warranty of
213             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
214             GNU General Public License for more details.
215              
216             You should have received a copy of the GNU General Public License
217             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
218              
219             =cut
220              
221             __PACKAGE__->meta->make_immutable;
222