line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Prove::Controller; |
2
|
|
|
|
|
|
|
$Mojolicious::Plugin::Prove::Controller::VERSION = '0.11'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
138832
|
use Mojo::Base 'Mojolicious::Controller'; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
6188
|
use App::Prove; |
|
8
|
|
|
|
|
155087
|
|
|
8
|
|
|
|
|
375
|
|
8
|
8
|
|
|
8
|
|
80
|
use Mojo::File qw(path); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
536
|
|
9
|
8
|
|
|
8
|
|
4655
|
use Capture::Tiny qw(capture); |
|
8
|
|
|
|
|
31594
|
|
|
8
|
|
|
|
|
8752
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub list { |
12
|
7
|
|
|
7
|
1
|
60432
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
7
|
|
|
|
|
34
|
my $conf = $self->stash->{conf}; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
81
|
my $name = $self->param( 'name' ); |
17
|
7
|
100
|
100
|
|
|
1562
|
if ( $name && !exists $conf->{$name} ) { |
18
|
2
|
|
|
|
|
16
|
$self->render( 'prove_exception' ); |
19
|
2
|
|
|
|
|
2890
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
5
|
100
|
|
|
|
20
|
if ( $name ) { |
23
|
|
|
|
|
|
|
my $files = path( $conf->{$name} ) |
24
|
|
|
|
|
|
|
->list |
25
|
2
|
|
|
2
|
|
396
|
->grep( sub { $_->extname eq 't' } ) |
26
|
2
|
|
|
2
|
|
102
|
->map( sub { $_->basename } ) |
27
|
1
|
|
|
|
|
6
|
->to_array; |
28
|
1
|
|
|
|
|
49
|
$self->stash( files => $files ); |
29
|
1
|
|
|
|
|
24
|
$self->stash( names => '' ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
4
|
|
|
|
|
18
|
$self->stash( name => '' ); |
33
|
4
|
|
|
|
|
87
|
$self->stash( names => [ keys %{$conf} ] ); |
|
4
|
|
|
|
|
19
|
|
34
|
4
|
|
|
|
|
60
|
$self->stash( files => '' ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
97
|
$self->render( 'prove_file_list' ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub file { |
41
|
5
|
|
|
5
|
1
|
88915
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
32
|
my $file = $self->param( 'file' ); |
44
|
5
|
|
|
|
|
250
|
my $name = $self->param( 'name' ); |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
141
|
$self->stash( format => 'html' ); |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
100
|
my $conf = $self->stash->{conf}; |
49
|
|
|
|
|
|
|
|
50
|
5
|
100
|
|
|
|
55
|
if ( !exists $conf->{$name} ) { |
51
|
1
|
|
|
|
|
6
|
$self->render( 'prove_exception' ); |
52
|
1
|
|
|
|
|
2653
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $found = path( $conf->{$name} ) |
56
|
|
|
|
|
|
|
->list |
57
|
8
|
50
|
|
8
|
|
1466
|
->grep( sub { $_->extname eq 't' and $file eq $_->basename } ) |
58
|
4
|
|
|
|
|
23
|
->first; |
59
|
|
|
|
|
|
|
|
60
|
4
|
100
|
|
|
|
303
|
if ( !$found ) { |
61
|
2
|
|
|
|
|
18
|
$self->render( 'prove_exception' ); |
62
|
2
|
|
|
|
|
1349
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
26
|
my $content = $found->slurp; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
238
|
$self->stash( code => $content ); |
68
|
2
|
|
|
|
|
41
|
$self->stash( file => $file ); |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
36
|
$self->render( 'prove_file' ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub run { |
74
|
8
|
|
|
8
|
1
|
72522
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
8
|
|
|
|
|
49
|
my $file = $self->param( 'file' ); |
77
|
8
|
|
|
|
|
1743
|
my $name = $self->param( 'name' ); |
78
|
|
|
|
|
|
|
|
79
|
8
|
|
|
|
|
298
|
my $conf = $self->stash->{conf}; |
80
|
|
|
|
|
|
|
|
81
|
8
|
100
|
|
|
|
93
|
if ( !exists $conf->{$name} ) { |
82
|
2
|
|
|
|
|
19
|
$self->render( 'prove_exception' ); |
83
|
2
|
|
|
|
|
7326
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $files = path( $conf->{$name} ) |
87
|
|
|
|
|
|
|
->list |
88
|
12
|
|
|
12
|
|
2451
|
->grep( sub { $_->extname eq 't' } ) |
89
|
12
|
|
|
12
|
|
534
|
->map( sub { [ $_->basename, $_->to_string ] } ) |
90
|
6
|
|
|
|
|
32
|
->to_array; |
91
|
|
|
|
|
|
|
|
92
|
6
|
|
|
|
|
293
|
my $found; |
93
|
6
|
100
|
|
|
|
28
|
if ( $file ) { |
94
|
3
|
50
|
|
|
|
8
|
($found) = grep{ $file eq $_->[0] } @{$files || []}; |
|
6
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
12
|
|
95
|
|
|
|
|
|
|
|
96
|
3
|
100
|
|
|
|
11
|
if ( !$found ) { |
97
|
1
|
|
|
|
|
6
|
$self->render( 'prove_exception' ); |
98
|
1
|
|
|
|
|
581
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
5
|
50
|
|
|
|
21
|
my @args = $found ? $found : @{ $files || [] }; |
|
3
|
100
|
|
|
|
13
|
|
103
|
5
|
|
|
|
|
13
|
@args = sort map{ $_->[1] } @args; |
|
8
|
|
|
|
|
28
|
|
104
|
|
|
|
|
|
|
|
105
|
5
|
|
|
|
|
24
|
local $ENV{HARNESS_TIMER}; |
106
|
|
|
|
|
|
|
|
107
|
5
|
|
100
|
|
|
22
|
my $accepts = $self->app->renderer->accepts( $self )->[0] // 'html'; |
108
|
5
|
100
|
|
|
|
3007
|
my $format = $accepts =~ m{\Ahtml?} ? 'html' : $accepts; |
109
|
|
|
|
|
|
|
|
110
|
5
|
|
|
|
|
65
|
my $prove = App::Prove->new; |
111
|
|
|
|
|
|
|
|
112
|
5
|
|
|
|
|
520
|
$prove->process_args( '--norc', @args ); |
113
|
5
|
100
|
|
|
|
13619
|
$prove->formatter('TAP::Formatter::HTML') if $format eq 'html'; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my ($stdout, $stderr, @result) = capture { |
116
|
5
|
|
|
5
|
|
7784
|
$prove->run; |
117
|
5
|
|
|
|
|
286
|
}; |
118
|
|
|
|
|
|
|
|
119
|
5
|
100
|
|
|
|
4006955
|
if ( $format eq 'html' ) { |
120
|
1
|
|
|
|
|
39
|
$stdout =~ s{\A.*?^(<!DOCTYPE)}{$1}xms; |
121
|
1
|
|
|
|
|
60
|
$self->render( text => $stdout ); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
else { |
124
|
4
|
|
|
|
|
174
|
$self->tx->res->headers->content_type('text/plain'); |
125
|
4
|
|
|
|
|
1126
|
$self->render( text => $stdout ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=pod |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=encoding UTF-8 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 NAME |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Mojolicious::Plugin::Prove::Controller - Controller for Mojolicious::Plugin::Prove |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 VERSION |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
version 0.11 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 METHODS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 file |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 list |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 run |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Renee Baecker <reneeb@cpan.org> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Renee Baecker. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This is free software, licensed under: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|