The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Egg::Helper - Helper module for Egg WEB Aplication Framework.

SYNOPSIS

  # Obtaining of helper script.
  perl -MEgg::Helper -e 'Egg::Helper->out' > egg_helper.pl
  
  # Generation of project.
  perl egg_helper.pl Project MyApp -o /home
  
  # The helper of the project is used.
  perl MyApp/bin/myapp_helper.pl Plugin::Maker NewPlugin

DESCRIPTION

This offers the helper function to use Egg WEB Aplication Framework.

* This document is the one to make the helper script chiefly. It is not personally related to the composition of WEB Aplication.

DEVELOPER

It becomes help of the helper script development, and it explains the behavior etc. of this module.

This module starts the helper module specified from the command line according to the following procedures.

  • perl myapp_helper.pl Plugin::Maker NewPlugin

    Myapp_helper.pl is a helper script only for the project generated to the bin folder of the project.

  • run

    The command line is evaluated by this method.

    The part of continuing myapp_helper.pl Plugin::Maker is recognized as a helper module of the object that puts the start.

    And, it tries to evaluate a suitable name or the option.

    The part of NewPlugin is concretely identified to 'any_name' in this example. It comes to be able to refer from the helper module with $helper->global->{any_name}. If the character string that starts by '_' continues, it is treated as an option. It comes to be able to access it globally by the name defined by the method of '_setup_get_options'.

  • execute

    The object helper module is read after the command line is suitably evaluated, and the method of '_execute' is called.

    At this time, it adds in @ISA of the object helper module beforehand and it adds it to Egg::Helper. As a result, it comes to be able to call all methods of Egg::Helper from the object helper module like the method completely. Egg::Helper operates in a word consequentially like the framework for the helper module.

A convenient code is only freely written now if a target helper module starts.

METHODS

new

Constructor.

It uses it when processing it after the object is made by the method of '_execute'.

The object of the HASH reference base is restored.

global

It is an accessor to global HASH.

When the method of '_execute' was called, some values had already been defined.

_setup_get_options ( [OPTION_STRING], [HELP_CODE] )

It prepares it. receive the option from the command line.

OPTION_STRING is an option to pass to Getopt::Easy. * ' o-out= g-debug h-help ' is added without fail.

The default of HELP_CODE is $helper->can('_output_help').

  $helper->SUPER::_setup_get_options( ' u-user_name= p-password= ' );

Please refer to the document of Getopt::Easy.

run ( [MODE], [ARGS_HASH] )

After the global variable is set up, the helper module is started.

MODE is a name of the helper who puts the start.

  * This name is progressed , saying that 'Egg::Helper::[MODE]'.
  * MODE that doesn't contain ':' is not accepted.

It is ,in a word, a part of 'Plugin::Maker' of the place said by the DEVELOPER explanation example.

start_dir

The current directory in the place where the helper script was started is returned.

project_root

Route PATH of the project of the object is returned.

* Anything doesn't return when project_root of ARGS_HASH passed with run is erased.

chdir ( [TARGET_DIR], [CREATE_FLAG] )

The current directory is changed and it reports to STDOUT.

After TARGET_DIR is made, chdir is done when CREATE_FLAG is given.

create_dir ( [CREATE_PATH] )

After CREATE_PATH is made, it reports to STDOUT.

It moves even if a deep hierarchy is suddenly specified because mkpath of File::Path is used.

remove_dir ( [DELETE_PATH] )

After DELETE_PATH is deleted, it reports to STDOUT.

Because rmtree of "File::Path " is used, the subdirectory is recurrently deleted.

remove_file ( [DELETE_FILE] )

It reports to STDOUT if the deletion of DELETE_FILE is tested, and it succeeds.

DELETE_FILE can be passed with ARRAY.

read_file ( [FILE_PATH] )

The content is returned reading FILE_PATH.

  • Alias: fread

save_file ( [SAVE_DATA_HASH], [REPLACE_PARAM_HASH] )

It saves a file based on structural the following SAVE_DATA_HASH, and it reports to STDOUT.

  filename ... PATH and name of made file.
               If the directory doesn't exist making ahead, it makes it.
  
  value    ... Content of made file.
  
  filetype ... File type.
  
    - If it is a name that starts by bin, it starts doing decode_base64 of
      L<MIME::Base64>, and it developing with the binary.
  
    - If it is a name that starts by script or bin_exec, chmod 0700 is done.

Filename is put on $helper->replace.

Value is put on $helper->replace in case of not being in the name that the file type starts by bin.

  $helper->save_file({
  
    filename => 'etc/example.txt',
    value    => $example_value,
  
    }, \%param_data );

  $helper->save_file({
  
    filename => 'htdocs/images/example.png',
    filetype => 'bin',
    value    => $base64_encode_text,
  
    });

yaml_load ( [YAML_TEXT] or [YAML_FILE_PATH] )

YAML_TEXT or YAML_FILE_PATH is done in Perth and the result is returned.

load_project_config ( [PM_ONLY_FLAG] )

The setting of the project is read and returned.

When PM_ONLY_FLAG is given, it reads for only config.pm.

generate ( [OPERATION_ATTR_HASH] )

