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