line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::ListParser::Output::Tabular::Struct::Delimited; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
2207
|
use Moose; |
|
26
|
|
|
|
|
209303
|
|
|
26
|
|
|
|
|
181
|
|
4
|
26
|
|
|
26
|
|
116773
|
use Carp; |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
1596
|
|
5
|
26
|
|
|
26
|
|
586
|
use namespace::autoclean; |
|
26
|
|
|
|
|
1007
|
|
|
26
|
|
|
|
|
252
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'Siebel::Srvrmgr::ListParser::Output::Tabular::Struct'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Siebel::Srvrmgr::ListParser::Output::Tabular::Struct::Delimited - subclasses to parse delimited output from srvrmgr |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This class is a subclass of L<Siebel::Srvrmgr::ListParser::Output::Tabular::Struct> to parse output from C<srvrmgr> that |
16
|
|
|
|
|
|
|
is created with a field delimiter character. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 trimmer |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
A code reference to remove additional spaces from the fields attributes data. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
It is created automatically by a L<Moose> builder. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has trimmer => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => 'CodeRef', |
31
|
|
|
|
|
|
|
reader => 'get_trimmer', |
32
|
|
|
|
|
|
|
builder => '_build_trimmer' |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# :WORKAROUND:01-01-2014 18:42:35:: could not user super() because |
36
|
|
|
|
|
|
|
# it was using a "default" value after calling _set_header_regex |
37
|
|
|
|
|
|
|
override '_build_header_regex' => sub { |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $new_sep = '(\s+)?' . $self->get_col_sep(); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->_set_header_regex( join( $new_sep, @{ $self->get_header_cols() } ) ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# :WORKAROUND:01-01-2014 17:43:39:: used closure to compile the regex only once |
48
|
|
|
|
|
|
|
sub _build_trimmer { |
49
|
|
|
|
|
|
|
|
50
|
56
|
|
|
56
|
|
152
|
my $r_spaces = qr/\s+$/; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return sub { |
53
|
|
|
|
|
|
|
|
54
|
3955
|
|
|
3955
|
|
3324
|
my $values_ref = shift; |
55
|
|
|
|
|
|
|
|
56
|
3955
|
|
|
|
|
3147
|
for ( my $i = 0 ; $i <= $#{$values_ref} ; $i++ ) { |
|
44019
|
|
|
|
|
53435
|
|
57
|
|
|
|
|
|
|
|
58
|
40064
|
|
|
|
|
89251
|
$values_ref->[$i] =~ s/$r_spaces//; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
3955
|
|
|
|
|
3338
|
return 1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
56
|
|
|
|
|
2097
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 get_fields |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Overrided method from parent class. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Expects a string as parameter and returns a array reference with the fields values extracted. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
override 'get_fields' => sub { |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $self = shift; |
81
|
|
|
|
|
|
|
my $line = shift; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $fields_ref = $self->split_fields($line); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$self->get_trimmer()->($fields_ref); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return $fields_ref; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=pod |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 BUILD |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This L<Moose> BUILD implementation does some additional validations during object creation |
96
|
|
|
|
|
|
|
and also escapes the field delimiter character to be used in regular expressions. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub BUILD { |
101
|
|
|
|
|
|
|
|
102
|
56
|
|
|
56
|
1
|
68
|
my $self = shift; |
103
|
56
|
|
|
|
|
74
|
my $args = shift; |
104
|
|
|
|
|
|
|
|
105
|
56
|
50
|
|
|
|
148
|
confess 'col_sep is a required attribute for ' . __PACKAGE__ . ' instances' |
106
|
|
|
|
|
|
|
unless ( defined( $args->{col_sep} ) ); |
107
|
|
|
|
|
|
|
|
108
|
56
|
|
|
|
|
1897
|
my $sep = $self->get_col_sep(); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#escape the char to be used in a regex |
111
|
56
|
|
|
|
|
1893
|
$self->_set_col_sep( '\\' . $sep ); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=pod |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 define_fields_pattern |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Method overrided from the superclass. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Since this classes doesn't use the concept of "fields pattern" for parsing, |
122
|
|
|
|
|
|
|
it simply returns C<true>, making this class compatible with parent class interface. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub define_fields_pattern { |
127
|
|
|
|
|
|
|
|
128
|
56
|
|
|
56
|
1
|
694
|
return 1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SEE ALSO |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<Moose> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<Siebel::Srvrmgr::ListParser::Output::Tabular::Struct> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This software is copyright (c) 2013 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
161
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
162
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
163
|
|
|
|
|
|
|
(at your option) any later version. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
166
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
167
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
168
|
|
|
|
|
|
|
GNU General Public License for more details. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
171
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |