« blib/lib/Tapper/Reports/Web/Controller/Tapper.pm
↑ Summary
blib/lib/Tapper/Reports/Web/Controller/Tapper/Testruns/Id.pm »
| 1 | package Tapper::Reports::Web::Controller::Tapper::Preconditions; | ||||||||||
| 2 | 13 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||
| 3 | 13 | $Tapper::Reports::Web::Controller::Tapper::Preconditions::VERSION = '5.0.17'; | |||||||||
| 4 | 13 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 13 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 13 | ▶ | use parent 'Tapper::Reports::Web::Controller::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 13 | ▶ | use Tapper::Cmd::Precondition; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 13 | ▶ | use Tapper::Model 'model'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub index :Path :Args(0) | ||||||||
|
Subroutine
index: not called CC=2 SCAR=17.9
| |||||||||||
| 12 | { | ||||||||||
| 13 | 0 | my ( $self, $c ) = @_; | |||||||||
| 14 | |||||||||||
| 15 | 0 | my $precond_search = $c->model('TestrunDB')->resultset('Precondition'); | |||||||||
| 16 | 0 | ▶ | while (my $this_precond = $precond_search->next()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | my $hash = $this_precond->precondition_as_hash; | |||||||||
| 18 | 0 | $hash->{id} = $this_precond->id; | |||||||||
| 19 | |||||||||||
| 20 | 0 | push @{$c->stash->{preconditions}}, $hash; | |||||||||
| 21 | } | ||||||||||
| 22 | 0 | return; | |||||||||
| 23 | 13 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 13 | ▶ | sub base : Chained PathPrefix CaptureArgs(0) { } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
base: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub id : Chained('base') PathPart('') CaptureArgs(1) | ||||||||
|
Subroutine
id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 29 | { | ||||||||||
| 30 | 0 | my ( $self, $c, $precondition_id ) = @_; | |||||||||
| 31 | 0 | $c->stash(precondition => $c->model('TestrunDB')->resultset('Precondition')->find($precondition_id)); | |||||||||
| 32 | 0 | ▶ | if (not $c->stash->{precondition}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | $c->response->body(qq(No precondition with id "$precondition_id" found in the database!)); | |||||||||
| 34 | 0 | return; | |||||||||
| 35 | } | ||||||||||
| 36 | 13 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub delete : Chained('id') PathPart('delete') | ||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 39 | { | ||||||||||
| 40 | 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 | $c->stash(done => 0); | |||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | return if not $force; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | |||||||||||
| 47 | 0 | my $cmd = Tapper::Cmd::Precondition->new(); | |||||||||
| 48 | 0 | my $retval = $cmd->del($c->stash->{precondition}->id); | |||||||||
| 49 | 0 | ▶ | if ($retval) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | $c->response->body(qq(Can't delete precondition: $retval)); | |||||||||
| 51 | 0 | return; | |||||||||
| 52 | } | ||||||||||
| 53 | 0 | $c->stash(done => 1); | |||||||||
| 54 | 13 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub similar : Chained('id') PathPart('similar') Args(0) | ||||||||
|
Subroutine
similar: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 58 | { | ||||||||||
| 59 | 13 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 60 | |||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub new_create : Chained('base') :PathPart('create') :Args(0) :FormConfig | ||||||||
|
Subroutine
new_create: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 64 | { | ||||||||||
| 65 | 0 | my ($self, $c) = @_; | |||||||||
| 66 | |||||||||||
| 67 | 0 | my $form = $c->stash->{form}; | |||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | if ($form->submitted_and_valid) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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)}; | |||||||||
| 75 | 0 | ▶ | if($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 13 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | |||||||||||
| 87 | 13 | 1; | |||||||||
| 88 | |||||||||||
| 89 | __END__ | ||||||||||