The file complete set is generated based on structural the following OPERATION_ATTR_HASH.

  • chdir => [ [PATH], [FLAG] ]

    If chdir is done, it defines it. This is an argument passed to $helper->chdir and an always ARRAY reference.

  • create_files => [ [SAVE_DATA_HASH] ]

    The made file data is defined by the ARRAY reference.

    Each value of ARRAY is an argument passed to $helper->save_file.

  • create_dirs => [ [CREATE_PATH_ARRAY] ]

    An empty directory is made.

  • create_code => [CODE_REF],

    The code can be added.

    The helper object is passed to the code.

  • makemaker_ok => [ 1 or 0 ]

    After the file complete set is generated, a series of perl Makefile.PL and others make test is done.

  • complete_msg => [COMPLETE_MESSAGE],

    COMPLETE_MESSAGE set when the generation processing is completed is output to STDOUT.

  • errors => [OPTION_HASH],

    It is a setting concerning the settlement when the error occurs.

      rmdir => [DELETE_DIR_ARRAY]
         List of deleted directory.
         This list extends to $helper-E<gt>remove_dir.
      
      unlink => [DELETE_FILE_ARRAY]
         List of deleted file.
         This list extends to $helper-E<gt>remove_file.
      
      message => [ERROR_MESSAGE]
         It is an error message.
  $helper->generate(
    chdir        => [qw{ /path/to/home 1 }],
    create_files => \@files,
    create_dirs  => \@dirs,
    makemaker_ok => 0,
    complete_msg => ' ... Coumpete. ',
    create_code  => sub { ... },
    errors => {
      rmdir   => \@dirs,
      unlink  => \@files,
      message => ' ... Internal Error !! ',
      },
    );

testfile_number_now

The number of the test file newly made is returned.

'00' is returned when project_root cannot be acquired or project_root/t has been deleted or it fails in acquisition.

  my $test_number= $helper->testfile_number_now;

mod_name_resolv ( [MODULE_PATH] )

It checks whether file PATH composition is resolved and the name of each hierarchy is suitable as the module name of Perl.

And, the result of the check is returned with ARRAY.

If it is not suitable among hierarchies even by one place as the module name of Perl, 0 is returned.

  $helper->mod_name_resolv('./MyApp/Orign/tools');

is_platform

OS while operating it is returned.

'Unix' returns if there is neither 'Win32' nor 'MacOS'.

is_unix

One returns if judged that $helper->is_platform is 'Unix'.

is_win32

One returns if judged that $helper->is_platform is 'Win32'.

is_mac

One returns if judged that $helper->is_platform is 'MacOS'.

project_name ( [PROJECT_NAME] )

When PROJECT_NAME is given, the project name is set again.

However, if it is not suitable as ':' is contained as the project name, the exception is generated.

When PROJECT_NAME is omitted, the project name under the setting is returned.

* Because the helper module is loaded with the project name has been set, it is not necessary to set it again usually.

get_cwd

The current directory is returned.

year

A present Christian era is returned.

dir_check ( [DIR_PATH] )

DIR_PATH exists, and it is recordable is checked.

When the check cannot be passed, the exception is generated.

perl_path

Passing the main body of perl is returned.

The value is returned if environment variable 'PERL_PATH' is set, and PATH is specified by File::Which in case of not being. When everything fails, the exception is generated.

_setup_rc

Reading the rc file is tried by Egg::Plugin::rc. And, 'copywright' etc. are set up to $helper->global.

Please refer to RESOURCE CODE VARIABLE for details.

_output_help

-h It moves when help is demanded by the option etc.

Override may do this method on the helper module side.

out

The helper script code is output.

Please preserve the output code in a suitable place and use it.

  perl -MEgg::Helper -e "Egg::Helper->out" > /path/to/bin/egg_helper.pl

GLOBAL VARIABLE

It is a key to global HASH that will be set up by the time the helper module is called list.

project_name

Project name.

project_root

Route PATH of project.

any_name

When the name has been passed to the helper script, it is set.

debug

-d When $ENV{EGG_DEBUG} is set, whether the option is effective it is set.

* If this value is effective, it sets it up like displaying the stack trace when the error occurs.

start_dir

The current directory is set.

output_path

-o If the option is effective, it is set. Or, if $ENV{EGG_OUT_PATH} is set, this value is set. If it is undefined, all current directories are set above.

help

-h If the option is effective, it is set.

... etc

Additionally, the global value set beforehand changes by the option to pass to the setting and the run method of the method of '_setup_get_options'.

RESOURCE CODE VARIABLE

When the method of '_setup_rc' is called, loading the rc file is tried by way of Egg::Plugin::rc. And, HASH that succeeds in loading is set in a global value.

It is a key as follows set up without fail when the method of '_setup_rc' is called.

  • author, copyright, headcopy

  * The above-mentioned default is a value obtained with $ENV{LOGNAME} or
    $ENV{USER}.
  * It is escaped in the mail address and <> for pod.

MODULE GENERATION VARIABLE

When the module file is generated, a special global value is set up when '_setup_module_maker' is called beforehand.

This is a list of the key set up.

created

Name and version mark of helper script under operation.

revision

Character for CVS and SVN to substitute it as Ribijon.

* It is measures against the situation that the character for the Ribijon mark replaces by committing of the helper script.

lib_dir

lib/$e->project_name

lc_project_name

Entire project name of small letter.

uc_project_name

Entire project name of capital letter.

ucfirst_project_name

The first character is a project name of the capital letter.

module_version

0.01

perl_version

Version of Perl under operation.

egg_release_version

Version of Egg::Release.

gmtime_string

Value of gmtime.

year

Christian era when starting. (CODE reference)

document

Pod document of default. (CODE reference)

dist

The module name is decided from the file name of the generation module. (CODE reference)

SEE ALSO

File::Path, File::Which, Getopt::Easy, MIME::Base64, YAML, Egg::Base, Egg::Exception, Egg::Plugin::rc, Egg::Release,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT

Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 271:

L<> starts or ends with whitespace