Scoreboard/PSGI/App.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 CC 2 SCAR 11.0
CC
2
Cov
0%
new
6.0
to_app
2.0
BEGIN
2.0
CRAP 3.0
1 package Parallel::Scoreboard::PSGI::App;
2  
3 use Class::Accessor::Lite;
4 use HTML::Entities;
5 use Parallel::Scoreboard;
6  
7 use strict;
8 use warnings;
9  
10 Class::Accessor::Lite->mk_accessors(qw(scoreboard));
11  
12 sub new {
13 my $klass = shift;
14 my %args = @_;
15 die "mandatory parameter:scoreboard is missing"
16 unless $args{scoreboard};
17 # build object
18 my $self = bless {
19 %args,
20 }, $klass;
21 return $self;
22 }
23  
24 sub to_app {
25 my $self = shift;
26 return sub {
27 my $status = $self->scoreboard->read_all;
28 return [
29 200,
30 [ 'Content-Type' => 'text/html; charset=utf-8' ],
31 [
32 sprintf(
33 << 'EOT',
34 <html>
35 <head>
36 <title>Status of %s</title>
37 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
38 </head>
39 <body>
40 <h1>Status of %s</h1>
41 <hr />
42 <table>
43 <tr><th>PID</th><th>Status</th></tr>
44 EOT
45 encode_entities($self->scoreboard->base_dir),
46 encode_entities($self->scoreboard->base_dir),
47 ),
48 (map {
49 sprintf(
50 '<tr><td>%s</td><td>%s</td>',
51 encode_entities($_),
52 encode_entities($status->{$_}),
53 )
54 } sort { $a <=> $b } keys %$status),
55 sprintf(
56 << 'EOT',
57 </table>
58 <hr />
59 Generated by <a href="http://search.cpan.org/dist/Parallel-Scoreboard/">Parallel::Scoreboard</a> %s
60 </body>
61 </html>
62 EOT
63 encode_entities($Parallel::Scoreboard::VERSION),
64 ),
65 ],
66 ];
67 };
68 }
69  
70 1;
71 __END__