File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output.pm
Criterion Covered Total %
statement 20 21 95.2
branch n/a
condition n/a
subroutine 7 8 87.5
pod 2 2 100.0
total 29 31 93.5


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