Mojolicious/Command/Author/generate/app.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 94.1% 32 / 34 CC 2 SCAR 3.4
CC
2
Cov
96%
run
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Mojolicious/Command/cgi.pm ↑ Summary Mojolicious/Command/Author/generate/dockerfile.pm »
1 package Mojolicious::Command::Author::generate::app;
2 1 ▶use Mojo::Base 'Mojolicious::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use Mojo::Util qw(class_to_file class_to_path decamelize);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 has description => 'Generate Mojolicious application directory structure';
7 2 ▶has usage => sub { shift->extract_usage };
Subroutine __ANON__: called CC=1 SCAR=0.0
8  
9 1 ▶sub run {
Subroutine run: called CC=2 SCAR=6.9
Pod documented
10 1 ▶ my ($self, $class) = (shift, shift || 'MyApp');
Condition50%1/2
shift() || 'MyApp'
l!l
01
MC/DC0%0/1
shift() || 'MyApp'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11  
12 # Script
13 1 my $name = class_to_file $class;
14 1 $self->render_to_rel_file('mojo', "$name/script/$name", {class => $class});
15 1 $self->chmod_rel_file("$name/script/$name", 0744);
16  
17 # Application class
18 1 my $app = class_to_path $class;
19 1 $self->render_to_rel_file('appclass', "$name/lib/$app", {class => $class});
20  
21 # Config file (using the default moniker)
22 1 $self->render_to_rel_file('config', "$name/@{[decamelize $class]}.yml");
23  
24 # Controller
25 1 my $controller = "${class}::Controller::Example";
26 1 my $path = class_to_path $controller;
27 1 $self->render_to_rel_file('controller', "$name/lib/$path", {class => $controller});
28  
29 # Test
30 1 $self->render_to_rel_file('test', "$name/t/basic.t", {class => $class});
31  
32 # Static file
33 1 $self->render_to_rel_file('static', "$name/public/index.html");
34 1 $self->create_dir("$name/public/assets");
35  
36 # Templates
37 1 $self->render_to_rel_file('layout', "$name/templates/layouts/default.html.ep");
38 1 $self->render_to_rel_file('welcome', "$name/templates/example/welcome.html.ep");
39 }
40  
41 1 1;
42  
43 =encoding utf8
44  
45 =head1 NAME
46  
47 Mojolicious::Command::Author::generate::app - App generator command
48  
49 =head1 SYNOPSIS
50  
51 Usage: APPLICATION generate app [OPTIONS] [NAME]
52  
53 mojo generate app
54 mojo generate app TestApp
55 mojo generate app My::TestApp
56  
57 Options:
58 -h, --help Show this summary of available options
59  
60 =head1 DESCRIPTION
61  
62 L<Mojolicious::Command::Author::generate::app> generates application directory structures for fully functional
63 L<Mojolicious> applications.
64  
65 This is a core command, that means it is always enabled and its code a good example for learning to build new commands,
66 you're welcome to fork it.
67  
68 See L<Mojolicious::Commands/"COMMANDS"> for a list of commands that are available by default.
69  
70 =head1 ATTRIBUTES
71  
72 L<Mojolicious::Command::Author::generate::app> inherits all attributes from L<Mojolicious::Command> and implements the
73 following new ones.
74  
75 =head2 description
76  
77 my $description = $app->description;
78 $app = $app->description('Foo');
79  
80 Short description of this command, used for the command list.
81  
82 =head2 usage
83  
84 my $usage = $app->usage;
85 $app = $app->usage('Foo');
86  
87 Usage information for this command, used for the help screen.
88  
89 =head1 METHODS
90  
91 L<Mojolicious::Command::Author::generate::app> inherits all methods from L<Mojolicious::Command> and implements the
92 following new ones.
93  
94 =head2 run
95  
96 $app->run(@ARGV);
97  
98 Run this command.
99  
100 =head1 SEE ALSO
101  
102 L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
103  
104 =cut
105  
106 __DATA__
« Mojolicious/Command/cgi.pm ↑ Summary Mojolicious/Command/Author/generate/dockerfile.pm »