NAME

Rose::DBx::Garden - bootstrap Rose::DB::Object and Rose::HTML::Form classes

SYNOPSIS

use Rose::DBx::Garden;
   
my $garden = Rose::DBx::Garden->new(

        garden_prefix   => 'MyRoseGarden',    # instead of class_prefix
        perltidy_opts   => '-pbp -nst -nse',  # Perl Best Practices
        db              => My::DB->new, # Rose::DB object
        find_schemas    => 0,           # set true if your db has schemas
        force_install   => 0,           # do not overwrite existing files
        debug           => 0,           # print actions on stderr
        skip_map_class_forms => 1,      # no Form classes for many2many map classes
        include_autoinc_form_fields => 1,
        # other Rose::DB::Object::Loader params here

);
                       
# $garden ISA Rose::DB::Object::Loader
                    
$garden->plant('path/to/where/i/want/files');

DESCRIPTION

Rose::DBx::Garden bootstraps Rose::DB::Object and Rose::HTML::Form based projects. The idea is that you can point the module at a database and end up with work-able RDBO and Form classes with a single method call.

Rose::DBx::Garden creates scaffolding only. It creates Rose::DB::Object-based and Rose::HTML::Object-based classes, which assume 1 table == 1 form. There is no generation of code to handle subforms, though it's relatively easy to add those later.

Rose::DBx::Garden inherits from Rose::DB::Object::Loader, so all the magic there is also available here.

METHODS

NOTE: All the init_* methods are intended for when you subclass the Garden class. You can pass in values to the new() constructor for normal use. See Rose::Object::MakeMethods::Generic.

include_autoinc_form_fields

The default behaviour is to include db columns flagged as auto_increment from the generated Form class and to map them to the 'serial' field type. Set this value to a false value to exclude auto_increment columns as form fields.

init_column_field_map

Sets the default RDBO column type to RHTMLO field type mapping. Should be a hash ref of 'rdbo' => 'rhtmlo' format.

init_column_to_label

Returns a CODE ref for filtering a column name to its corresponding form field label. The CODE ref should expect two arguments: the Garden object and the column name.

The default is just to return the column name. If you wanted to return, for example, a prettier version aligned with the naming conventions used in Rose::DB::Object::ConventionManager, you might do something like:

my $garden = Rose::DBx::Garden->new(
                column_to_label => sub {
                       my ($garden_obj, $col_name) = @_;
                       return join(' ', 
                                   map { ucfirst($_) }
                                   split(m/_/, $col_name)
                              );
                }
             );

init_garden_prefix

The default base class name is MyRoseGarden. This value overrides class_prefix and base_class in the base Loader class.

init_perltidy_opts

If set, Perl::Tidy will be called to format all generated code. The value of perltidy_opts should be the same as the command-line options to perltidy.

The default is 0 (no run through Perl::Tidy).

init_text_field_size

Tie the size and maxlength of text input fields to the allowed length of text columns. Should be set to an integer corresponding to the max size of a text field. The default is 64.

init_base_code

The return value is inserted into the base RDBO class created.

init_base_form_class_code

The return value is inserted into the base RHTMLO class created.

init_limit_to_schemas

The default return value is an empty arrayref, which is interpreted as "all schemas" if the find_schemas flag is true.

Otherwise, you may explicitly name an array of schema names to limit the code generated to only those schemas you want. Must be used with find_schemas set to true.

use_db_name( name )

Define an explicit database name to use when generating class names. The default is taken from the Rose::DB connection information. NOTE:This does not affect the db connection, only the string used in constructing class names.

NOTE:This option is ignored if find_schemas() is true.

plant( path )

path will override module_dir() if set in new().

Returns a hash ref of all the class names created, in the format:

RDBO::Class => RHTMLO::Class

If no RHTMLO class was created the hash value will be '1'.

make_garden

An alias for plant().

garden_prefix

Returns the garden_prefix() value with which this class was created.

garden_default_field( column, label, tabindex )

Returns the Perl code text for creating a generic Form field.

garden_numeric_field( column, label, tabindex )

Returns the Perl code text for creating a numeric Form field.

garden_boolean_field( column, label, tabindex )

Returns the Perl code text for creating a boolean Form field.

garden_text_field( column, label, tabindex )

Returns the Perl code text for creating a text Form field.

garden_menu_field( column, label, tabindex )

Returns the Perl code text for creating a menu Form field.

garden_textarea_field( column, label, tabindex )

Returns Perl code for textarea field.

garden_hidden_field( column, label, tabindex )

Returns the Perl code text for creating a hidden Form field.

garden_serial_field( column, label, tabindex )

Returns the Perl code text for creating a serial Form field.

AUTHORS

Peter Karman, <karman at cpan.org>

BUGS

Please report any bugs or feature requests to bug-rose-dbx-garden at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Rose-DBx-Garden. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Rose::DBx::Garden

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to Adam Prime, adam.prime at utoronto.ca for patches and feedback on the design.

The Minnesota Supercomputing Institute http://www.msi.umn.edu/ sponsored the development of this software.

COPYRIGHT & LICENSE

Copyright 2007 by the Regents of the University of Minnesota.

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