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   769 use Mojo::Base 'Mojolicious::Plugin';
  1         3  
  1         7  
4              
5 1     1   222 use 5.12.0;
  1         14  
6              
7             our $VERSION = '0.20';
8             $VERSION = eval $VERSION;
9              
10 1     1   6 use Mojo::Home;
  1         2  
  1         46  
11 1     1   7 use Mojo::ByteStream 'b';
  1         2  
  1         64  
12 1     1   9 use Mojo::File;
  1         2  
  1         39  
13              
14 1     1   6 use File::Basename 'dirname';
  1         2  
  1         74  
15 1     1   562 use File::Share ();
  1         26083  
  1         1337  
16              
17             has home => sub { Mojo::Home->new(File::Share::dist_dir('Mojolicious-Plugin-RevealJS')) };
18              
19             sub register {
20 1     1 1 112 my ($plugin, $app, $conf) = @_;
21 1         4 my $home = $plugin->home;
22 1         323 push @{ $app->static->paths }, $home->child('public');
  1         15  
23 1         86 push @{ $app->renderer->paths }, $home->child('templates');
  1         6  
24              
25 1         45 $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         34 $app->helper('revealjs.export' => \&_export);
34              
35 1         453 $app->helper(include_code => \&_include_code);
36 1         94 $app->helper(include_sample => \&_include_sample);
37 1     3   87 $app->helper(section => sub { shift->tag(section => @_) });
  3         150214  
38             $app->helper(markdown_section => sub {
39 3     3   178 my ($c, @args) = @_;
40             return $c->tag(section => data => { markdown => undef } => sub {
41 3         79 return $c->tag(script => (type => 'text/template') => @args);
42 3         35 });
43 1         87 });
44             }
45              
46             sub _include_code {
47 15     15   1188 my ($c, $filename, %opts) = @_;
48 15   66     75 my $file = $c->stash->{'revealjs.private.files'}{$filename}
49             ||= $c->app->home->rel_file($filename)->slurp;
50 15         1782 my $mark = qr'^\h*(?:#+|-{2,}|/{2,}| or C<<