Skip to content

Commit 2e28037

Browse files
committed
Introduce a starting point in the main package
1 parent fdea4c7 commit 2e28037

File tree

4 files changed

+69
-10
lines changed

4 files changed

+69
-10
lines changed

README

+26-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ SYNOPSIS
77

88
app.psgi
99

10-
use Minima::Setup;
11-
\&Minima::Setup::init;
10+
use Minima;
11+
Minima::init;
1212

1313
For a "hello, world":
1414

@@ -82,6 +82,30 @@ HOW IT WORKS
8282
Content is then assigned to the response and finalized.
8383

8484

85+
GETTING STARTED
86+
87+
To begin a project, the Minima package provides a subroutine
88+
(described below) to help you get started with the process mentioned
89+
above.
90+
91+
You can also interact directly with Minima::Setup for full control
92+
over the setup process.
93+
94+
init
95+
96+
sub init ($config = undef)
97+
98+
A convenience subroutine that calls Minima::Setup::prepare to
99+
prepare the main app object and returns a reference to
100+
Minima::Setup::init.
101+
102+
The optional argument allows you to specify the location of the
103+
configuration file.
104+
105+
For a detailed explanation of behavior and options, refer to the
106+
documentation for Minima::Setup.
107+
108+
85109
EXAMPLE
86110

87111
Minima's repository contains an example application under eg/. To

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Efficient web framework build with modern core classes.
44

55
_app.psgi_
66

7-
use Minima::Setup;
8-
\&Minima::Setup::init;
7+
use Minima;
8+
Minima::init;
99

1010
For a `hello, world`:
1111

lib/Minima.pm

+38-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
use v5.40;
2+
23
package Minima v0.3.0;
4+
5+
use Minima::Setup;
6+
7+
sub init ($config = undef)
8+
{
9+
Minima::Setup::prepare($config);
10+
\&Minima::Setup::init;
11+
}
12+
313
1;
414

515
__END__
@@ -12,8 +22,8 @@ Minima - Efficient web framework built with modern core classes
1222
1323
F<app.psgi>
1424
15-
use Minima::Setup;
16-
\&Minima::Setup::init;
25+
use Minima;
26+
Minima::init;
1727
1828
For a "hello, world":
1929
@@ -69,7 +79,7 @@ A typical web application using Minima operates as follows:
6979
=item 1.
7080
7181
L<Minima::Setup> is loaded. It will read a configuration file (if any,
72-
see L<"Config File in Minima::Setup"|Minima::Setup/"CONFIG FILE">) and
82+
see L<"Config File" in Minima::Setup|Minima::Setup/"CONFIG FILE">) and
7383
provides a C<init> subroutine that is passed to Plack as the entry point
7484
for receiving requests.
7585
@@ -80,12 +90,12 @@ configuration.
8090
8191
=item 3.
8292
83-
Minima::App passes a routes file (where all application routes are
93+
L<Minima::App> passes a routes file (where all application routes are
8494
defined) to L<Minima::Router> to be read and parsed.
8595
8696
=item 4.
8797
88-
The request URL is matched to a route. Minima::App then calls the
98+
The request URL is matched to a route. L<Minima::App> then calls the
8999
appropriate controller and method, setting them up and passing along the
90100
relevant information such as request and route data.
91101
@@ -97,6 +107,29 @@ assigned to the response and finalized.
97107
98108
=back
99109
110+
=head1 GETTING STARTED
111+
112+
To begin a project, the Minima package provides a subroutine (described
113+
below) to help you get started with the process mentioned above.
114+
115+
You can also interact directly with L<Minima::Setup> for full control
116+
over the setup process.
117+
118+
=head2 init
119+
120+
sub init ($config = undef)
121+
122+
A convenience subroutine that calls
123+
L<C<Minima::Setup::prepare>|Minima::Setup/prepare> to prepare the main
124+
app object and returns a reference to
125+
L<C<Minima::Setup::init>|Minima::Setup/init>.
126+
127+
The optional argument allows you to specify the location of the
128+
configuration file.
129+
130+
For a detailed explanation of behavior and options, refer to the
131+
documentation for L<Minima::Setup>.
132+
100133
=head1 EXAMPLE
101134
102135
Minima's repository contains an example application under F<eg/>. To run

t/50-live.t

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use v5.40;
22
use Test2::V0;
33
use HTTP::Request::Common;
44

5+
use Minima;
56
use Minima::Setup;
7+
use Plack::Test;
68

79
my $test = Minima::Setup::test;
810

@@ -20,7 +22,7 @@ ok( length($res->content), 'respects config for auto HEAD' );
2022
# Move to the complex example in eg/
2123
{
2224
chdir 'eg';
23-
$Minima::Setup::app->_read_config; # refresh config in new dir
25+
$test = Plack::Test->create(Minima::init);
2426

2527
local @INC = ( 'lib', @INC );
2628
local %ENV = %ENV;

0 commit comments

Comments
 (0)