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   1023 use Mojo::Base 'Mojolicious::Command';
  1         1  
  1         5  
3 1     1   127 use Mojo::Home;
  1         1  
  1         9  
4              
5             our $VERSION = '0.16';
6              
7             has description => <<'EOF';
8             Generate "url_for" function for javasctipt (perldoc Mojolicious::Plugin::JSUrlFor)
9             EOF
10              
11             has usage => <<"EOF";
12             usage: $0 generate js_url_for \$file
13              
14             \$file - file for saving javascript code
15             For example, you can save it to public/static/url_for.js
16              
17             EOF
18              
19             sub run {
20 2     2 0 5009 my ( $self, $filename ) = @_;
21 2 100       34 die $self->usage unless $filename;
22              
23 1         26 $self->app->plugin('Mojolicious::Plugin::JSUrlFor');
24 1         263 my $js = $self->app->_js_url_for_code_only;
25              
26 1         17 $self->write_rel_file( $filename, $js );
27             }
28              
29             1;