File Coverage

blib/lib/Plack/App/Restricted.pm
Criterion Covered Total %
statement 32 32 100.0
branch 2 2 100.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 43 43 100.0


line stmt bran cond sub pod time code
1             package Plack::App::Restricted;
2              
3 3     3   254157 use base qw(Plack::Component::Tags::HTML);
  3         6  
  3         1959  
4 3     3   293144 use strict;
  3         8  
  3         115  
5 3     3   19 use warnings;
  3         6  
  3         208  
6              
7 3     3   21 use Plack::Util::Accessor qw(label);
  3         9  
  3         33  
8 3     3   2276 use Tags::HTML::Container;
  3         59951  
  3         10330  
9              
10             our $VERSION = 0.01;
11              
12             sub _css {
13 3     3   2748 my ($self, $env) = @_;
14              
15 3         19 $self->{'_tags_html_container'}->process_css;
16              
17 3         1060 $self->{'css'}->put(
18             ['s', '.restricted'],
19             ['d', 'color', 'red'],
20             ['d', 'font-family', 'sans-serif'],
21             ['d', 'font-size', '3em'],
22             ['e'],
23             );
24              
25 3         719 return;
26             }
27              
28             sub _prepare_app {
29 3     3   471245 my $self = shift;
30              
31             # Inherite defaults.
32 3         21 $self->SUPER::_prepare_app;
33              
34 3 100       891 if (! defined $self->label) {
35 2         17 $self->label('Restricted access');
36             }
37              
38 3         30 $self->{'_tags_html_container'} = Tags::HTML::Container->new(
39             'css' => $self->css,
40             'tags' => $self->tags,
41             );
42              
43 3         1400 return;
44             }
45              
46             sub _tags_middle {
47 3     3   11631 my ($self, $env) = @_;
48              
49 3         15 my $label = $self->label;
50             $self->{'_tags_html_container'}->process(
51             sub {
52 3     3   2433 my $self = shift;
53              
54 3         23 $self->{'tags'}->put(
55             ['b', 'div'],
56             ['a', 'class', 'restricted'],
57             ['d', $label],
58             ['e', 'div'],
59             );
60              
61 3         3466 return;
62             },
63 3         46 );
64              
65 3         1030 return;
66             }
67              
68              
69             1;
70              
71             __END__