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   1270 use App::revealup::base;
  2         5  
  2         12  
3 2     2   506 use App::revealup::util;
  2         5  
  2         140  
4 2     2   601 use App::revealup::builder;
  2         4  
  2         50  
5 2     2   9 use Path::Tiny qw/path/;
  2         3  
  2         80  
6 2     2   9 use Term::ANSIColor;
  2         3  
  2         80  
7 2     2   10 use Pod::Usage;
  2         4  
  2         861  
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 4 my ($self, @args) = @_;
17 1         1 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         13 );
26 1         5 for my $key (keys %$opt) {
27 5         14 $self->$key( $opt->{$key} );
28             }
29              
30 1 50       4 if (path($self->output)->exists) {
31 0         0 App::revealup::util::error("@{[$self->output]} exists");
  0         0  
32             }
33              
34 1         32 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     31 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       4 die if !$html;
49 1         44 path($self->output)->spew_utf8($html);
50 1         510 App::revealup::util::info("Generated your HTML to @{[$self->output]}");
  1         5  
51 1         5 my $reveal_path = App::revealup::util::share_path([qw/share revealjs/]);
52 1         20 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         6  
54             }
55              
56             1;