NAME

PkgForge::Registry::App - A Moose role for applications which use the registry

VERSION

This documentation refers to PkgForge::Registry::App version 1.3.0

SYNOPSIS

package PkgForge::App::Foo;

use Moose;

with 'PkgForge::Registry::App';

sub action_add { ... }

sub action_delete { ... }

1;

# and then via the command-line pkgforge application:

% pkgforge foo add
% pkgforge foo del

DESCRIPTION

This is a Moose role which is designed to simplify the creation of Package Forge command-line applications that need to query or modify the registry. It is intended to assist in doing two separate things which are always required. The first is to add support for sub-commands (actions) on top of the MooseX::App::Cmd behaviour already in place. The second is to give standardised access to the Package Forge registry.

ATTRIBUTES

Any class which has this role applied will have the following attributes:

configfile

An optional configuration file name which can be used to set the values of the registry database attributes when a PkgForge::Registry object is instantiated using the new_with_config method. If not specified then the default file will be used, if it exists, see PkgForge::Registry for full details. When used in conjunction with MooseX::App::Cmd::Command this becomes available as a command-line option.

registry

This holds the reference to the PkgForge::Registry object itself.

SUBROUTINES/METHODS

Any class which has this role applied will have the following methods:

actions_list

This returns the list of all "action" methods in a class. An action method is just a normal method with the name prefixed by action_. The prefix is stripped from the method names, e.g. if there is a method named action_foo then this method will return foo.

actions_map

This method takes the list of action methods from the actions_list method and converts it into a hash using Text::Abbrev. The keys are the unique abbreviations for each action name and the values are the full length name.

actions_string

This method converts the list of actions into a comma-separated string suitable for displaying to the user.

require_parameters(@attributes)

Normally all attributes would be marked as required where necessary. When using this role some attributes may only be required for certain actions. This method can be used to check the requirements for each action. It is called to ensure that those attributes exist and have values set, if any are not set it will die with a useful error message.

execute

The App::Cmd::Command class expects there to be a method named execute which does the actual work. This role extends this to allow sub-commands (actions) and this is the method which decides what action method should be executed. This allows the user to do something like:

pkgforge foo list

pkgforge foo add

pkgforge foo del

by creating a class named PkgForge::App::Foo, which applies this role, with methods named action_list, action_add and action_delete.

CONFIGURATION AND ENVIRONMENT

This role adds an attribute, named configfile, which can be used to load a configuration file for the registry DB access. If you do not specify this file name then the PkgForge::Registry object will be created using the default configuration file, if it exists and is accessible. When used in conjunction with MooseX::App::Cmd::Command this becomes available as a command-line option.

It is not necessary to set all the attributes to successfully connect to the database. The DBI layer has support for using environment variables for nearly all possible connection options, see DBD::Pg for full details.

DEPENDENCIES

This module is powered by Moose and uses MooseX::ConfigFromFile and MooseX::Types. This module is intended to work with MooseX::App::Cmd::Command but there is no direct dependency. It also uses Text::Abbrev to handle unique shortened names for actions.

SEE ALSO

PkgForge, pkgforge(1)

PLATFORMS

This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.

ScientificLinux5, Fedora13

BUGS AND LIMITATIONS

Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.

AUTHOR

Stephen Quinney <squinney@inf.ed.ac.uk>

LICENSE AND COPYRIGHT

Copyright (C) 2010 University of Edinburgh. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.