File Coverage

blib/lib/Tapper/Reports/Web/Controller/Tapper/Preconditions.pm
Criterion Covered Total %
statement 33 68 48.5
branch 0 10 0.0
condition n/a
subroutine 11 17 64.7
pod 0 5 0.0
total 44 100 44.0


line stmt bran cond sub pod time code
1             package Tapper::Reports::Web::Controller::Tapper::Preconditions;
2             our $AUTHORITY = 'cpan:TAPPER';
3             $Tapper::Reports::Web::Controller::Tapper::Preconditions::VERSION = '5.0.13';
4 10     10   5010 use strict;
  10         16  
  10         320  
5 10     10   37 use warnings;
  10         12  
  10         258  
6              
7 10     10   33 use parent 'Tapper::Reports::Web::Controller::Base';
  10         15  
  10         60  
8 10     10   594 use Tapper::Cmd::Precondition;
  10         11  
  10         194  
9 10     10   35 use Tapper::Model 'model';
  10         13  
  10         1433  
10              
11             sub index :Path :Args(0)
12             {
13 0     0   0 my ( $self, $c ) = @_;
14              
15 0         0 my $precond_search = $c->model('TestrunDB')->resultset('Precondition');
16 0         0 while (my $this_precond = $precond_search->next()) {
17 0         0 my $hash = $this_precond->precondition_as_hash;
18 0         0 $hash->{id} = $this_precond->id;
19              
20 0         0 push @{$c->stash->{preconditions}}, $hash;
  0         0  
21             }
22 0         0 return;
23 10     10   46 }
  10         17  
  10         55  
24              
25              
26 10     10 0 74594 sub base : Chained PathPrefix CaptureArgs(0) { }
  10     0   16  
  10         47  
27              
28             sub id : Chained('base') PathPart('') CaptureArgs(1)
29             {
30 0     0 0 0 my ( $self, $c, $precondition_id ) = @_;
31 0         0 $c->stash(precondition => $c->model('TestrunDB')->resultset('Precondition')->find($precondition_id));
32 0 0       0 if (not $c->stash->{precondition}) {
33 0         0 $c->response->body(qq(No precondition with id "$precondition_id" found in the database!));
34 0         0 return;
35             }
36 10     10   8003 }
  10         13  
  10         38  
37              
38             sub delete : Chained('id') PathPart('delete')
39             {
40 0     0 0 0 my ( $self, $c, $force) = @_;
41             # when "done" is true, the precondition will already be deleted by the
42             # controller once we get into the template, hence the name
43 0         0 $c->stash(done => 0);
44              
45 0 0       0 return if not $force;
46              
47 0         0 my $cmd = Tapper::Cmd::Precondition->new();
48 0         0 my $retval = $cmd->del($c->stash->{precondition}->id);
49 0 0       0 if ($retval) {
50 0         0 $c->response->body(qq(Can't delete precondition: $retval));
51 0         0 return;
52             }
53 0         0 $c->stash(done => 1);
54 10     10   7497 }
  10         14  
  10         41  
55              
56              
57             sub similar : Chained('id') PathPart('similar') Args(0)
58       0 0   {
59 10     10   6818 }
  10         18  
  10         44  
60              
61              
62              
63             sub new_create : Chained('base') :PathPart('create') :Args(0) :FormConfig
64             {
65 0     0 0   my ($self, $c) = @_;
66              
67 0           my $form = $c->stash->{form};
68              
69 0 0         if ($form->submitted_and_valid) {
70 0           my $cmd = Tapper::Cmd::Precondition->new();
71 0           my $file = $form->param('precondition');
72 0           my $data = $file->slurp;
73 0           my @preconditions;
74 0           eval { @preconditions = $cmd->add($data)};
  0            
75 0 0         if($@) {
76 0           $c->stash(error => $@);
77             }
78 0           $c->stash(preconditions => \@preconditions);
79             } else {
80 0           print STDERR "created form for new precondition";
81             }
82              
83 10     10   7716 }
  10         15  
  10         41  
84              
85              
86              
87             1;
88              
89             __END__
90              
91             =pod
92              
93             =encoding UTF-8
94              
95             =head1 NAME
96              
97             Tapper::Reports::Web::Controller::Tapper::Preconditions
98              
99             =head1 DESCRIPTION
100              
101             Catalyst Controller.
102              
103             =head1 NAME
104              
105             Tapper::Reports::Web::Controller::Tapper::Preconditions - Catalyst Controller
106              
107             =head1 METHODS
108              
109             =head2 index
110              
111             =head1 AUTHOR
112              
113             Steffen Schwigon,,,
114              
115             =head1 LICENSE
116              
117             This program is released under the following license: freebsd
118              
119             =head1 AUTHORS
120              
121             =over 4
122              
123             =item *
124              
125             AMD OSRC Tapper Team <tapper@amd64.org>
126              
127             =item *
128              
129             Tapper Team <tapper-ops@amazon.com>
130              
131             =back
132              
133             =head1 COPYRIGHT AND LICENSE
134              
135             This software is Copyright (c) 2017 by Advanced Micro Devices, Inc..
136              
137             This is free software, licensed under:
138              
139             The (two-clause) FreeBSD License
140              
141             =cut