File Coverage

blib/lib/Tapper/Reports/Web/Controller/Tapper.pm
Criterion Covered Total %
statement 29 36 80.5
branch 1 6 16.6
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 40 52 76.9


line stmt bran cond sub pod time code
1             package Tapper::Reports::Web::Controller::Tapper;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Reports::Web::Controller::Tapper::VERSION = '5.0.13';
4 10     10   5054 use strict;
  10         17  
  10         296  
5 10     10   38 use warnings;
  10         13  
  10         269  
6 10     10   264 use 5.010;
  10         26  
7 10     10   3710 use Tapper::Reports::Web::Util;
  10         21  
  10         345  
8              
9 10     10   56 use parent 'Tapper::Reports::Web::Controller::Base';
  10         11  
  10         76  
10              
11             sub index :Path :Args(0)
12             {
13 3     3   3742 my ( $self, $c ) = @_;
14              
15             # the easy way, to avoid fiddling with Mason autohandlers on
16             # simple redirects
17              
18 3         11 my $body = <<EOF;
19             <html>
20             <head>
21             <meta http-equiv="refresh" content="0; URL=/tapper/start">
22             <meta name="description" content="Tapper"
23             <title>Tapper</title>
24             </head>
25             EOF
26 3         73 $c->response->body($body);
27 10     10   1102 }
  10         11  
  10         79  
28              
29              
30             sub auto :Private
31             {
32 18     18 1 20106 my ( $self, $c ) = @_;
33 18         178 my $util = Tapper::Reports::Web::Util->new();
34              
35              
36 18         3059 my (undef, $action) = split '/', $c->req->action;
37 18         920 $c->stash->{top_menu} = $util->prepare_top_menu($action);
38 18 50       983 if ($c->config->{use_authentication}) {
39 0 0       0 if ($c->user_exists()) {
40 0         0 my $username = $c->user->username;
41 0         0 foreach (@{$c->stash->{top_menu}}) {
  0         0  
42 0 0       0 if ($_->{text} eq 'Login') {
43 0         0 $_->{text} = "Logout $username";
44 0         0 $_->{uri} = '/tapper/user/logout';
45             }
46             }
47             }
48             }
49              
50             # if auto returns false the remaining actions are not called
51 18         1211 1;
52 10     10   78911 }
  10         20  
  10         50  
53              
54              
55             1;
56              
57             __END__
58              
59             =pod
60              
61             =encoding UTF-8
62              
63             =head1 NAME
64              
65             Tapper::Reports::Web::Controller::Tapper
66              
67             =head2 auto
68              
69             This function is called. It creates the datastructure for the associated
70             autohandler template to generate the navigation links. This
71             datastructure is put onto the stash and therefore the function does not
72             return anything. It is called automatically from Catalyst with an object
73             reference ($self) and the catalyst context. Thus you also don't need to
74             worry about parameters.
75              
76             =head1 AUTHORS
77              
78             =over 4
79              
80             =item *
81              
82             AMD OSRC Tapper Team <tapper@amd64.org>
83              
84             =item *
85              
86             Tapper Team <tapper-ops@amazon.com>
87              
88             =back
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is Copyright (c) 2017 by Advanced Micro Devices, Inc..
93              
94             This is free software, licensed under:
95              
96             The (two-clause) FreeBSD License
97              
98             =cut