File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Buffer.pm
Criterion Covered Total %
statement 12 12 100.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Buffer;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Siebel::Srvrmgr::ListParser::Buffer - class to store output of commands
8              
9             =cut
10              
11 23     23   2674 use Moose;
  23         260266  
  23         123  
12 23     23   122752 use namespace::autoclean;
  23         21785  
  23         114  
13              
14             =pod
15              
16             =head1 SYNOPSIS
17              
18             my $buffer = Siebel::Srvrmgr::ListParser::Buffer->new(
19             {
20             type => 'sometype',
21             cmd_line => 'list something'
22             }
23             );
24              
25             $buffer->set_content( $cmd_output_line );
26              
27             =head1 DESCRIPTION
28              
29             This class is used by L<Siebel::Srvrmgr::ListParser> to store output read (between two commands) while is processing all the output.
30              
31             =head1 ATTRIBUTES
32              
33             =head2 type
34              
35             String that identified which kind of output is being stored. This will be used by abstract factory classes to instantiate objects from
36             L<Siebel::Srvrmgr::ListParser::Output> subclasses.
37              
38             =cut
39              
40             has 'type' => ( is => 'ro', isa => 'Str', required => 1, reader => 'get_type' );
41              
42             =pod
43              
44             =head2 cmd_line
45              
46             String that contains the identified commands that generated the output.
47              
48             =cut
49              
50             has 'cmd_line' =>
51             ( is => 'ro', isa => 'Str', required => 1, reader => 'get_cmd_line' );
52              
53             =pod
54              
55             =head2 content
56              
57             An array reference with the output being stored. Each index is one line read stored from the output.
58              
59             =cut
60              
61             has 'content' => (
62             is => 'rw',
63             isa => 'ArrayRef',
64             reader => 'get_content',
65             writer => '_set_content',
66             default => sub { return [] }
67             );
68              
69             =pod
70              
71             =head1 METHODS
72              
73             =head2 get_type
74              
75             Returns the string stored in the attribute C<type>.
76              
77             =head2 get_cmd_line
78              
79             Returns the string stored in the attribute C<type>.
80              
81             =head2 get_content
82              
83             =head2 set_content
84              
85             =cut
86              
87             sub set_content {
88              
89 12515     12515 1 13517 my $self = shift;
90 12515         9701 my $value = shift;
91              
92 12515 50       15763 if ( defined($value) ) {
93              
94 12515         338084 my $buffer_ref = $self->get_content();
95              
96 12515         10142 push( @{$buffer_ref}, $value );
  12515         333225  
97              
98             }
99              
100             }
101              
102             =pod
103              
104             =head1 AUTHOR
105              
106             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
107              
108             =head1 COPYRIGHT AND LICENSE
109              
110             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
111              
112             This file is part of Siebel Monitoring Tools.
113              
114             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
115             it under the terms of the GNU General Public License as published by
116             the Free Software Foundation, either version 3 of the License, or
117             (at your option) any later version.
118              
119             Siebel Monitoring Tools is distributed in the hope that it will be useful,
120             but WITHOUT ANY WARRANTY; without even the implied warranty of
121             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
122             GNU General Public License for more details.
123              
124             You should have received a copy of the GNU General Public License
125             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
126              
127             =cut
128              
129             __PACKAGE__->meta->make_immutable;