NAME

Egg::Helper::Util::Base - Utility for a helper module.

DESCRIPTION

It is a utility class for the helper module.

METHODS

The method of this module can be used in the shape succeeded to to Egg::Helper.

These methods are the one having aimed at use from the helper module.

helper_perl_path

Passing perl is acquired and returned by File::Which.

However, if PERL_PATH is set in the environment variable, the value is returned.

my $perl_path= Egg::Helper->helper_perl_path;

helper_temp_dir

The work directory is temporarily made from File::Temp, and the passing is returned.

When the process is annulled, the made directory is deleted by the automatic operation.

my $tempdir= Egg::Helper->helper_temp_dir;
  • Alias = helper_tempdir

helper_current_dir

A current now passing is acquired and returned by Cwd.

my $current_dir= Egg::Helper->helper_current_dir;

helper_is_platform

The name of the platform under operation is returned.

It is only Win32, MacOS, and Unix to be returned.

All Unix is returned if it is Win32, MacOS, and it doesn't exist.

helper_is_unix

The platform under operation returns and Win32 and MacOS return true if it is not.

helper_is_win32

If the platform under operation is Win32, true is returned.

helper_is_macos

If the platform under operation is MacOS, true is returned.

  • helper_is_mac

helper_yaml_load ([YAML_TEXT])

The text of the YAML form is converted into data and it returns it.

my $hash= Egg::Helper->helper_yaml_load($yaml_text);

helper_stdout ([ARGS])

ARGS is passed to the out method of Egg::Util::STDIO, and the result is returned.

helper_stdin ([ARGS])

ARGS is passed to the in method of Egg::Util::STDIO, and the result is returned.

helper_load_rc ([HASH_REF])

The rc file arranged by Egg::Plugin::rc for the project is read.

And, it read from the rc file, and author, copywright, headcopy, and license are set to HASH_REF and it returns it.

helper_chdir ([PATH_STR], [BOOL])

The current directory is moved to PATH_STR. And, the moving destination is output to STDOUT.

It makes it if there is no moving destination when BOOL is given.

$helper->helper_chdir('/path/to/move', 1);

helper_create_dir ([PATH_LIST])

The directory of PATH_LIST is made and the passing is output to STDOUT.

There is exist former directory not worrying because it uses 'mkpath' of File::Path.

$helper->helper_create_dir('/path/to/hoge', '/path/to/booo');

helper_remove_dir ([PATH_LIST])

The directory of PATH_LIST is deleted and the passing is output to STDOUT. File::Path Because drinking 'rmtree' is used, all subordinate's directories are deleted.

$helper->helper_remove_dir('/path/to/hoge', '/path/to/booo');

helper_remove_file ([PATH_LIST])

All files of PATH_LIST are deleted and the passing is output to STDOUT. The deletion fails if passing specified this is specializing in the file is a file and doesn't exist.

$helper->helper_remove_file('/path/to/hoge.txt', '/path/to/booo.tmp');

helper_read_file ([FILE_PATH])

The content is returned reading FILE_PATH. Because binmode is always done, it is possible to read even by the binary.

my $value= $helper->helper_read_file('/path/to/hoge.txt');
  • Alias = helper_fread

helper_save_file ([PATH], [SCALAR_REF], [TYPE])

The file is generated.

PATH is passing of the generation file.

SCALAR_REF is a content of the generated file. It gives it by the SCALAR reference.

After it generates it, the execution attribute of 0700 is set if TYPE is script or 'bin_exec'.

If it is a name that TYPE starts by bin, it puts it into the state to restore SCALAR_REF with MIME::Base64.

If the directory of the generation place doesn't exist, 'helper_create_dir' is done and the directory is made.

And, the generation situation is output to STDOUT.

$helper->helper_save_file('/path/to/', $value, 'text');

The file is always written with binmode.

helper_create_file ([HASH_REF], [PARAM])

'helper_save_file' is done according to the content of HASH_REF.

HASH_REF is HASH reference with the following keys.

filename ..... It corresponds to PATH of 'helper_save_file'.
value    ..... It corresponds to SCALAR_REF of 'helper_save_file'.
filetype ..... It corresponds to TYPE of 'helper_save_file'.

Moreover, it is Egg::Util if it is a name that giving PARAM and filetype start by bin and it doesn't exist. It 'drinks egg_var'.

