diff --git a/Makefile.PL b/Makefile.PL index a1f369a..e973cd0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,3 +1,4 @@ +use 5.006; #our, weaken use strict; use ExtUtils::MakeMaker; @@ -5,10 +6,9 @@ use ExtUtils::MakeMaker; my %required = ( 'Set::Object' => 1.10, - "Test::More" => 0, #"Date::Manip" => 0, "Time::Piece" => 0, - "Class::Date" => 0, + #"Class::Date" => 0, #not used in modules and test suite #"DateTime" => 0, "Scalar::Util" => 1.14, "Data::Lazy" => 0.6, @@ -25,13 +25,13 @@ while (my ($module, $min_ver) = each %required) { eval "use $mod_ver;"; if($@) { if (exists $required_hard{$module}) { - $bomb_out = 1; + #$bomb_out = 1; print STDERR ("$mod_ver not found.\n"); } elsif ( exists $required_soft{$module} ) { print STDERR ("$mod_ver not found. Some tests and/or " ."functionality may be missing.\n"); } else { - $skip_tests = 1; + #$skip_tests = 1; print STDERR ("$mod_ver not found. You will not be able " ."to run the test suite.\n"); } @@ -44,15 +44,12 @@ use lib '.'; sub yes { - print ' (Y/n) '; - return =~ /^(Y(e(s)?)?|A(YE|II+!*))?\n?$/i; + return prompt(' (Y/n) ','Y') =~ /^(Y(e(s)?)?|A(YE|II+!*))?\n?$/i; } sub yeah_no # it's an antipodean thing { - print ' (N/y) '; - return =~ /^(Y(e(s)?)?|A(YE|II+!*))\n?$/i; - + return prompt(' (N/y) ','N') =~ /^(Y(e(s)?)?|A(YE|II+!*))\n?$/i; } print q{Do you plan to run the test suite? @@ -90,20 +87,35 @@ connection information from a previous installation. Should I use it?}; unless ($configured) { - print q{ + my ($use_tx, $use_subsel, $table_type) = (1, 1); + my $cs; + my ($user, $passwd); + if (eval { require Test::Database; 1;} && lc(prompt('use Test::Database?','Y')) eq 'y') { + my @db_handles = Test::Database->handles(); + my $db; + foreach my $d (@db_handles) { + my $t = $d->dbd; + next if $t eq 'CSV' || $t eq 'DBM'; + $db = $d; + } + do { $skip_tests = 1; goto NOTESTS } unless $db; + $cs = $db->dsn(); + $user = $db->username(); + $passwd = $db->password(); + } else { + print q{ Please give me the login and password for accessing the test database. I must be able to create and drop tables in that database.}; - print "\n1) DBI connect string (omit the \'DBI:\' part): "; - my $cs = ; - chop $cs; + $cs = prompt("\n1) DBI connect string (omit the \'DBI:\' part): "); + chomp $cs; + do { $skip_tests = 1; goto NOTESTS } unless $cs; - $cs = "dbi:$cs" unless $cs =~ /^dbi\:/i; + $cs = "dbi:$cs" unless $cs =~ /^dbi\:/i; - my ($use_tx, $use_subsel, $table_type) = (1, 1); - if ($cs =~ m/:mysql:/i) { - print q{ + if ($cs =~ m/:mysql:/i) { + print q{ You have selected the MySQL back-end. Normally, subselects and transactions are disabled for this database. However, if you are using MySQL-Max, or some other MySQL version with InnoDB support @@ -119,44 +131,41 @@ sub-select tests. It is not possible to use sub-selects with InnoDB table types. Use InnoDB tables}; - unless (yeah_no()) { - $use_tx = 0; - - print "Use sub-selects"; - unless (yeah_no()) { - $use_subsel = 0; - } - } else { - $table_type = "InnoDB"; + unless (yeah_no()) { + $use_tx = 0; + + print "Use sub-selects"; + unless (yeah_no()) { + $use_subsel = 0; + } + } else { + $table_type = "InnoDB"; + } } - } - my ($user, $passwd); - if ( $cs =~ /:sqlite:/i ) { - print q{ + if ( $cs =~ /:sqlite:/i ) { + print q{ You have selected the SQLite back-end. Sub-selects will be disabled. }; - $use_subsel = 0; - $user = $passwd = ""; - } else { + $use_subsel = 0; + $user = $passwd = ""; + } else { - print "2) Login: "; - $user = ; - chop $user; + $user = prompt('2) Login: '); + chomp $user; - print "3) Password: "; - $passwd = ; - chop $passwd; + $passwd = prompt('3) Password:'); + chomp $passwd; - } + } - print <<'MSG'; + print <<'MSG'; Thank you. I am going to save this information to 't/CONFIG'. If you have given me sensitive information, make sure to destroy the file when the tests have been completed. MSG - + } open CONFIG, '>t/CONFIG' or die "Cannot create 't/CONFIG', reason: $!"; print CONFIG "$cs\n$user\n$passwd\ntx_do = $use_tx\nsubselects = $use_subsel\n".($table_type?"table_type = $table_type\n":""); close CONFIG; @@ -201,10 +210,49 @@ find(sub { }; }, "lib"); -WriteMakefile( - 'NAME' => 'Tangram', - 'VERSION_FROM' => 'lib/Tangram.pm', # finds $VERSION - PREREQ_PM => \%required, - PM => \%PM, - test => { TESTS => $tests }, +WriteMakefile1( + 'NAME' => 'Tangram', + 'VERSION_FROM' => 'lib/Tangram.pm', # finds $VERSION + PREREQ_PM => \%required, + TEST_REQUIRES => { + "Test::More" => 0, + }, + MIN_PERL_VERSION => '5.006', + META_MERGE => { + resources => { + repository => 'https://github.com/samv/tangram', + }, + }, + 'LICENSE' => 'GPL2', + PM => \%PM, + test => { TESTS => $tests }, ); + +sub WriteMakefile1 { #Compatibility code for old versions of EU::MM. Written by Alexandr Ciornii, version 0.23. Added by eumm-upgrade. + my %params=@_; + my $eumm_version=$ExtUtils::MakeMaker::VERSION; + $eumm_version=eval $eumm_version; + die "EXTRA_META is deprecated" if exists $params{EXTRA_META}; + die "License not specified" if not exists $params{LICENSE}; + if ($params{AUTHOR} and ref($params{AUTHOR}) eq 'ARRAY' and $eumm_version < 6.5705) { + $params{META_ADD}->{author}=$params{AUTHOR}; + $params{AUTHOR}=join(', ',@{$params{AUTHOR}}); + } + if ($params{TEST_REQUIRES} and $eumm_version < 6.64) { + $params{BUILD_REQUIRES}={ %{$params{BUILD_REQUIRES} || {}} , %{$params{TEST_REQUIRES}} }; + delete $params{TEST_REQUIRES}; + } + if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { + #EUMM 6.5502 has problems with BUILD_REQUIRES + $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} }; + delete $params{BUILD_REQUIRES}; + } + delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; + delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; + delete $params{META_MERGE} if $eumm_version < 6.46; + delete $params{META_ADD} if $eumm_version < 6.46; + delete $params{LICENSE} if $eumm_version < 6.31; + + WriteMakefile(%params); +} + diff --git a/lib/Tangram.pm b/lib/Tangram.pm index 9d14623..4d30919 100644 --- a/lib/Tangram.pm +++ b/lib/Tangram.pm @@ -2,9 +2,10 @@ package Tangram; +use 5.006; use strict; -use vars qw( $TRACE $DEBUG_LEVEL ); +our ( $TRACE, $DEBUG_LEVEL ); $TRACE = (\*STDOUT, \*STDERR)[$ENV{TANGRAM_TRACE} - 1] || \*STDERR if exists $ENV{TANGRAM_TRACE} && $ENV{TANGRAM_TRACE}; diff --git a/lib/Tangram/Relational.pm b/lib/Tangram/Relational.pm index 4e09509..17c8f9d 100644 --- a/lib/Tangram/Relational.pm +++ b/lib/Tangram/Relational.pm @@ -5,6 +5,7 @@ package Tangram::Relational; use Tangram::Relational::Engine; use Carp qw(cluck); +use 5.006; use strict; sub new { bless { }, shift } diff --git a/lib/Tangram/Schema.pm b/lib/Tangram/Schema.pm index d507dde..62d0b9b 100644 --- a/lib/Tangram/Schema.pm +++ b/lib/Tangram/Schema.pm @@ -5,6 +5,7 @@ package Tangram::Schema; use Tangram::Schema::ClassHash; use Tangram::Schema::Class; +use 5.006; #our, weaken use strict; #our @ISA = qw( SelfLoader ); use Carp; diff --git a/lib/Tangram/Springfield.pm b/lib/Tangram/Springfield.pm index 1f7517e..d1cb15c 100644 --- a/lib/Tangram/Springfield.pm +++ b/lib/Tangram/Springfield.pm @@ -1,5 +1,6 @@ +use 5.006; use strict; package SpringfieldObject; diff --git a/lib/Tangram/Storage.pm b/lib/Tangram/Storage.pm index af74252..8bd5c3b 100644 --- a/lib/Tangram/Storage.pm +++ b/lib/Tangram/Storage.pm @@ -1,5 +1,6 @@ package Tangram::Storage; +use 5.006; use strict; use Tangram::Storage::Statement;