-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.PL
67 lines (61 loc) · 2.2 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use strict;
use warnings;
use ExtUtils::MakeMaker qw( WriteMakefile prompt );
# define database list
my %db_list = (
'mysql' => 'MySQL',
'postgres' => 'Postgres',
'oracle' => 'Oracle',
'sqlserver' => 'SQL Server',
);
# load old db connection info, prompt for new info
my $answer;
my %DBINFO;
if ( -e 't/dbinfo' ) {
print "--Current test DB info--\n";
open( INF, 't/dbinfo' );
while ( <INF> ) {
print $_;
chomp( $_ );
my ( $key, $value ) = split( /=/, $_, 2 );
$DBINFO{$key} = $value;
}#while
close( INF );
$answer = prompt( 'Do you want to change the current test DB info?', 'no' );
}#if
else {
print "The tests require information for each database you want to run them against.\n";
$answer = prompt( 'Do you want to enter test DB info?', 'no' );
}#else
# request new info from user
if ( $answer =~ /^y/i ) {
while ( my ( $db, $name ) = each( %db_list ) ) {
$answer = prompt( "Enter $name test DB info?", 'no' );
if ( $answer =~ /^y/i ) {
$DBINFO{"${db}_host"} = prompt( "Enter $name test DB host", $DBINFO{"${db}_host"} || 'localhost' );
$DBINFO{"${db}_db"} = prompt( "Enter $name test DB name", $DBINFO{"${db}_db"} || 'test' );
$DBINFO{"${db}_user"} = prompt( "Enter $name test DB user", $DBINFO{"${db}_user"} || 'test' );
$DBINFO{"${db}_pass"} = prompt( "Enter $name test DB pass", $DBINFO{"${db}_pass"} || '' );
# Oracle hack, users are almost always uppercase
$DBINFO{"${db}_user"} = uc( $DBINFO{"${db}_user"} );
}#if
}#foreach
# write out changes
open( OUTF, '>t/dbinfo' );
foreach my $key ( sort keys %DBINFO ) {
print OUTF "$key=$DBINFO{$key}\n";
}#foreach
close( INF );
}#if
WriteMakefile(
NAME => 'Cosmic::DB',
VERSION_FROM => 'lib/Cosmic/DB.pm', # finds \$VERSION
AUTHOR => 'Lyle Hopkins ([email protected])',
ABSTRACT => 'Lightweight SQL generation, portable across Oracle, MySQL, Postgres & SQL Server',
PREREQ_PM => {
'Test::Simple' => 0.44,
'DBI' => 0,
'Test::More' => 0,
'Test::Deep' => 0,
},
);