Catalyst::Helper::Model::ISBNDB - Catalyst::Helper assist for ISBNDB


Catalyst-Model-ISBNDB documentation Contained in the Catalyst-Model-ISBNDB distribution.

Index


Code Index:

NAME

Top

Catalyst::Helper::Model::ISBNDB - Catalyst::Helper assist for ISBNDB

SYNOPSIS

Top

    perl script/myapp_create.pl model MyISBNDB ISBNDB API_KEY

DESCRIPTION

Top

This is a Catalyst::Helper component to allow you to add model components deriving from the Catalyst::Model::ISBNDB class, using the Catalyst-generated create.pl helper-script.

When run via the creation-helper, a new model class and a simple test suite for it will be added to your Catalyst application. The class will be added in the same directory as your other models, and the test added to the t/ directory in the top-level of the project.

USAGE

Top

When the helper script is invoked, you provide it with 3 or 4 arguments:

model

This is always model, when adding a model component.

MyClass

The name of the new class you want to add.

ISBNDB

The name of the model class you are deriving from, ISBNDB in this case.

API_KEY

(This parameter is optional.)

The isbndb.com API key your application will be using, if you wish to have it explicitly defined in the configuration block of the new class.

You can provide just model and ISBNDB alone (two arguments), in which case the new class will be given a name using your project's class hierarchy and ending in ISBNDB, and no default API key will be configured.

METHODS

Top

This class defines the following two methods:

mk_compclass($SELF, $HELPER, [$KEY])

Creates the class by using the Catalyst::Helper instance pointed to by $HELPER. If $KEY is passed and is non-null, the call to config in the generated class will set the value as the default API key used for data calls to isbndb.com.

mk_comptest($SELF, $HELPER)

Creates the unit test suite for the new model. Does this by using the Catalyst::Helper instance pointed to by $HELPER.

SEE ALSO

Top

Catalyst::Model::ISBNDB, Catalyst::Helper

BUGS

Top

Please report any bugs or feature requests to bug-catalyst-model-isbndb at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-ISBNDB. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Model-ISBNDB

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Catalyst-Model-ISBNDB

* CPAN Ratings

http://cpanratings.perl.org/d/Catalyst-Model-ISBNDB

* Search CPAN

http://search.cpan.org/dist/Catalyst-Model-ISBNDB

* Source code on GitHub

http://github.com/rjray/catalyst-model-isbndb/tree/master

COPYRIGHT & LICENSE

Top

AUTHOR

Top

Randy J. Ray <rjray@blackperl.com>


Catalyst-Model-ISBNDB documentation Contained in the Catalyst-Model-ISBNDB distribution.
###############################################################################
#
# This file copyright (c) 2008-2009 by Randy J. Ray, all rights reserved
#
# Copying and distribution are permitted under the terms of the Artistic
# License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php) or
# the GNU LGPL (http://www.opensource.org/licenses/lgpl-license.php).
#
###############################################################################
#
#   Description:    Helper file for auto-generating Catalyst::Model::ISBNDB
#                   sub-classes by means of a Catalyst project's create.pl
#                   script.
#
#   Functions:      mk_compclass
#                   mk_comptest
#
#   Global Consts:  $VERSION
#
###############################################################################

package Catalyst::Helper::Model::ISBNDB;

use 5.008;
use strict;
use warnings;
use vars qw($VERSION);
use subs qw(mk_compclass mk_comptest);

use Catalyst::Model::ISBNDB;

$VERSION = '0.12';
$VERSION = eval $VERSION;  ## no critic

###############################################################################
#
#   Sub Name:       mk_compclass
#
#   Description:    Create the component class from one of the two templates
#                   provided later, after the __DATA__ token.
#
#   Arguments:      NAME      IN/OUT  TYPE      DESCRIPTION
#                   $self     in      ref       Object of this class
#                   $helper   in      ref       Catalyst::Helper instance
#                   $api_key  in      scalar    Default API key to use
#
#   Returns:        1
#
###############################################################################
sub mk_compclass
{
    my ($self, $helper, $api_key) = @_;

    $helper->{api_key} = $api_key || '';
    $helper->{this_module} = __PACKAGE__ . "/$VERSION";
    $helper->{base_module} =
        "Catalyst::Model::ISBNDB/$Catalyst::Model::ISBNDB::VERSION";

    $helper->render_file('modelclass', $helper->{file});

    1;
}

###############################################################################
#
#   Sub Name:       mk_comptest
#
#   Description:    Create the a basic test-suite for the component class,
#                   using the other of the two templates provided after the
#                   __DATA__ token.
#
#   Arguments:      NAME      IN/OUT  TYPE      DESCRIPTION
#                   $self     in      ref       Object of this class
#                   $helper   in      ref       Catalyst::Helper instance
#
#   Returns:        1
#
###############################################################################
sub mk_comptest
{
    my ($self, $helper) = @_;

    $helper->render_file('modeltest', $helper->{test});

    1;
}

1;

__DATA__

1;
__modeltest__
use strict;
use warnings;
use Test::More tests => 2;

use_ok('Catalyst::Test', '[% app %]');
use_ok('[% class %]');

exit;