$helper->helper_create_file({
  filename => '<e.die.etc>/hoge.txt',
  value    => 'Create OK',
  filetype => 'text',
  }, $e->config );

helper_create_files ([CREATE_LIST], [PARAM])

Two or more files are generated with helper_create_file based on CREATE_LIST. In CREATE_LIST, it is ARRAY always reference, and each element is HASH_REF passed to helper_create_file.

PARAM extends to helper_create_file as it is.

$helper->helper_create_files
  ([ $helper->helper_yaml_load( join '', <DATA> ) ])

helper_document_template

The document sample to bury it under the content when the module is generated is returned.

my $sample= $helper->helper_document_template;

helper_valid_version_number ([VERSION_NUM])

It examines whether VERSION_NUM is suitable as the version number of the module.

'_helper_help' is called in case of not being suitably.

When VERSION_NUM is omitted, '0.01' is returned.

my $version= $helper->helper_valid_version_number($o->{version});

helper_prepare_param ([PARAM])

Each parameter needed when the file is generated is set in PARAM and it returns it.

PARAM is omissible. Thing made HASH reference when giving it.

my $param= $helper->helper_prepare_param;
$helper->helper_create_files($data, $param);

helper_prepare_param_module ([PARAM])

Each parameter needed when the module is generated is set in PARAM and it returns it.

my $param= $helper->helper_prepare_param;
$helper->helper_prepare_param_module($param);
$helper->helper_create_files($data, $param);

helper_generate_files ([HASH_REF])

A series of file generation processing according to the content of HASH_REF is done.

HASH_REF is HASH reference of the following content. Only param is indispensable.

  • param

    It is a parameter acquired with 'helper_prepare_param' etc.

  • chdir

    It extends to 'helper_chdir'. When the flag is given, it does by the ARRAY reference.

  • create_dirs

    It is ARRAY reference passed to 'helper_create_dir'.

  • create_files

    It is ARRAY reference passed to 'helper_create_files'.

  • create_code

    It is CODE reference for doing on the way as for some processing.

  • makemaker_ok

    After the file is generated, '_helper_execute_makemaker' is done.

  • complete_msg

    It is a message after processing ends.

  • errors

    It is a setting when the error occurs by processing the above-mentioned and HASH reference.

    • message

      Message when error occurs.

    • rmdir

      List of directory passed to 'helper_remove_dir'.

    • unlink

      List of file passed to 'helper_remove_file'.

helper_get_dbi_attr ([HASH])

The setting concerning DBI for Egg is acquired from the environment variable. This is the one having aimed at the thing used in the test of the package.

The following environment variables are acquired and the HASH reference is returned.

{
  table   => ($ENV{EGG_DBI_TEST_TABLE} || 'egg_release_dbi_test'),
  dsn     => ($ENV{EGG_DBI_DSN}      || ""),
  user    => ($ENV{EGG_DBI_USER}     || ""),
  password=> ($ENV{EGG_DBI_PASSWORD} || ""),
  options => ($_[1] ? {@_}: ($_[0] || {})),
  };

helper_http_request ([REQUEST_METHOD], [URI], [PARAM])

When emulation is done in the code, the WEB request is convenient for this in the package test.

HTTP::Request::Common is done, and 'as_string' of HTTP::Request is received. And, after environment variable CONTENT_LENGTH and CONTENT_TYPE are set, the fragment of as_ string is returned.

_helper_execute_makemaker

Perl Makefile.PL etc. are executed at the command line level in the current directory.

When the error occurs, the exception is not generated. It only reports on the error to STOUT.

Moreover, helper_is_unix returns false and if environment variable EGG_MAKEMAKER is also undefined, it returns it without doing anything.

When Module::Install is not installed, only warning is vomited and nothing is done.

_helper_help ([MSG])

Help of default is displayed.

After it helps, it is displayed in the part when MSG is passed.

SEE ALSO

Egg::Release, Egg::Helper, Egg::Plugin::YAML, Egg::Plugin::rc, Egg::Util::STDIO, Egg::Exception, Cwd, File::Basename, File::Path, File::Spec, File::Temp, File::Which, FileHandle, Getopt::Easy, HTTP::Request::Common, MIME::Base64, UNIVERSAL::require,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>.

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.