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