File Coverage

blib/lib/Mojolicious/Plugin/RevealJS.pm
Criterion Covered Total %
statement 62 82 75.6
branch 16 22 72.7
condition 10 17 58.8
subroutine 12 13 92.3
pod 1 1 100.0
total 101 135 74.8


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::RevealJS;
2              
3 1     1   761 use Mojo::Base 'Mojolicious::Plugin';
  1         3  
  1         8  
4              
5 1     1   214 use 5.12.0;
  1         15  
6              
7             our $VERSION = '0.19';
8             $VERSION = eval $VERSION;
9              
10 1     1   7 use Mojo::Home;
  1         2  
  1         45  
11 1     1   5 use Mojo::ByteStream 'b';
  1         2  
  1         59  
12 1     1   7 use Mojo::File;
  1         2  
  1         36  
13              
14 1     1   6 use File::Basename 'dirname';
  1         2  
  1         54  
15 1     1   527 use File::Share ();
  1         25293  
  1         1295  
16              
17             has home => sub { Mojo::Home->new(File::Share::dist_dir('Mojolicious-Plugin-RevealJS')) };
18              
19             sub register {
20 1     1 1 51 my ($plugin, $app, $conf) = @_;
21 1         5 my $home = $plugin->home;
22 1         288 push @{ $app->static->paths }, $home->child('public');
  1         7  
23 1         83 push @{ $app->renderer->paths }, $home->child('templates');
  1         7  
24              
25 1         42 $app->defaults('revealjs.init' => {
26             controls => \1,
27             progress => \1,
28             history => \1,
29             center => \1,
30             transition => 'slide', #none/fade/slide/convex/concave/zoom
31             });
32              
33 1         32 $app->helper('revealjs.export' => \&_export);
34              
35 1         442 $app->helper(include_code => \&_include_code);
36 1         92 $app->helper(include_sample => \&_include_sample);
37 1     3   83 $app->helper(section => sub { shift->tag(section => @_) });
  3         152115  
38             $app->helper(markdown_section => sub {
39 3     3   182 my ($c, @args) = @_;
40             return $c->tag(section => data => { markdown => undef } => sub {
41 3         77 return $c->tag(script => (type => 'text/template') => @args);
42 3         44 });
43 1         83 });
44             }
45              
46             sub _include_code {
47 15     15   1238 my ($c, $filename, %opts) = @_;
48 15   66     48 my $file = $c->stash->{'revealjs.private.files'}{$filename}
49             ||= $c->app->home->rel_file($filename)->slurp;
50 15         1788 my $mark = qr'^\h*(?:#+|-{2,}|/{2,}| or C<<