| 1 | package App::Prove::Plugin::HTML; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | App::Prove::Plugin::HTML - a prove plugin for HTML output | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | # command-line usage: | ||||||||||
| 10 | prove -m -P HTML=outfile:out.html,css_uri:style.css,js_uri:foo.js,force_inline_css:0 | ||||||||||
| 11 | |||||||||||
| 12 | # NOTE: this is currently in alpha, this usage will likely change! | ||||||||||
| 13 | |||||||||||
| 14 | =cut | ||||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | use TAP::Formatter::HTML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | our $VERSION = '0.13'; | |||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub import { | ||||||||
|
Subroutine
import: not called CC=1 SCAR=6.9
| |||||||||||
| 24 | 0 | my ($class, @args) = @_; | |||||||||
| 25 | # deprecated, do nothing | ||||||||||
| 26 | 0 | return $class; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 1 | ▶ | sub load { | ||||||||
|
Subroutine
load: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||
| 30 | 1 | my ($class, $p) = @_; | |||||||||
| 31 | 1 | my @args = @{ $p->{args} }; | |||||||||
| 32 | 1 | my $app = $p->{app_prove}; | |||||||||
| 33 | |||||||||||
| 34 | # parse the args | ||||||||||
| 35 | 1 | my %TFH_args; | |||||||||
| 36 | 1 | foreach my $arg (@args) { | |||||||||
| 37 | 7 | my ($key, $val) = split(/:/, $arg, 2); | |||||||||
| 38 | 7 | ▶ | if (grep {$key eq $_} qw(css_uri js_uri)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 4 | push @{ $TFH_args{$key . 's'}}, $val; | |||||||||
| 40 | } else { | ||||||||||
| 41 | 3 | $TFH_args{$key} = $val; | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | # set the formatter to use | ||||||||||
| 46 | 1 | $app->formatter( 'TAP::Formatter::HTML' ); | |||||||||
| 47 | |||||||||||
| 48 | # set ENV vars in order to pass args to TAP::Formatter::HTML | ||||||||||
| 49 | # horrible, but it's currently the only way :-/ | ||||||||||
| 50 | 1 | ▶ | while (my ($key, $val) = each %TFH_args) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 5 | ▶ | $val = join( ':', @$val ) if (ref($val) eq 'ARRAY'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 5 | $ENV{"TAP_FORMATTER_HTML_".uc($key)} = $val; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | # we're done | ||||||||||
| 56 | 1 | return $class; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | 1 | 1; | |||||||||
| 61 | |||||||||||
| 62 | __END__ | ||||||||||