package Egg::Helper::Build::Project; # # Masatoshi Mizuno ElusheE<64>cpan.orgE # # $Id: Project.pm 337 2008-05-14 12:30:09Z lushe $ # use strict; use warnings; our $VERSION= '3.04'; sub _start_helper { my($self)= @_; my $project_name= shift(@ARGV) || return $self->_helper_help(' I want project name. '); my $o= $self->_helper_get_options; $o->{help} and return $self->_helper_help; $project_name=~m{^[A-Z][A-Za-z0-9_]+$} || return $self->_helper_help(' Bad format of project name. '); my $version= $o->{version} || '0.01'; $version=~m{^\d+\.\d\d+} || return $self->_helper_help(' Bad format of version number. '); my $c= $self->config; $c->{project_name}= $project_name; $c->{root} = $o->{output_path} || '.'; $c->{root}.= "/${project_name}"; -e $c->{root} and return $self->_helper_help(qq{'$c->{root}' already exists.}); my $files= [$self->helper_yaml_load(join '', )]; my $param= $self->helper_prepare_param({ module_version => $version }); $self->helper_chdir($c->{root}, 1); $param->{project_root}= $self->helper_current_dir; $self->helper_generate_files( param => $param, create_files => $files, create_dirs => [qw/ bin root comp etc t htdocs cache tmp /], makemaker_ok => ($o->{unmake} ? 0: 1), errors => { rmdir=> [$c->{root}] }, complete_msg => "Project generate is completed.\n\n" . "output path : $c->{root}", ); if (my $test= $self->config->{helper_option}{test_code}) { $test->($self, $param, $files); } $self; } sub _helper_get_options { shift->next::method(' v-version= m-unmake '); } sub _helper_help { my $self= shift; my $msg = shift || ""; $msg= "ERROR: ${msg}\n\n" if $msg; print <. The mode and the made project name are passed to the generated helper script and it starts. % egg_helper.pl project [PROJECT_NAME] PROJECT_NAME is made for the current directory by this, and the file complete set is generated in that. PROJECT_NAME specifies the name that can be used as a module name of Perl. Moreover, the form of the subclass including ':' is not accepted. =head1 SEE ALSO L, L, =head1 AUTHOR Masatoshi Mizuno ElusheE<64>cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2008 Bee Flag, Corp. ELE. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available. =cut __DATA__ --- filename: lib/.pm filetype: module value: | package ; # # # # This is controller. # use strict; use warnings; use Egg qw/ -Debug ConfigLoader /; our $VERSION= ''; __PACKAGE__->egg_startup; 1; __END__ < $e.document > --- filename: lib//Dispatch.pm filetype: module value: | package ::Dispatch; # # < e.revision > # # This is dispatch. # use strict; use warnings; use base qw/ Egg::Dispatch::Standard /; our $VERSION= '0.01'; ->dispatch_map( _default => sub { my($e, $dispatch)= @_; require Egg::Util::BlankPage; $e->response->body( Egg::Util::BlankPage->out($e) ); }, # _default => sub {}, # sitemap => sub {}, # contact => sub {}, # help => { # _default=> sub {}, # }, ); 1; __END__ --- filename: lib//config.pm filetype: module value: | package ::config; # # # use strict; use warnings; sub out { { # Project Title. title=> '< e.project_name >', # Project root directory. (Absolutely path only) root => '< e.project_root >', # Directory configuration. static_uri=> '/', dir => { lib => '\/lib', htdocs => '\/htdocs', etc => '\/etc', cache => '\/cache', tmp => '\/tmp', template => '\/root', comp => '\/comp', }, # Character code for processing. # character_in => 'euc', # euc or sjis or utf8 # disable_encode_query => 0, # Template. # template_default_name => 'index', # template_extension => '.tt', template_path=> [qw/ \ \ /], # Default content type and language. # charset_out => 'euc-jp', # content_type => 'text/html', # content_language => 'ja', # Regular expression of Content-Type that doesn't send Content-Length. # no_content_length_regex => qr{(?:^text/|/(?:rss\+)?xml)}, # Upper bound of request directory hierarchy. # max_snip_deep => 10, # Regular expression in part that wants to be erased from Request PATH always. # request_path_trim => qr{^/?speedy\.cgi}, # Accessor to stash. * Do not overwrite a regular method. # accessor_names => [qw/hoge/], # Cookie default setup. # cookie_default => { # domain => 'mydomain', # path => '/', # expires => 0, # secure => 0, # }, # MODEL => [ # [ DBI => { # dsn => 'dbi:SQLite;dbname=\/.db', # user => '', # password => '', # options => { AutoCommit=> 1, RaiseError=> 0 }, # } ], # ], # VIEW => [ # [ Mason => { # comp_root=> [ # [ main => '\' ], # [ private=> '\' ], # ], # data_dir=> '\', # } ], # [ HT => { # path=> ['\', '\'], # global_vars=> 1, # die_on_bad_params=> 0, # # cache=> 1, # } ], # ], # request => { # DISABLE_UPLOADS => 0, # TEMP_DIR => '\', # POST_MAX => 10240, # }, # * For ErrorDocument plugin. # plugin_error_document=> { # view_name => 'Mason', # template => 'error/document.tt', # }, # * For FillInForm plugin. # plugin_fillinform=> { # ignore_fields => [qw{ ticket }], # fill_password => 0, # }, } } 1; --- filename: Makefile.PL filetype: text value: | use inc::Module::Install; name ''; all_from 'lib/.pm'; abstract_from 'lib/.pm'; version_from 'lib/.pm'; author ''; license ''; requires 'Egg::Release' => ; build_requires 'Test::More' => 0; build_requires 'Test::Pod' => 0; # build_requires 'Test::Perl::Critic => 0; # build_requires 'Test::Pod::Coverage => 0; use_test_base; auto_include; WriteAll; --- filename: bin/trigger.cgi filetype: script value: | #! package ::trigger; # use FindBin; # use lib "$FindBin::Bin/../lib"; use lib qw{ /lib }; use ; ->handler; --- filename: bin/dispatch.fcgi filetype: script value: | #! package EggRelease::trigger; BEGIN { $ENV{_REQUEST_CLASS} ||= 'Egg::Request::FastCGI'; # $ENV{_FCGI_LIFE_COUNT} = 0; # $ENV{_FCGI_LIFE_TIME} = 0; # $ENV{_FCGI_REBOOT} = 0; }; use FindBin; use lib "$FindBin::Bin/../lib"; use ; ->handler; --- filename: bin/speedy.cgi filetype: script value: | #!/usr/bin/perperl package ::trigger; # use FindBin; # use lib "$FindBin::Bin/../lib"; use lib qw{ /lib }; use ; ->handler; --- filename: bin/_helper.pl filetype: script value: | #! use FindBin; use lib "$FindBin::Bin/../lib"; use Egg::Helper; Egg::Helper->run( shift(@ARGV), { project_name_orign => '', project_root => '', } ); --- filename: bin/_tester.pl filetype: script value: | #! use FindBin; use lib "$FindBin::Bin/../lib"; use Egg::Helper; Egg::Helper->run( 'Util::Tester', project_name_orign => '', project_root => '', ); --- filename: etc/mod_perl2.conf.example filetype: text value: | LoadModule perl_module modules/mod_perl.so ServerName hostname.example.com DocumentRoot /htdocs PerlOptions +Parent PerlSwitches -I PerlModule mod_perl2 PerlModule SetHandler perl-script PerlHandler # # When proxy such as Pound is put on frontend, it is likely to need it. # # * The reference ahead. -> http://stderr.net/apache/rpaf/ # # LoadModule rpaf_module modules/mod_rpaf-X.X.so # RPAFenable On # RPAFsethostname Off # RPAFproxy_ips 255.255.255.255 --- filename: etc/lighttpd+fastcgi.conf.example filetype: text value: | $HTTP["host"] == "mydomain.name" { # $HTTP["remoteip"] !~ "^255\.255\.255\.0$" { # url.access-deny = ("") # } server.document-root = "/htdocs" url.rewrite-once = ( "^/([^\.]+)?([\?\#].*)?$" => "/dispatch.fcgi/$1$2", ) fastcgi.server = ( "/dispatch.fcgi" => (( "socket" => "/tmp/fcgi.socket", "bin-path" => "/htdocs/dispatch.fcgi", "max-procs" => 1, # "idle-timeout" => 10 )) ) } --- filename: t/00_.t filetype: text value: | use Test::More tests => 1; use FindBin; use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/../../lib", ); BEGIN { use_ok('') }; --- filename: t/01_< $e.project_name >-config.t filetype: text value: | use Test::More tests => 1; use FindBin; use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/../../lib", ); BEGIN { use_ok('::config') }; --- filename: t/02_-dispatch.t filetype: text value: | use Test::More tests => 12; use FindBin; use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib", "$FindBin::Bin/../../lib", ); use ; ok my $e= ->new; isa_ok $e, 'Egg'; isa_ok $e, 'Egg::Request'; isa_ok $e, 'Egg::Response'; isa_ok $e, 'Egg::Util'; isa_ok $e, 'Egg::Manager::Model'; isa_ok $e, 'Egg::Manager::View'; isa_ok $e, 'Egg::Component'; isa_ok $e, '::Dispatch'; can_ok $e, 'dispatch_map'; isa_ok $e->dispatch_map, 'HASH'; isa_ok $e->dispatch_map->{_default}, 'CODE'; --- filename: t/89_pod.t~ filetype: text value: | use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); --- filename: t/98_perlcritic.t~ filetype: text value: | use strict; use Test::More; eval q{ use Test::Perl::Critic }; plan skip_all => "Test::Perl::Critic is not installed." if $@; all_critic_ok("lib"); # # Please install Test::Perl::Critic to do this test effectively. # - perl -MCPAN -e "install Test::Perl::Critic" # --- filename: t/99_pod_coverage.t~ filetype: text value: | use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); --- filename: Changes filetype: text value: | Revision history for Perl extension . - original version; created by with module name . --- filename: README filetype: text value: | . ================================================= The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install AUTHOR COPYRIGHT AND LICENCE Put the correct copyright and licence information here. Copyright (C) by . This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version or, at your option, any later version of Perl 5 you may have available. --- filename: MANIFEST.SKIP filetype: text value: | \bRCS\b \bCVS\b ^MANIFEST\. ^MakeMaker-\d ^Makefile$ ^_build/ ^blib/ ^pm_to_blib ^t/9\d+_.*\.t Build$ \.cvsignore \.?svn* ^\% ^(bin|etc)/ (~|\-|\.(old|save|back))$ --- filename: htdocs/css/index.css filetype: text value: | body { margin:0px; background:#AAA; font:normal 12pt sans-serif; color:#000; text-align:center; } a { color:#05F } img { border:0px } /* ---------------------------------------------- */ h1, h2, h3 { margin: 5px; font: bold 25px Times,sans-serif; text-decoration: underline; } h2, h3 { font-size: 14px } h3 { margin-top: 0px } pre { margin: 2px 10px 5px 0px; padding: 10px; background: #FFF7E5; font: normal 12px sans-serif; border: #C99158 solid 1px; } /* ---------------------------------------------- */ #container { width:780px; padding:0px; margin:0px auto 0px auto; background:#EB0; border:#000 solid 2px; } #header { text-align:left; height:73px; border-bottom:#000 solid 2px; background:#FD0; } #header .logo { float:left; } #header .descript { padding:20px; height:73px; border-left:#000 solid 2px; } #content { padding:10px; width:522px; float:right; border:#000 solid 2px; border-top:0px; border-right:0px; background:#FFF; text-align:left; } #side_content { width:234px; float:left; } #menu a { display:block; border-bottom:#740 solid 1px; text-decoration:none; color:#333; } #menu a:hover { color:#000; background:#FC0; } #footer { clear:both; padding:1px 3px 3px 3px; font-size:8pt; } #footer a { text-decoration:none; color:#555; } #footer a:hover { text-decoration:underline; color:#000; } #copyright { font:italic 10pt Times; color:#555; } --- filename: comp/html-header.tt filetype: text value: | <%init> my $lang= $e->response->content_language; <% $e->page_title %> % % if ($s->{load_prototype}) { % } # $s->{load_prototype} end. % % if ($s->{javascript}) {