NAME

Data::Type::Query - introspection of Data::Type library via DBI

SYNOPSIS

use Data::Type qw(:all);

use Data::Type::Query; 

  my $dtq = Data::Type::Query->new();

  foreach my $what ( $dtq->tables )
  {
    my $sth = $dtq->dbh->do( "SELECT * FROM $what" ) || Carp::croak "$DBI::err";
  
    while( my $href = $sth->fetchrow_hashref )
    {
      print join ', ', $href;
    }
  }

  $dtq->depends();

  print $dtq->toc();

  my $href = $dtq->catalog();

  print $href->{$_} for qw(types facets filters regexps);

Description

Data::Type is planned to get big as more datatypes are added to collections. Therefore introspection and surfing through the collections will be essential. Especially when alternativ collections arent always installed and available. This module adds introspection/reflection of Data::Type datatypes, filters and documentation via DBI (via *ingenous* DBD::AnyData).

METHODS

Data::Type::Query->new

my $dtq = Data::Type::Query->new;

The constructor does not require arguments.

$dtq->dbh;

Returns the DBI $dbh handle ready for querying.

$dtq->catalog()

my $href = $dtq->catalog();

Returns a hashref which hold prerendered tabular listings (as scalars).

print $href->{types};
print $href->{regexps};
print $href->{facets};
print $href->{filters};

Valid keys of that hash are retrievable with $dtq->tables.

[NOTE] Be carefull since the catalog is generated only one time (for the life time of your program) and latter calls return the cached version.

$dtq->toc()

my $scalar = $dtq->toc;

Returns a static string containing a grouped listing of all know types.

$dtq->depends()

my $href = $dtq->depends;

Generates a dependency tree. Which type depends on which module. Returns an hash reference with this something similar to this structure:

        {
          'Locale::Language' => {
                                  'types' => [
                                               {
                                                 'name' => 'LANGCODE'
                                               },
                                               {
                                                 'name' => 'LANGNAME'
                                               }
                                             ],
                                  'version' => '2.02'
                                },
          'Business::CreditCard' => {
                                      'types' => [
                                                   {
                                                     'name' => 'CREDITCARD'
                                                   }
                                                 ],
                                      'version' => '0.27'
                                    },
          'Email::Valid' => {
                              'types' => [
                                           {
                                             'name' => 'EMAIL'
                                           }
                                         ],
                              'version' => '0.14'
                            },
	}

[NOTE] In future helps implementing clever runtime module loading for only types really used.

CONTACT

Sourceforge http://sf.net/projects/datatype is hosting a project dedicated to this module. And I enjoy receiving your comments/suggestion/reports also via http://rt.cpan.org or http://testers.cpan.org.

AUTHOR

Murat Uenalan, <muenalan@cpan.org>