File Coverage

blib/lib/App/MaMGal/Base.pm
Criterion Covered Total %
statement 15 24 62.5
branch 0 6 0.0
condition 1 3 33.3
subroutine 4 6 66.6
pod 0 2 0.0
total 20 41 48.7


line stmt bran cond sub pod time code
1             # mamgal - a program for creating static image galleries
2             # Copyright 2007, 2008 Marcin Owsiany
3             # See the README file for license information
4             # Base class with some common stuff
5             package App::MaMGal::Base;
6 9     9   48 use strict;
  9         24  
  9         255  
7 9     9   46 use warnings;
  9         15  
  9         195  
8 9     9   4664 use App::MaMGal::Exceptions;
  9         48  
  9         2145  
9              
10             sub new
11             {
12 366     366 0 158092 my $that = shift;
13 366   33     2092 my $class = ref $that || $that;
14              
15 366         641 my $self = {};
16 366         1204 bless $self, $class;
17 366         1632 $self->init(@_);
18              
19 335         1176 return $self;
20             }
21              
22 0     0 0   sub init {;}
23              
24             #######################################################################################################################
25             # Utility methods
26             sub _write_contents_to
27             {
28 0     0     my $self = shift;
29 0           my $code = shift;
30 0           my $tmp_name = shift;
31 0           my $full_name = shift;
32              
33 0 0         open(OUT, '>', $tmp_name) or App::MaMGal::SystemException->throw(message => '%s: open failed: %s', objects => [$tmp_name, $!]);
34 0           print OUT &$code;
35 0 0         close(OUT) or App::MaMGal::SystemException->throw(message => '%s: close failed: %s', objects => [$tmp_name, $!]);
36 0 0         rename($tmp_name, $full_name) or App::MaMGal::SystemException->throw(message => '%s: rename failed from "%s": %s', objects => [$full_name, $tmp_name, $!]);
37             }
38              
39             1;