#!/usr/bin/perl -w # -*- perl -*- use strict; use warnings; use lib qw( ./lib ../lib ); use Config; use File::Spec::Functions qw( catfile ); use Template; use ExtUtils::MakeMaker; use Cwd; select STDERR; $| = 1; select STDOUT; our $CONFIG_DIR = -d 't' ? 't' : '.'; our $CONFIG_FILE = 'dbi_test.cfg'; our $CONFIG_PATH = catfile($CONFIG_DIR, $CONFIG_FILE); our $RUN_TESTS = 'n'; our $TT_QUIET = 0; our $TT_ACCEPT = 0; dbi_config(); my %opts = ( 'NAME' => 'Template-DBI', 'VERSION_FROM' => 'lib/Template/Plugin/DBI.pm', 'PMLIBDIRS' => [ 'lib' ], 'PREREQ_PM' => { 'Template' => 2.15, 'DBI' => 1.00, }, 'dist' => { 'COMPRESS' => 'gzip', 'SUFFIX' => 'gz', }, 'clean' => { 'FILES' => 't/dbi_test.cfg', }, ); if ($ExtUtils::MakeMaker::VERSION >= 5.43) { $opts{ AUTHOR } = 'Andy Wardley '; $opts{ ABSTRACT } = 'DBI plugin for the Template Toolkit', } WriteMakefile( %opts ); #------------------------------------------------------------------------ # dbi_config() # # Quiz the user for options related to running the DBI tests. #------------------------------------------------------------------------ sub dbi_config { my ($dsn, $user, $pass) = ('') x 3; if (ttprompt("Do you want to run the DBI tests?\n" . "It requires access to an existing test database.", $RUN_TESTS) =~ /y/i) { $RUN_TESTS = 1; my ($driver, $dbname); require DBI; my @drivers = DBI->available_drivers(); local $" = ', '; my $default = (grep(/m.?sql/i, @drivers))[0] || $drivers[0] || ''; message(<$CONFIG_PATH") || die "$CONFIG_PATH: $!\n"; print CFGFILE <); } return ($ans ne '') ? $ans : $def; } #------------------------------------------------------------------------ # yep($text) #------------------------------------------------------------------------ sub yep { return if $TT_QUIET; print '[X] ', shift, "\n"; } #------------------------------------------------------------------------ # nope($text) #------------------------------------------------------------------------ sub nope { return if $TT_QUIET; print '[ ] ', shift, "\n"; }