File Coverage

blib/lib/App/revealup/cli/export/html.pm
Criterion Covered Total %
statement 36 39 92.3
branch 3 6 50.0
condition 5 10 50.0
subroutine 7 7 100.0
pod 0 1 0.0
total 51 63 80.9


line stmt bran cond sub pod time code
1             package App::revealup::cli::export::html;
2 2     2   916 use App::revealup::base;
  2         4  
  2         21  
3 2     2   336 use App::revealup::util;
  2         4  
  2         108  
4 2     2   343 use App::revealup::builder;
  2         4  
  2         57  
5 2     2   10 use Path::Tiny qw/path/;
  2         3  
  2         91  
6 2     2   11 use Term::ANSIColor;
  2         4  
  2         67  
7 2     2   22 use Pod::Usage;
  2         4  
  2         827  
8              
9             has 'theme';
10             has 'transition';
11             has 'width';
12             has 'height';
13             has 'output' => 'original.html';
14              
15             sub run {
16 1     1 0 5 my ($self, @args) = @_;
17 1         2 my $opt;
18             parse_options(
19             \@args,
20             'theme=s' => \$opt->{theme},
21             'transition=s' => \$opt->{transition},
22             'width=i' => \$opt->{width},
23             'height=i' => \$opt->{height},
24             'output=s' => \$opt->{output},
25 1         5 );
26 1         22 for my $key (keys %$opt) {
27 5         13 $self->$key( $opt->{$key} );
28             }
29              
30 1 50       17 if (path($self->output)->exists) {
31 0         0 App::revealup::util::error("@{[$self->output]} exists");
  0         0  
32             }
33              
34 1         33 my $filename = shift @args;
35 1 50       2 if (!path($filename)->exists) {
36 0         0 App::revealup::util::error("$filename is not exist");
37             }
38            
39 1   50     28 my $builder = App::revealup::builder->new(
      50        
      50        
      50        
      50        
40             filename => $filename || '',
41             theme => $self->theme || '',
42             transition => $self->transition || '',
43             width => $self->width || 0,
44             height => $self->height || 0,
45             );
46            
47 1         4 my $html = $builder->build_html();
48 1 50       3 die if !$html;
49 1         3 path($self->output)->spew_utf8($html);
50 1         530 App::revealup::util::info("Generated your HTML to @{[$self->output]}");
  1         4  
51 1         4 my $reveal_path = App::revealup::util::share_path([qw/share revealjs/]);
52 1         19 App::revealup::util::info("Copy command for the revealjs directory is:");
53 1         2 App::revealup::util::info("cp -r @{[$reveal_path->absolute]} ./revealjs");
  1         4  
54             }
55              
56             1;