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