blib/lib/AppBuilder.pm untested

filter: Statementstmt 0.0% 0 / 99 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 23 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 134 CC 4 SCAR 15.6
CC
4
Cov
0%
new
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 4.8
1 package CGI::AppBuilder;
2  
3 # Perl standard modules
4 use strict;
5 use warnings;
6 use Getopt::Std;
7 use POSIX qw(strftime);
8 use CGI;
9 use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
10 use CGI::Pretty ':standard';
11 use CGI::AppBuilder::Apps qw(:all);
12 use CGI::AppBuilder::Config qw(:all);
13 use CGI::AppBuilder::Message qw(:all);
14 use CGI::AppBuilder::Log qw(:all);
15 use CGI::AppBuilder::Form qw(:all);
16 use CGI::AppBuilder::Table qw(:all);
17 use CGI::AppBuilder::Header qw(:all);
18 use CGI::AppBuilder::Frame qw(:all);
19 use CGI::AppBuilder::Net qw(:all);
20 use CGI::AppBuilder::File qw(:all);
21 use CGI::AppBuilder::Security qw(:all);
22 use CGI::AppBuilder::Define qw(:all);
23 use CGI::AppBuilder::HTML qw(:all);
24 use CGI::AppBuilder::PLSQL qw(:all);
25  
26 our $VERSION = 1.0001;
27 warningsToBrowser(1);
28  
29 require Exporter;
30 our @ISA = qw(Exporter);
31 our @EXPORT = qw();
32 our @IMPORT_OK = (@CGI::AppBuilder::Apps::EXPORT_OK,
33 @CGI::AppBuilder::Config::EXPORT_OK,
34 @CGI::AppBuilder::Message::EXPORT_OK,
35 @CGI::AppBuilder::Log::EXPORT_OK,
36 @CGI::AppBuilder::Form::EXPORT_OK,
37 @CGI::AppBuilder::Table::EXPORT_OK,
38 @CGI::AppBuilder::Header::EXPORT_OK,
39 @CGI::AppBuilder::Frame::EXPORT_OK,
40 @CGI::AppBuilder::Net::EXPORT_OK,
41 @CGI::AppBuilder::File::EXPORT_OK,
42 @CGI::AppBuilder::Security::EXPORT_OK,
43 @CGI::AppBuilder::Define::EXPORT_OK,
44 @CGI::AppBuilder::HTML::EXPORT_OK,
45 @CGI::AppBuilder::PLSQL::EXPORT_OK,
46 );
47 our @EXPORT_OK = (@IMPORT_OK);
48 our %EXPORT_TAGS = (
49 app => [@CGI::AppBuilder::Apps::EXPORT_OK],
50 config => [@CGI::AppBuilder::Config::EXPORT_OK],
51 echo_msg => [@CGI::AppBuilder::Message::EXPORT_OK],
52 log => [@CGI::AppBuilder::Log::EXPORT_OK],
53 form => [@CGI::AppBuilder::Form::EXPORT_OK],
54 table => [@CGI::AppBuilder::Table::EXPORT_OK],
55 header => [@CGI::AppBuilder::Header::EXPORT_OK],
56 frame => [@CGI::AppBuilder::Frame::EXPORT_OK],
57 exec => [@CGI::AppBuilder::Net::EXPORT_OK],
58 file => [@CGI::AppBuilder::File::EXPORT_OK],
59 security => [@CGI::AppBuilder::Security::EXPORT_OK],
60 html => [@CGI::AppBuilder::HTML::EXPORT_OK],
61 plsql => [@CGI::AppBuilder::PLSQL::EXPORT_OK],
62 all => [@EXPORT_OK, @IMPORT_OK]
63 );
64  
65 =head1 NAME
66  
67 CGI::AppBuilder - CGI Application Builder
68  
69 =head1 SYNOPSIS
70  
71 use CGI::AppBuilder;
72  
73 my $cg = CGI::AppBuilder->new('ifn', 'my_init.cfg', 'opt', 'vhS:a:');
74 my $ar = $cg->get_inputs;
75  
76 =head1 DESCRIPTION
77  
78 There are already many application builders out there. Why you need
79 another one? Well, if you are already familiar with CGI::Builder or
80 CGI::Application, this one will provide some useful methods to you to
81 read your configuration file and pre-process your templates.
82 Please read on.
83  
84 =cut
85  
86 =head3 new (ifn => 'file.cfg', opt => 'hvS:')
87  
88 Input variables:
89  
90 $ifn - input/initial file name.
91 $opt - options for Getopt::Std
92  
93 Variables used or routines called:
94  
95 None
96  
97 How to use:
98  
99 my $ca = new CGI::AppBuilder; # or
100 my $ca = CGI::AppBuilder->new; # or
101 my $ca = CGI::AppBuilder->new(ifn=>'file.cfg',opt=>'hvS:'); # or
102 my $ca = CGI::AppBuilder->new('ifn', 'file.cfg','opt','hvS:');
103  
104 Return: new empty or initialized CGI::AppBuilder object.
105  
106 This method constructs a Perl object and capture any parameters if
107 specified. It creates and defaults the following variables:
108
109 $self->{ifn} = ""
110 $self->{opt} = 'hvS:';
111  
112 =cut
113  
114 sub new {
115 my $caller = shift;
116 my $caller_is_obj = ref($caller);
117 my $class = $caller_is_obj || $caller;
118 my $self = bless {}, $class;
119 my %arg = @_; # convert rest of inputs into hash array
120 foreach my $k ( keys %arg ) {
121 if ($caller_is_obj) {
122 $self->{$k} = $caller->{$k};
123 } else {
124 $self->{$k} = $arg{$k};
125 }
126 }
127 $self->{ifn} = "" if ! exists $arg{ifn};
128 $self->{opt} = 'hvS:' if ! exists $arg{opt};
129 return $self;
130 }
131  
132 1;
133  
134 =head1 HISTORY
135  
136 =over 4
137  
138 =item * Version 0.10
139  
140 This version is to extract out the app methods from CGI::Getopt class.
141 It was too much for CGI::Getopt to include the start_app, end_app,
142 build_html_header, and disp_form methods.
143  
144 0.11 Rewrote start_app method so that content-type can be changed.
145 0.12 Moved disp_form to CGI::AppBuilder::Form,
146 moved build_html_header to CGI::AppBuilder::Header, and
147 imported all the methods in sub-classes into this class.
148  
149 =item * Version 1.0001
150  
151 Removed start_app and end_app to CGI::AppBuilder::Apps module.
152  
153 =cut
154  
155 =head1 SEE ALSO (some of docs that I check often)
156  
157 Oracle::Loader, Oracle::Trigger, CGI::Getopt, File::Xcopy,
158 CGI::AppBuilder, CGI::AppBuilder::Message, CGI::AppBuilder::Log,
159 CGI::AppBuilder::Config, etc.
160  
161 =head1 AUTHOR
162  
163 Copyright (c) 2005 ~ 2015 Hanming Tu. All rights reserved.
164  
165 This package is free software and is provided "as is" without express
166 or implied warranty. It may be used, redistributed and/or modified
167 under the terms of the Perl Artistic License (see
168 http://www.perl.com/perl/misc/Artistic.html)
169  
170 =cut
171