NAME

OpenInteract::Package - Perform actions on individual packages

SYNOPSIS

DESCRIPTION

This module defines actions to be performed on individual packages. The first argument for many of the methods that

METHODS

create_subdirectories( $root_dir, $main_class )

Creates subdirectories in a package directory -- currently the list of subdirectories is held in the package lexical @PKG_SUBDIR, plus we also create the directories:

$main_class
$main_class/Handler
$main_class/SQLInstall

If there is no $main_class passed in, 'OpenInteract' is assumed.

create_package_skeleton( $package_name, $base_install_dir )

Creates the skeleton for a package in the current directory. The skeleton can then be used to for a fully functioning package.

The skeleton creates the directories found in @PKG_SUBDIR and copies a number of files from the base OpenInteract installation to the skeleton. These include:

Changes
package.conf
MANIFEST
MANIFEST.SKIP
conf/spops.perl
conf/action.perl
doc/package.pod
doc/titles
template/dummy.meta
template/dummy.tmpl
<PackageName>/SQLInstall/<PackageName>.pm
<PackageName>/Handler/<PackageName>.pm

We fill in as much default information as we know in the files above, and several of the files have helpful hints about the type information that goes in each.

install_distribution

Install a package distribution file to the base OpenInteract installation. We do not need to do any localization work here since we are just putting the distribution in the base installation, so the operation is fairly straightforward.

More work and testing likely needs to be done here to ensure it works on Win32 systems as well as Unix systems. The use of File::Spec and File::Path should help with this, but there are still issues with the version of Archive::Tar shipped with ActiveState Perl.

install_to_website( \%params )

Installs a package from the base OpenInteract installation to a website. The package must already have defined 'website_name', 'website_dir' and 'package_dir' object_properties. Also, the directory:

website_dir/pkg/pkg-version

should not exist, otherwise the method will die.

Note that we use the routines _copy_spops_config_file() and _copy_action_config_file(), which localize the spops.perl and action.perl configuration files for the website. The localization consists of changing the relevant class names from 'OpenInteract' to 'MyWebsiteName'.

export_package( \%params )

Exports the package whose root directory is the current directory into a distribution file in tarred-gzipped format, also placed into the current directory.

Parameters:

  • config_file ($) (optional)

    Name of configuration file for package.

  • config (\%) (optional)

    Hashref of package configuration file information.

Returns: Information about the new package in hashref format with the following keys:

  • name ($)

    Name of package

  • version ($)

    Version of package

  • file ($)

    Full filename of distribution file created

read_config( \%params )

Reads in a package configuration file. This file is in a simple name-value format, although the file supports lists and hashes as well. Whether a parameter supports a list or a hash is defined in the package lexical variables %CONF_LIST_KEYS and %CONF_HASH_KEYS. The reading goes like this:

If a key is not in %CONF_LIST_KEYS or %CONF_HASH_KEYS, it is just a simple key/value pair; a key in %CONF_LIST_KEYS gets the value pushed onto a stack, and a key found in %CONF_HASH_KEYS has its value split on whitespace again and that assigned to the hashref indexed by the original key. Once we hit the 'description' key, the rest of the file is read in at once and assigned to the description. Note that comments and blank lines are skipped until we get to the description when it is all just slurped in.

Returns: hashref of configuration information with the configuration keys as hashref keys.

Parameters:

  • file ($)

    Full filename of package file to be read in

  • info ($)

    Hashref of package information to read package config from

  • directory ($)

    Directory from which to read the package config.

replace_and_copy( \%params )

Copy a file from one place to another and in the process do a search-and-replace of certain keys.

Parameters:

  • from_file ($)

    File from which we should read text.

  • to_file ($)

    File to which we write changed text.

  • from_text (\@)

    List of keys to replace

  • to_text (\@)

    Replacement values for each of the keys in 'from_text'

copy_modules( $pkg_info, $to_dir )

Copy all module files (everything ending in .pm) from this package to a separate directory.

Returns: arrayref with the full destination path of all files copied.

HELPER METHODS

_check_module_install( @modules )

Check to see if all the @modules are installed on the local machine. Return value is a list of all modules that are NOT installed, so an empty list is good.

_create_full_path( $filename )

If necessary, creates the full path necessary to reach $filename.

Returns: true if the necessary path already exists or was successfully created, throws a die if it cannot be created.

_clean_package_name( $package_name )

Ensures that the package name can be used in OpenInteract, which basically checks whether we can turn it into a valid Perl namespace.

Returns: cleaned package name, or throws a die if the errors cannot be cleaned.

_extract_archive( $archive_filename )

This method is a wrapper around Archive::Tar to try and account for some of the differences between versions of the module. Errors found during extraction will be found in the package lexical $ARCHIVE_ERROR.

Note that before calling this you should already be in the directory where the archive will be extracted.

_create_manifest

Creates a MANIFEST file in the current directory. This file follows the same rules as found in ExtUtils::Manifest since we use the mkmanifest() routine from that module.

Note that we turn on the 'Quiet' and turn off the 'Verbose' parameters in hopes that the operation will be silent (too confusing), but the current version of ExtUtils::Manifest does not make its sub-operations silent. The version shipped with 5.6.1 should take care of this.

_remove_directory_tree( $dir )

Remove a directory and all files/directories beneath it. Return the number of removed files.

_change_class_name( $old_class, $new_name )

Changes the name from 'OpenInteract' to $new_name within $old_class. For instance:

my $old_class = 'OpenInteract::Handler::FormProcess';
my $new_class = $class->_change_class_name( $old_class, 'MyWebsiteName' );
print "New class is: $new_class\n";

>> New class is: MyWebsiteName::Handler::FormProcess

If the method is called from an object and the second argument ($new_name) is not given, we default it to: $object->{website_name}.

TO DO

Documentation.

BUGS

None known.

SEE ALSO

OpenInteract::PackageRepository

COPYRIGHT

Copyright (c) 2001-2002 intes.net, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>