File Coverage

blib/lib/Amon2/Setup/Flavor/Basic.pm
Criterion Covered Total %
statement 12 58 20.6
branch n/a
condition n/a
subroutine 4 7 57.1
pod 0 3 0.0
total 16 68 23.5


line stmt bran cond sub pod time code
1 1     1   515 use strict;
  1         3  
  1         37  
2 1     1   5 use warnings FATAL => 'all';
  1         3  
  1         42  
3 1     1   5 use utf8;
  1         3  
  1         8  
4              
5             use parent qw(Amon2::Setup::Flavor);
6 1     1   36  
  1         2  
  1         6  
7             our $VERSION = '6.16';
8              
9             my $self = shift;
10              
11 0     0 0   # write code.
12             $self->render_file( "tmpl/index.tx", "Basic/tmpl/index.tx" );
13             $self->render_file( "tmpl/include/layout.tx", "Basic/tmpl/include/layout.tx" );
14 0           $self->render_file( "tmpl/include/pager.tx", "Basic/tmpl/include/pager.tx" );
15 0            
16 0           $self->render_file( 'lib/<<PATH>>.pm', 'Basic/lib/__PATH__.pm' );
17             $self->render_file( 'lib/<<PATH>>/Web.pm', 'Basic/lib/__PATH__/Web.pm' );
18 0           $self->render_file( 'lib/<<PATH>>/Web/Plugin/Session.pm','Basic/lib/__PATH__/Web/Plugin/Session.pm' );
19 0           $self->render_file( 'lib/<<PATH>>/Web/Dispatcher.pm', 'Basic/lib/__PATH__/Web/Dispatcher.pm' );
20 0           $self->render_file( 'lib/<<PATH>>/Web/View.pm', 'Minimum/lib/__PATH__/Web/View.pm' );
21 0           $self->render_file( 'lib/<<PATH>>/Web/ViewFunctions.pm', 'Minimum/lib/__PATH__/Web/ViewFunctions.pm' );
22 0           $self->render_file( 'lib/<<PATH>>/DB.pm', 'Basic/lib/__PATH__/DB.pm' );
23 0           $self->render_file( 'lib/<<PATH>>/DB/Schema.pm', 'Basic/lib/__PATH__/DB/Schema.pm' );
24 0           $self->render_file( 'lib/<<PATH>>/DB/Row.pm', 'Basic/lib/__PATH__/DB/Row.pm' );
25 0            
26 0           $self->render_file( $self->psgi_file, 'Basic/script/server.pl' );
27             $self->render_file( 'Build.PL', 'Minimum/Build.PL' );
28 0           $self->render_file( 'minil.toml', 'Minimum/minil.toml' );
29 0           $self->render_file( 'builder/MyBuilder.pm', 'Minimum/builder/MyBuilder.pm' );
30 0            
31 0            
32             $self->create_cpanfile({
33             'HTML::FillInForm::Lite' => '1.11',
34 0           'Time::Piece' => '1.20',
35             'Plack::Middleware::ReverseProxy' => '0.09',
36             'JSON' => '2.50',
37             'Teng' => '0.18',
38             'DBD::SQLite' => '1.33',
39             'Test::WWW::Mechanize::PSGI' => 0,
40             'Router::Boom' => '0.06',
41             'HTTP::Session2' => '1.03',
42             'Crypt::CBC' => '0',
43             'Crypt::Rijndael' => '0',
44             });
45              
46             # static files
47             $self->write_assets();
48              
49 0           $self->write_file("static/img/.gitignore", '');
50             $self->write_file("static/robots.txt", '');
51 0            
52 0           $self->render_file("static/js/main.js", "Basic/static/js/main.js");
53             $self->render_file("static/css/main.css", "Basic/static/css/main.css");
54 0            
55 0           $self->render_file('db/.gitignore', 'Basic/db/dot.gitignore');
56              
57 0           # configuration files
58             for my $env (qw(development production test)) {
59             $self->render_file( "config/${env}.pl", 'Basic/config/__ENV__.pl', { env => $env } );
60 0           }
61 0            
62             $self->render_file( 'sql/mysql.sql', 'Basic/sql/mysql.sql' );
63             $self->render_file( 'sql/sqlite.sql', 'Basic/sql/sqlite.sql' );
64 0            
65 0           $self->render_file( 't/Util.pm', 'Basic/t/Util.pm' );
66             $self->render_file( 't/00_compile.t', 'Basic/t/00_compile.t' );
67 0           $self->render_file( 't/01_root.t', 'Minimum/t/01_root.t', {
68 0           psgi_file => $self->psgi_file,
69 0           });
70             $self->render_file( 't/02_mech.t', 'Minimum/t/02_mech.t', {
71             psgi_file => $self->psgi_file,
72 0           });
73             $self->render_file( 't/03_assets.t', 'Basic/t/03_assets.t', {
74             psgi_file => $self->psgi_file,
75 0           });
76             $self->render_file( 't/06_jshint.t', 'Basic/t/06_jshint.t' );
77             $self->render_file( 'xt/01_pod.t', 'Minimum/xt/01_pod.t' );
78 0           $self->render_file( 'xt/02_perlcritic.t', 'Basic/xt/02_perlcritic.t' );
79 0            
80 0           $self->render_file('.gitignore', 'Basic/dot.gitignore');
81             $self->render_file('.proverc', 'Basic/dot.proverc');
82 0            
83 0           {
84             my %status = (
85             '503' => 'Service Unavailable',
86 0           '502' => 'Bad Gateway',
  0            
87             '500' => 'Internal Server Error',
88             '504' => 'Gateway Timeout',
89             '404' => 'Not Found'
90             );
91             while (my ($status, $status_message) = each %status) {
92             $self->render_file(
93 0           "static/$status.html",
94 0           "Basic/static/__STATUS__.html",
95             { status => $status, status_message => $status_message }
96             );
97             }
98             }
99             }
100              
101             my $self = shift;
102             'script/' . lc($self->{dist}) . '-server';
103             }
104 0     0 0    
105 0           my $self = shift;
106              
107             printf <<'...', $self->psgi_file;
108             --------------------------------------------------------------
109 0     0 0    
110             Setup script was done! You are ready to run the skelton.
111 0            
112             You need to install the dependencies by:
113              
114             > carton install
115              
116             And then, run your application server:
117              
118             > carton exec perl -Ilib %s
119              
120             --------------------------------------------------------------
121             ...
122             }
123              
124             1;
125              
126             =head1 NAME
127              
128             Amon2::Setup::Flavor::Basic - Basic flavor selected by default
129              
130             =head1 SYNOPSIS
131              
132             % amon2-setup.pl --flavor=Basic MyApp
133              
134             =head1 DESCRIPTION
135              
136             This is a basic flavor for Amon2. This is the default flavor.
137              
138             =head1 AUTHOR
139              
140             Tokuhiro Matsuno