line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::ListParser::Output::Tabular::Struct; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Siebel::Srvrmgr::ListParser::Output::Tabular::Struct - base class for parsing srvrmgr tabular output |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
30
|
|
|
30
|
|
19232
|
use Moose 2.0401; |
|
30
|
|
|
|
|
772
|
|
|
30
|
|
|
|
|
300
|
|
12
|
30
|
|
|
30
|
|
261477
|
use namespace::autoclean 0.13; |
|
30
|
|
|
|
|
845
|
|
|
30
|
|
|
|
|
336
|
|
13
|
30
|
|
|
30
|
|
3351
|
use Carp; |
|
30
|
|
|
|
|
104
|
|
|
30
|
|
|
|
|
13523
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.29'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=pod |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is a base classes to parse C<srvrmgr> output in tabular form. That means that the output is expected to be |
21
|
|
|
|
|
|
|
as a table, having a header and a clear definition of columns. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The subclasses of this class are expected to be used inside an output class like L<Siebel::Srvrmgr::ListParser::Output::Tabular> |
24
|
|
|
|
|
|
|
since it will know the differences in parsing fixed width output from delimited one. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 header_regex |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This attribute is read-only. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The regular expression used to match the header of the list <command> output (the sequence of column names). |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
There is a L<Moose> C<builder> associated with it, so the definition of the regular expression is created automatically. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This attribute is also C<lazy>. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has 'header_regex' => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
isa => 'Str', |
43
|
|
|
|
|
|
|
builder => '_build_header_regex', |
44
|
|
|
|
|
|
|
writer => '_set_header_regex', |
45
|
|
|
|
|
|
|
reader => 'get_header_regex', |
46
|
|
|
|
|
|
|
lazy => 1 |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _build_header_regex { |
50
|
110
|
|
|
110
|
|
323
|
my $self = shift; |
51
|
|
|
|
|
|
|
$self->_set_header_regex( |
52
|
110
|
|
|
|
|
5564
|
join( $self->get_col_sep(), @{ $self->get_header_cols() } ) ); |
|
110
|
|
|
|
|
5624
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 col_sep |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This attribute is read-only. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
A regular expression string used to match the columns separator. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
col_sep has a builder C<sub> that must be override by subclasses of this class or |
64
|
|
|
|
|
|
|
an exception will be raised. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This attribute is also C<lazy>. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has 'col_sep' => ( |
71
|
|
|
|
|
|
|
is => 'ro', |
72
|
|
|
|
|
|
|
isa => 'Str', |
73
|
|
|
|
|
|
|
builder => '_build_col_sep', |
74
|
|
|
|
|
|
|
writer => '_set_col_sep', |
75
|
|
|
|
|
|
|
reader => 'get_col_sep', |
76
|
|
|
|
|
|
|
lazy => 1 |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _build_col_sep { |
80
|
0
|
|
|
0
|
|
0
|
confess '_build_col_sep must be overrided by subclasses'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 header_cols |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This attribute is read-only and required during object instantiation. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
An array reference with all the header columns names, in the exact sequence their appear in the output. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has 'header_cols' => ( |
92
|
|
|
|
|
|
|
is => 'ro', |
93
|
|
|
|
|
|
|
isa => 'ArrayRef', |
94
|
|
|
|
|
|
|
reader => 'get_header_cols', |
95
|
|
|
|
|
|
|
writer => '_set_header_cols', |
96
|
|
|
|
|
|
|
required => 1 |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=pod |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
All the attributes, since read-only, have their associated getters. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 get_col_sep |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the col_sep attribute value. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 get_header_cols |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the header_cols attribute value. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 split_fields |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Split a output line into fields as defined by C<get_col_sep> method. It expects a string as parameter. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns an array reference. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
If the separator could not be matched against the string, returns C<undef>. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub split_fields { |
124
|
21944
|
|
|
21944
|
1
|
52850
|
my ($self, $line) = @_; |
125
|
21944
|
|
|
|
|
1085442
|
my $sep = $self->get_col_sep(); |
126
|
21944
|
|
|
|
|
97538
|
my $comp_sep = qr/$sep/; |
127
|
|
|
|
|
|
|
|
128
|
21944
|
100
|
|
|
|
111073
|
if ( $line =~ $comp_sep ) { |
129
|
21942
|
|
|
|
|
208590
|
my @columns = split( $comp_sep, $line ); |
130
|
21942
|
|
|
|
|
112772
|
return \@columns; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
else { |
133
|
2
|
|
|
|
|
10
|
return; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=pod |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 define_fields_pattern |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This method must be overrided by subclasses of this classes or an exception will be raised. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
It is responsible to define automatically the fields pattern to be used during parsing to retrieve |
144
|
|
|
|
|
|
|
fields values. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub define_fields_pattern { |
149
|
2
|
|
|
2
|
1
|
1664
|
confess |
150
|
|
|
|
|
|
|
'define_fields_pattern must be overrided by subclasses of Siebel::Srvrmgr::ListParser::Output::Tabular::Struct'; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=pod |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 get_fields |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This method must be overrided by subclasses of this classes or an exception will be raised. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This methods returns the fields data as an array reference. Expects as parameter the string of the line of |
160
|
|
|
|
|
|
|
C<srvrmgr> output. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub get_fields { |
165
|
2
|
|
|
2
|
1
|
3341
|
confess |
166
|
|
|
|
|
|
|
'get_fields must be overrided by subclasses of Siebel::Srvrmgr::ListParser::Output::Tabular::Struct'; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=pod |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 CAVEATS |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
All subclasses of Siebel::Srvrmgr::ListParser::Output::Tabular::Struct expect to have both the header and trailer of |
174
|
|
|
|
|
|
|
executed commands in C<srvrmgr> program. Removing one or both of them will result in parsing errors and |
175
|
|
|
|
|
|
|
probably exceptions. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 SEE ALSO |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=over |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L<Moose> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular::Struct::Fixed> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular::Struct::Delimited> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 AUTHOR |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This software is copyright (c) 2013 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
210
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
211
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
212
|
|
|
|
|
|
|
(at your option) any later version. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
215
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
216
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
217
|
|
|
|
|
|
|
GNU General Public License for more details. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
220
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |