File Coverage

lib/BalanceOfPower/Printer.pm
Criterion Covered Total %
statement 21 22 95.4
branch 2 4 50.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 26 30 86.6


line stmt bran cond sub pod time code
1             package BalanceOfPower::Printer;
2             $BalanceOfPower::Printer::VERSION = '0.400110';
3 13     13   5022 use Template;
  13         170443  
  13         316  
4 13     13   65 use Cwd 'abs_path';
  13         15  
  13         2177  
5              
6             sub print
7             {
8 2     2 0 5 my $mode = shift;
9 2         5 my $world = shift;
10 2         5 my $template = shift;
11 2         3 my $vars = shift;
12              
13 2         6 my $module_file_path = __FILE__;
14 2         121 my $root_path = abs_path($module_file_path);
15 2         8 $root_path =~ s/Printer\.pm//;
16 2         8 $root_path .= "templates";
17              
18 2         44 my $tt = Template->new({INCLUDE_PATH => "$root_path/$mode",
19             PLUGIN_BASE => 'Template::Plugin::Filter'});
20              
21 2 50       33060 if(ref $world eq 'BalanceOfPower::World')
22             {
23 2         3 my %nation_codes = reverse %{$world->nation_codes};
  2         25  
24 2         6 $vars->{'nation_codes'} = \%nation_codes;
25             }
26 2         5 my $output;
27 2 50       11 $tt->process("$template.tt", $vars, \$output) || die $tt->error . "\n";
28 0           return $output;
29             }
30              
31             1;
32