File Coverage

ex/BeerDB.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package BeerDB;
2 2     2   38232 use Maypole::Application;
  0            
  0            
3             use Class::DBI::Loader::Relationship;
4              
5             sub debug { $ENV{BEERDB_DEBUG} }
6             # This is the sample application. Change this to the path to your
7             # database. (or use mysql or something)
8             use constant DBI_DRIVER => 'SQLite';
9             use constant DATASOURCE => $ENV{BEERDB_DATASOURCE} || 't/beerdb.db';
10              
11             my $dbi_driver;
12              
13             BEGIN {
14             $dbi_driver = DBI_DRIVER;
15            
16             if ($dbi_driver =~ /^SQLite/)
17             {
18             die sprintf "SQLite datasource '%s' not found, correct the path or "
19             . "recreate the database by running Makefile.PL", DATASOURCE
20             unless -e DATASOURCE;
21            
22             eval "require DBD::SQLite";
23            
24             if ($@)
25             {
26             eval "require DBD::SQLite2" and $dbi_driver = 'SQLite2';
27             }
28             }
29            
30             BeerDB->setup(join ':', "dbi", $dbi_driver, DATASOURCE);
31             }
32              
33             # Give it a name.
34             BeerDB->config->application_name('The Beer Database');
35              
36             # Change this to the root of the web site for your maypole application.
37             BeerDB->config->uri_base( $ENV{BEERDB_BASE} || "http://localhost/beerdb/" );
38              
39             # Change this to the htdoc root for your maypole application.
40             BeerDB->config->template_root( $ENV{BEERDB_TEMPLATE_ROOT} ) if $ENV{BEERDB_TEMPLATE_ROOT};
41              
42             # Specify the rows per page in search results, lists, etc : 10 is a nice round number
43             BeerDB->config->rows_per_page(10);
44              
45             # Handpumps should not show up.
46             BeerDB->config->display_tables([qw[beer brewery pub style]]);
47             BeerDB::Brewery->untaint_columns( printable => [qw/name notes url/] );
48             BeerDB::Style->untaint_columns( printable => [qw/name notes/] );
49             BeerDB::Beer->untaint_columns(
50             printable => [qw/abv name price notes url/],
51             integer => [qw/style brewery score/],
52             date =>[ qw/date/],
53             );
54             BeerDB::Pub->untaint_columns(printable => [qw/name notes url/]);
55              
56             BeerDB->config->{loader}->relationship($_) for (
57             "a brewery produces beers",
58             "a style defines beers",
59             "a pub has beers on handpumps");
60              
61             # For testing classmetadata
62             sub BeerDB::Beer::classdata: Exported {};
63             sub BeerDB::Beer::list_columns { return qw/score name price style brewery url/};
64              
65             1;