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

NAME

ExtUtils::ModuleMaker::Utility - Utility subroutines for EU::MM

SYNOPSIS

    use ExtUtils::ModuleMaker::Utility qw(
        _get_home_directory
        _get_mmkr_directory
        _preexists_mmkr_directory
        _make_mmkr_directory
        _restore_mmkr_dir_status
        _get_dir_and_file
    );

    $home_dir = _get_home_directory();

    $mmkr_dir = _get_mmkr_directory();

    $dirref = _preexists_mmkr_directory();

    ($mmkr_dir, $no_mmkr_dir_flag) = _make_mmkr_directory();

    _restore_mmkr_dir_status($mmkr_dir, $no_mmkr_dir_flag),

    ($dir, $file) = _get_dir_and_file($module);

DESCRIPTION

This package holds utility subroutines imported and used by ExtUtils::ModuleMaker and/or its test suite. The subroutines exist primarily to eliminate blocks of repeated code.

USAGE

_get_home_directory()

Analyzes environmental information to determine whether there exists on the system a 'HOME' or 'home-equivalent' directory. Returns that directory if it exists; croaks otherwise.

On Win32, this directory is the one returned by the following function from the Win32module:

    Win32->import( qw(CSIDL_LOCAL_APPDATA) );
    $realhome =  Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() );

... which translates to something like C:\Documents and Settings\localuser\Local Settings\Application Data.

Well, not quite. On some systems, that directory does not exist or is hidden. What does exist is the same path less the Local Settings\\ level. So we run $realhome through a regex to eliminate that.

    $realhome =~ s|(.*?)\\Local Settings(.*)|$1$2|;

On Unix-like systems, things are much simpler. We simply check the value of $ENV{HOME}. We cannot do that on Win32 (at least not on ActivePerl), because $ENV{HOME} is not defined there.

_get_mmkr_directory()

If the modulemaker environmental variable ($ENV{modulemaker}) has been set administratively, return its contents. Otherwise, compose a directory name from the home directory. Note: This subroutine simply returns the name of a path; it does not check for the path's existence as a directory.

_preexists_mmkr_directory()

Internally calls _get_mmkr_directory() to get an appropriate name for a directory. Returns a reference to an array holding a two-element list. The first element is that directory name. The second is a flag indicating whether that directory already exists (a true value) or not (undef). The flag is used only within ExtUtils::Modulemaker's test suite.

_make_mmkr_directory()

Takes as argument the array reference returned by _preexists_mmkr_directory(). Examines the first element in that array -- the directory name -- and creates the directory if it doesn't already exist. The function croaks if the directory cannot be created.

_restore_mmkr_dir_status()

Undoes _make_mmkr_directory(), i.e., if there was no .modulemaker directory on the user's system before testing, any such directory created during testing is removed. On the other hand, if there was such a directory present before testing, it is left unchanged.

_get_dir_and_file()

  Usage     : _get_dir_and_file($module) within complete_build()
  Purpose   : Get directory and name for .pm file being processed
  Returns   : 2-element list: First $dir; Second: $file
  Argument  : $module: pointer to the module being built
              (as there can be more than one module built by EU::MM);
              for the primary module it is a pointer to $self
  Comment   : Merely a utility subroutine to refactor code; not a method call.

BUGS

So far checked only on Win32 (WindowsXP Pro) and Darwin.

AUTHOR/MAINTAINER

James E Keenan (jkeenan [at] cpan [dot] org).

SUPPORT

Send email to jkeenan [at] cpan [dot] org. Please include 'modulemaker' in the subject line.

COPYRIGHT

Copyright (c) 2005 James E. Keenan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

ExtUtils::ModuleMaker.