line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Siebel::Srvrmgr::ListParser::Output::ToString; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
18426
|
use Moose::Role; |
|
27
|
|
|
|
|
42
|
|
|
27
|
|
|
|
|
198
|
|
4
|
27
|
|
|
27
|
|
101580
|
use Carp; |
|
27
|
|
|
|
|
45
|
|
|
27
|
|
|
|
|
8091
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Siebel::Srvrmgr::ListParser::Output::ToString - Moose role to "stringfy" objects |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Siebel::Srvrmgr::ListParser::Output::ToString'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This role will use some introspection to enable a object to return all it's attributes as a string. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 to_string_header |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Returns a string with all attributes values, ordered alphabetically by their respective attribute names, concatenated with a single character. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Expects as parameter a single character to be used as field separator. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub to_string_header { |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
1
|
429
|
my $self = shift; |
31
|
1
|
|
|
|
|
1
|
my $separator = shift; |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
33
|
|
|
8
|
confess 'separator must be a single character' |
34
|
|
|
|
|
|
|
unless ( ( defined($separator) ) and ( $separator =~ /^.$/ ) ); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
3
|
my $meta = $self->meta; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
15
|
my $attribs_names_ref = $self->_to_string; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
2
|
return join( $separator, @{$attribs_names_ref} ); |
|
1
|
|
|
|
|
4
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 to_string |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Returns a string with all attributes values, ordered alphabetically by their respective attribute names, concatenated with a single character. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Expects as parameter a single character to be used as field separator. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub to_string { |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
2
|
1
|
27
|
my $self = shift; |
55
|
2
|
|
|
|
|
3
|
my $separator = shift; |
56
|
|
|
|
|
|
|
|
57
|
2
|
100
|
66
|
|
|
26
|
confess 'separator must be a single character' |
58
|
|
|
|
|
|
|
unless ( ( defined($separator) ) and ( $separator =~ /^.$/ ) ); |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
5
|
my $meta = $self->meta; |
61
|
1
|
|
|
|
|
20
|
my $attribs_names_ref = $self->_to_string; |
62
|
1
|
|
|
|
|
2
|
my @values; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
1
|
foreach my $name ( @{$attribs_names_ref} ) { |
|
1
|
|
|
|
|
3
|
|
65
|
|
|
|
|
|
|
|
66
|
16
|
|
|
|
|
30
|
my $attrib = $meta->get_attribute($name); |
67
|
16
|
|
|
|
|
76
|
my $reader = $attrib->get_read_method; |
68
|
|
|
|
|
|
|
|
69
|
16
|
100
|
|
|
|
569
|
push( @values, ( defined( $self->$reader ) ? $self->$reader : '' ) ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
62
|
return join( $separator, @values ); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _to_string { |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
3
|
my $meta = $self->meta; |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
31
|
my @attribs = sort( $meta->get_attribute_list ); |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
|
|
30
|
return \@attribs; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This file is part of Siebel Monitoring Tools. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Siebel Monitoring Tools is free software: you can redistribute it and/or modify |
100
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
101
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
102
|
|
|
|
|
|
|
(at your option) any later version. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Siebel Monitoring Tools is distributed in the hope that it will be useful, |
105
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
106
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
107
|
|
|
|
|
|
|
GNU General Public License for more details. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
110
|
|
|
|
|
|
|
along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |