File Coverage

blib/lib/Buffer/Transactional/Buffer/File.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Buffer::Transactional::Buffer::File;
2 1     1   2700 use Moose;
  0            
  0            
3             use Moose::Util::TypeConstraints;
4              
5             use IO::File;
6             use Data::UUID;
7              
8             our $VERSION = '0.02';
9             our $AUTHORITY = 'cpan:STEVAN';
10              
11             class_type 'IO::File';
12              
13             has 'uuid' => (
14             is => 'ro',
15             isa => 'Str',
16             lazy => 1,
17             default => sub { Data::UUID->new->create_str },
18             );
19              
20             has '_buffer' => (
21             is => 'ro',
22             isa => 'IO::File',
23             lazy => 1,
24             default => sub { IO::File->new( (shift)->uuid, 'w' ) },
25             handles => {
26             'put' => 'print'
27             }
28             );
29              
30             # *sigh* Moose
31             with 'Buffer::Transactional::Buffer';
32              
33             sub as_string {
34             my $self = shift;
35             $self->_buffer->flush;
36             join "" => IO::File->new( $self->uuid, 'r' )->getlines;
37             }
38              
39             sub DEMOLISH {
40             my $self = shift;
41             unlink $self->uuid;
42             }
43              
44             __PACKAGE__->meta->make_immutable;
45              
46             no Moose; 1;
47              
48             __END__
49              
50             =pod
51              
52             =head1 NAME
53              
54             Buffer::Transactional::Buffer::File - A file based buffer
55              
56             =head1 DESCRIPTION
57              
58             This buffer will write a file for each buffer it creates and
59             name it with a UUID. Upon destruction it will cleanup the file.
60              
61             =head1 BUGS
62              
63             All complex software has bugs lurking in it, and this module is no
64             exception. If you find a bug please either email me, or add the bug
65             to cpan-RT.
66              
67             =head1 AUTHOR
68              
69             Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             Copyright 2009, 2010 Infinity Interactive, Inc.
74              
75             L<http://www.iinteractive.com>
76              
77             This library is free software; you can redistribute it and/or modify
78             it under the same terms as Perl itself.
79              
80             =cut