lib/POE/Component/MessageQueue/Statistics/Publish/YAML.pm

filter: Statementstmt 59.3% 19 / 32 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 2 / 2 totaltotal 56.2% 27 / 48 CC 4 SCAR 20.8
CC
4
Cov
50%
publish_file
20.0
publish_handle
2.0
BEGIN
1.0
CRAP 8.0
« lib/POE/Component/MessageQueue/Storage/Generic/DBI.pm ↑ Summary lib/POE/Component/MessageQueue/Storage/Generic.pm »
1 # $Id$
2 #
3 # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
4 # All rights reserved.
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18  
19 package POE::Component::MessageQueue::Statistics::Publish::YAML;
20 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use base qw(POE::Component::MessageQueue::Statistics::Publish);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use Best [ qw(YAML::Syck YAML) ], qw(Dump);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use File::Copy qw(move);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 sub publish_file
28 {
29 0 ▶ my ($self, $filename) = @_;
Subroutine publish_file: not called CC=4 SCAR=30.0
Pod documented
30  
31 # Be friendly to people who might be reading the file
32 0 my $fh = File::Temp->new(UNLINK => 0);
33 0 my %h = %{ $self->{statistics}->{statistics} };
34 0 eval {
35 0 $fh->print( Dump( { %h, generated => scalar localtime } ) );
36 0 $fh->flush;
37 0 ▶ move($fh->filename, $filename) or die "Failed to rename $fh to $filename: $!";
Branch: 1 branch
BranchTrueFalseTotal
move($fh->filename, $filename) or die "Failed to rename $fh to ${filename}: $!" 0 0 0
38 };
39 0 ▶ if (my $e = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 0 0
40 0 ▶ $fh->unlink_on_destroy( 1 ) if $fh;
Branch: 1 branch
BranchTrueFalseTotal
if $fh 0 0 0
41 0 die $e;
42 }
43 }
44  
45 sub publish_handle
46 {
47 0 ▶ my ($self, $handle) = @_;
Subroutine publish_handle: not called CC=1 SCAR=6.9
Pod documented
48 0 $handle->print( Dump( $self->{statistics}->{statistics} ) );
49 }
50  
51 2 1;
52  
53 __END__
54  
55 =head1 NAME
56  
57 POE::Component::MessageQueue::Statistics::Publish::YAML - Publish Statistics In YAML Format
58  
59 =head1 SYNOPSIS
60  
61 use POE::Component::MessageQueue::Statistics;
62 use POE::Component::MessageQueue::Statistics::Publish::YAML;
63  
64 # This is initialized elsewhere
65 my $stats = POE::Component::MessageQueue::Statistics->new();
66  
67 my $publish = POE::Component::MessageQueue::Statistics::Publish::YAML->new(
68 output => \*STDOUT,
69 statistics => $stats
70 );
71 $publish->publish();
72  
73 =head1 DESCRIPTION
74  
75 This module dumps the statistics information in YAML format
76  
77 =head1 SEE ALSO
78  
79 L<POE::Component::MessageQueue::Statistics>,
80 L<POE::Component::MessageQueue::Statistics::Publish>
81  
82 =head1 AUTHOR
83  
84 Daisuke Maki E<lt>daisuke@endeworks.jpE<gt>
85  
86 =cut
« lib/POE/Component/MessageQueue/Storage/Generic/DBI.pm ↑ Summary lib/POE/Component/MessageQueue/Storage/Generic.pm »