File Coverage

blib/lib/App/revealup/cli/export/theme.pm
Criterion Covered Total %
statement 30 32 93.7
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 39 45 86.6


line stmt bran cond sub pod time code
1             package App::revealup::cli::export::theme;
2 2     2   814 use App::revealup::base;
  2         4  
  2         27  
3 2     2   331 use App::revealup::util;
  2         3  
  2         133  
4 2     2   12 use Path::Tiny qw/path/;
  2         3  
  2         89  
5 2     2   42 use Getopt::Long qw/GetOptionsFromArray/;
  2         5  
  2         11  
6 2     2   251 use Term::ANSIColor;
  2         3  
  2         942  
7              
8             has 'base' => 'black';
9             has 'output' => 'original.css';
10              
11             sub run {
12 2     2 0 4 my ($self, @args) = @_;
13 2         2 my $opt;
14             my $result = parse_options(
15             \@args,
16             'output=s' => \$opt->{output},
17             'base=s' => \$opt->{base},
18 2         7 );
19              
20 2         7 for my $key (keys %$opt) {
21 4         14 $self->$key( $opt->{$key} );
22             }
23              
24 2         5 my $filepath = path('.', $self->output);
25 2 50       80 if ($filepath->exists) {
26 0         0 App::revealup::util::error("$filepath exists");
27             }
28              
29 2 50       34 my $base = $self->base !~ m!\.css$! ? $self->base . '.css' : $self->base;
30 2         6 my $reveal_theme_path = App::revealup::util::share_path([qw/share revealjs dist theme/]);
31 2         42 my $base_path = $reveal_theme_path->child($base);
32              
33 2 50       60 if (!$base_path->exists) {
34 0         0 App::revealup::util::error("base theme '$base' does not exist");
35             }
36              
37 2         31 my $content = $base_path->slurp();
38 2         378 $filepath->spew_utf8($content);
39 2         1628 App::revealup::util::info("Generated your CSS to @{[$self->output]}");
  2         7  
40             }
41              
42             1;