File Coverage

blib/lib/Mojolicious/Command/Author/generate/localplugin.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Mojolicious::Command::Author::generate::localplugin;
2 2     2   1139 use Mojo::Base 'Mojolicious::Command';
  2         6  
  2         14  
3              
4 2     2   41947 use Mojo::Util qw(camelize class_to_path decamelize);
  2         7  
  2         139  
5 2     2   1194 use Mojolicious;
  2         517630  
  2         25  
6              
7             our $VERSION = 0.04;
8              
9             has description => 'Generate Mojolicious plugin directory structure for application';
10             has usage => sub { shift->extract_usage };
11              
12             sub run {
13 2     2 1 49585 my ($self, $name) = @_;
14 2   100     16 $name ||= 'MyPlugin';
15              
16             # Class
17 2 100       16 my $class = $name =~ /^[a-z]/ ? camelize $name : $name;
18 2         31 my $app = class_to_path $class;
19 2         25 my @app_params = ({ class => $class, name => $name });
20 2         29 $self->render_to_rel_file('class', "lib/$app", @app_params);
21              
22             # Test
23 2         11548 my $testname = decamelize $class;
24 2         71 my @test_params = ({ name => $name });
25 2         11 $self->render_to_rel_file('test', "t/$testname.t", @test_params);
26             }
27              
28              
29             1;
30              
31             =pod
32              
33             =encoding UTF-8
34              
35             =head1 NAME
36              
37             Mojolicious::Command::Author::generate::localplugin
38              
39             =head1 VERSION
40              
41             version 0.04
42              
43             =head1 SYNOPSIS
44              
45             Usage: APPLICATION generate localplugin [OPTIONS] [NAME]
46              
47             mojo generate localplugin
48             mojo generate localplugin TestPlugin
49              
50             Options:
51             -h, --help Show this summary of available options
52              
53             =head1 DESCRIPTION
54              
55             L generates directory structures for
56             fully functional L plugins.
57              
58             See L for a list of commands that are
59             available by default.
60              
61             =head1 NAME
62              
63             Mojolicious::Command::generate::localplugin - Plugin generator command
64              
65             =head1 ATTRIBUTES
66              
67             L inherits all attributes from
68             L and implements the following new ones.
69              
70             =head2 description
71              
72             my $description = $plugin->description;
73             $plugin = $plugin->description('Foo');
74              
75             Short description of this command, used for the command list.
76              
77             =head2 usage
78              
79             my $usage = $plugin->usage;
80             $plugin = $plugin->usage('Foo');
81              
82             Usage information for this command, used for the help screen.
83              
84             =head1 METHODS
85              
86             L inherits all methods from
87             L and implements the following new ones.
88              
89             =head2 run
90              
91             $plugin->run(@ARGV);
92              
93             Run this command.
94              
95             =head1 SEE ALSO
96              
97             L, L, L.
98              
99             =head1 AUTHOR
100              
101             Renee Baecker
102              
103             =head1 COPYRIGHT AND LICENSE
104              
105             This software is copyright (c) 2018 by Renee Baecker.
106              
107             This is free software; you can redistribute it and/or modify it under
108             the same terms as the Perl 5 programming language system itself.
109              
110             =cut
111              
112             __DATA__