-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.PL
64 lines (56 loc) · 1.97 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
BEGIN { }
use strict;
use warnings;
use ExtUtils::MakeMaker;
use Data::Dumper;
my $conf_file = 'mysql.pldat';
my $table = 'TEMP_DATA_CONSUMER_TEST_TABLE';
my $db = 'dev';
my $usr = 'test';
my $pwd = 'test';
unless (-e $conf_file) {
print <<EOFTEXT;
To test properly I will need access to a MySQL database
with create and drop table privileges. To do this I will
need to ask some more questions to complete configuration.
What you answer will be stored in the file '$conf_file'
and will not be removed unless you do a make clean, thus
you wont have to go through this process again even if you
rerun this script. If you wish to change your answer
delete the file (or run make clean) and rerun Makefile.PL.
If you wish to set things up now the db, username, and
password will by default be '$db', '$usr', '$pwd',
and the table I will create and drop for testing
will be '$table'.
EOFTEXT
my $do_mysql_config = prompt "Run MySQL tests? [yes/no]",'no';
my @connect;
if ($do_mysql_config=~/^y/i) {
$db = prompt "Please enter database name:",$db;
$usr = prompt "Please enter user name to connect to $db with:",$usr;
$pwd = prompt "Please enter password to use for $usr:",$pwd;
$table = prompt "Table to use for testing:",$table;
push @connect,$db,$usr,$pwd;
}
open my $fh,">",$conf_file or die "Cant open '$conf_file' for writing: $!";
print $fh Data::Dumper->Dump([$table, \@connect],[qw(*table *connect_args)]);
close $fh;
}
WriteMakefile(
NAME => 'Data::Consumer',
AUTHOR => 'Yves Orton <[email protected]>',
VERSION_FROM => 'lib/Data/Consumer.pm',
ABSTRACT_FROM => 'lib/Data/Consumer.pm',
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
'Data::Dumper' => 0,
'DBI' => 0,
'File::Spec' => 3.2701,
'File::Path' => 2.04,
'Fcntl' => 0,
'POSIX' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => "Data-Consumer-* *~ $conf_file" },
);