File Coverage

lib/Mojolicious/Command/generate/js_url_for.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 16 17 94.1


line stmt bran cond sub pod time code
1             package Mojolicious::Command::generate::js_url_for;
2 1     1   944 use Mojo::Base 'Mojolicious::Command';
  1         1  
  1         5  
3 1     1   122 use Mojo::Home;
  1         3  
  1         8  
4              
5             has description => <<'EOF';
6             Generate "url_for" function for javasctipt (perldoc Mojolicious::Plugin::JSUrlFor)
7             EOF
8              
9             has usage => <<"EOF";
10             usage: $0 generate js_url_for \$file
11              
12             \$file - file for saving javascript code
13             For example, you can save it to public/static/url_for.js
14              
15             EOF
16              
17             sub run {
18 2     2 0 6177 my ( $self, $filename ) = @_;
19 2 100       32 die $self->usage unless $filename;
20              
21 1         26 $self->app->plugin('Mojolicious::Plugin::JSUrlFor');
22 1         411 my $js = $self->app->_js_url_for_code_only;
23              
24 1         15 $self->write_rel_file( $filename, $js );
25             }
26              
27             1;