File Coverage

blib/lib/CGI/Snapp/Demo/One.pm
Criterion Covered Total %
statement 9 21 42.8
branch n/a
condition n/a
subroutine 3 7 42.8
pod 1 4 25.0
total 13 32 40.6


line stmt bran cond sub pod time code
1             package CGI::Snapp::Demo::One;
2              
3 1     1   20165 use parent 'CGI::Snapp';
  1         325  
  1         5  
4 1     1   69233 use strict;
  1         3  
  1         30  
5 1     1   4 use warnings;
  1         7  
  1         197  
6              
7             our $VERSION = '1.02';
8              
9             # ------------------------------------------------
10              
11             sub build_head
12             {
13 0     0 0   my($self) = @_;
14 0           my $localtime = localtime();
15 0           my($package) = __PACKAGE__;
16              
17 0           return "$packageThis module is: $package.
The time is: $localtime.
";
18              
19             } # End of build_head.
20              
21             # ------------------------------------------------
22              
23             sub build_tail
24             {
25 0     0 0   my($self) = @_;
26              
27 0           return '';
28              
29             } # End of build_tail.
30              
31             # ------------------------------------------------
32              
33             sub first_rm_method
34             {
35 0     0 0   my($self) = @_;
36 0           my($package) = __PACKAGE__;
37              
38 0           return $self -> build_head . $self -> build_tail;
39              
40             } # End of first_rm_method.
41              
42             # ------------------------------------------------
43              
44             sub setup
45             {
46 0     0 1   my($self) = @_;
47              
48 0           $self -> start_mode('first_rm');
49 0           $self -> run_modes(first_rm => 'first_rm_method');
50              
51             } # End of setup.
52              
53             # ------------------------------------------------
54              
55             1;
56              
57             =pod
58              
59             =head1 NAME
60              
61             CGI::Snapp::Demo::One - A template-free demo of CGI::Snapp using just 1 run mode
62              
63             =head1 Synopsis
64              
65             After installing the module, do one or both of:
66              
67             =over 4
68              
69             =item o Use the L script
70              
71             Unpack the distro and copy http/cgi-bin/cgi.snapp.one.cgi to your web server's cgi-bin/ directory, and make it executable.
72              
73             Then browse to http://127.0.0.1/cgi-bin/cgi.snapp.one.cgi.
74              
75             =item o Use the L script
76              
77             Note: In order to not require users to install L or L, they have been commented out in Build.PL and Makefile.PL.
78              
79             Edit httpd/cgi-bin/cgi.snapp.one.psgi and change my value for the web server's doc root from /dev/shm/html to match your set up.
80              
81             /dev/shm/ is a directory provided by L which is actually a RAM disk, and within that my doc root is the sub-directory /dev/shm/html/.
82              
83             Then, install L and/or L and then do one or both of:
84              
85             =over 4
86              
87             =item o Use L
88              
89             Start starman with: starman -l 127.0.0.1:5171 --workers 1 httpd/cgi-bin/cgi.snapp.one.psgi &
90              
91             =item o Use L
92              
93             Start plackup with: plackup -l 127.0.0.1:5171 httpd/cgi-bin/cgi.snapp.one.psgi &
94              
95             =back
96              
97             Then, with either starman or plackup, direct your browser to hit 127.0.0.1:5171/.
98              
99             These commands are copied from comments within httpd/cgi-bin/cgi.snapp.one.psgi. The value 5171 is of course just a suggestion. All demos in this series use port 5171 and up.
100              
101             =back
102              
103             =head1 Description
104              
105             Shows how to write a minimal CGI script using L, with 1 run mode.
106              
107             =head1 Distributions
108              
109             This module is available as a Unix-style distro (*.tgz).
110              
111             See L
112             for help on unpacking and installing distros.
113              
114             =head1 Installation
115              
116             Install L as you would for any C module:
117              
118             Run:
119              
120             cpanm CGI::Snapp::Demo::One
121              
122             or run:
123              
124             sudo cpan CGI::Snapp::Demo::One
125              
126             or unpack the distro, and then either:
127              
128             perl Build.PL
129             ./Build
130             ./Build test
131             sudo ./Build install
132              
133             or:
134              
135             perl Makefile.PL
136             make (or dmake or nmake)
137             make test
138             make install
139              
140             =head1 Constructor and Initialization
141              
142             C is called as C<< my($app) = CGI::Snapp::Demo::One -> new(k1 => v1, k2 => v2, ...) >>.
143              
144             It returns a new object of type C.
145              
146             See http/cgi-bin/cgi.snapp.one.cgi.
147              
148             =head1 Methods
149              
150             =head2 run()
151              
152             Runs the code which responds to HTTP requests.
153              
154             See http/cgi-bin/cgi.snapp.one.cgi.
155              
156             =head1 Troubleshooting
157              
158             =head2 It doesn't work!
159              
160             Hmmm. Things to consider:
161              
162             =over 4
163              
164             =item o Run the *.cgi script from the command line
165              
166             shell> perl httpd/cgi-bin/cgi.snapp.one.cgi
167              
168             If that doesn't work, you're in b-i-g trouble. Keep reading for suggestions as to what to do next.
169              
170             =item o The system Perl 'v' perlbrew
171              
172             Are you using perlbrew? If so, recall that your web server will use the first line of http/cgi-bin/cgi.snapp.one.cgi to find a Perl, and that line says #!/usr/bin/env perl.
173              
174             So, you'd better turn perlbrew off and install L and this module under the system Perl, before trying again.
175              
176             =item o Generic advice
177              
178             L.
179              
180             =back
181              
182             =head1 See Also
183              
184             L
185              
186             The following are all part of this set of distros:
187              
188             L - A almost back-compat fork of CGI::Application
189              
190             L - A template-free demo of CGI::Snapp using just 1 run mode
191              
192             L - A template-free demo of CGI::Snapp using N run modes
193              
194             L - A template-free demo of CGI::Snapp using the forward() method.
195              
196             L - A template-free demo of CGI::Snapp using Log::Handler::Plugin::DBI
197              
198             L - A wrapper around CGI::Snapp::Demo::Four, to simplify using Log::Handler::Plugin::DBI
199              
200             L - A plugin which uses Config::Tiny
201              
202             L - A plugin which uses Config::Tiny with 1 of N sections
203              
204             L - Persistent session data management
205              
206             L - A plugin for Log::Handler using Log::Hander::Output::DBI
207              
208             L - A helper for Log::Hander::Output::DBI to create your 'log' table
209              
210             =head1 Machine-Readable Change Log
211              
212             The file CHANGES was converted into Changelog.ini by L.
213              
214             =head1 Version Numbers
215              
216             Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
217              
218             =head1 Support
219              
220             Email the author, or log a bug on RT:
221              
222             L.
223              
224             =head1 Author
225              
226             L was written by Ron Savage Iron@savage.net.auE> in 2012.
227              
228             Home page: L.
229              
230             =head1 Copyright
231              
232             Australian copyright (c) 2012, Ron Savage.
233              
234             All Programs of mine are 'OSI Certified Open Source Software';
235             you can redistribute them and/or modify them under the terms of
236             The Artistic License, a copy of which is available at:
237             http://www.opensource.org/licenses/index.html
238              
239             =cut