[Rt-commit] r2878 - in DBIx-SearchBuilder/trunk: .
inc/Module/Install t
jesse at bestpractical.com
jesse at bestpractical.com
Thu May 12 19:31:35 EDT 2005
Author: jesse
Date: Thu May 12 19:31:34 2005
New Revision: 2878
Added:
DBIx-SearchBuilder/trunk/inc/Module/Install/AutoInstall.pm
DBIx-SearchBuilder/trunk/t/01nocap_api.t
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
Log:
r16512 at hualien: jesse | 2005-05-13 00:28:54 +0100
* Tests for the no-capitalization API
Added: DBIx-SearchBuilder/trunk/inc/Module/Install/AutoInstall.pm
==============================================================================
--- (empty file)
+++ DBIx-SearchBuilder/trunk/inc/Module/Install/AutoInstall.pm Thu May 12 19:31:34 2005
@@ -0,0 +1,62 @@
+#line 1 "inc/Module/Install/AutoInstall.pm - /usr/local/share/perl/5.8.4/Module/Install/AutoInstall.pm"
+package Module::Install::AutoInstall;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+sub AutoInstall { $_[0] }
+
+sub run {
+ my $self = shift;
+ $self->auto_install_now(@_);
+}
+
+sub write {
+ my $self = shift;
+ $self->auto_install(@_);
+}
+
+sub auto_install {
+ my $self = shift;
+ return if $self->{done}++;
+
+# ExtUtils::AutoInstall Bootstrap Code, version 7.
+AUTO:{my$p='ExtUtils::AutoInstall';my$v=0.49;$p->VERSION||0>=$v
+or+eval"use $p $v;1"or+do{my$e=$ENV{PERL_EXTUTILS_AUTOINSTALL};
+(!defined($e)||$e!~m/--(?:default|skip|testonly)/and-t STDIN or
+eval"use ExtUtils::MakeMaker;WriteMakefile(PREREQ_PM=>{'$p',$v}
+);1"and exit)and print"==> $p $v required. Install it from CP".
+"AN? [Y/n] "and<STDIN>!~/^n/i and print"*** Installing $p\n"and
+do{if (eval '$>' and lc(`sudo -V`) =~ /version/){system('sudo',
+$^X,"-MCPANPLUS","-e","CPANPLUS::install $p");eval"use $p $v;1"
+||system('sudo', $^X, "-MCPAN", "-e", "CPAN::install $p")}eval{
+require CPANPLUS;CPANPLUS::install$p};eval"use $p $v;1"or eval{
+require CPAN;CPAN::install$p};eval"use $p $v;1"||die"*** Please
+manually install $p $v from cpan.org first...\n"}}}
+
+ # Flatten array of arrays into a single array
+ my @core = map @$_, map @$_, grep ref,
+ $self->build_requires, $self->requires;
+
+ while ( @core and @_ > 1 and $_[0] =~ /^-\w+$/ ) {
+ push @core, splice(@_, 0, 2);
+ }
+
+ ExtUtils::AutoInstall->import(
+ (@core ? (-core => \@core) : ()), @_, $self->features
+ );
+
+ $self->makemaker_args( ExtUtils::AutoInstall::_make_args() );
+
+ my $class = ref($self);
+ $self->postamble(
+ "# --- $class section:\n" .
+ ExtUtils::AutoInstall::postamble()
+ );
+}
+
+sub auto_install_now {
+ my $self = shift;
+ $self->auto_install;
+ ExtUtils::AutoInstall::do_install();
+}
+
+1;
Added: DBIx-SearchBuilder/trunk/t/01nocap_api.t
==============================================================================
--- (empty file)
+++ DBIx-SearchBuilder/trunk/t/01nocap_api.t Thu May 12 19:31:34 2005
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use Test::More;
+BEGIN { require "t/utils.pl" }
+
+use vars qw(@SPEC_METHODS @MODULES);
+my @SPEC_METHODS = qw(AUTOLOAD DESTROY CLONE);
+my @MODULES = qw(DBIx::SearchBuilder DBIx::SearchBuilder::Record);
+
+if( not eval { require Devel::Symdump } ) {
+ plan skip_all => 'Devel::Symdump is not installed';
+} elsif( not eval { require capitalization } ) {
+ plan skip_all => 'capitalization pragma is not installed';
+} else {
+ plan tests => scalar @MODULES;
+}
+
+foreach my $mod( @MODULES ) {
+ eval "require $mod";
+ my $dump = Devel::Symdump->new($mod);
+ my @methods = ();
+ foreach my $method (map { s/^\Q$mod\E:://; $_ } $dump->functions) {
+ push @methods, $method;
+
+ my $nocap = nocap( $method );
+ push @methods, $nocap if $nocap ne $method;
+ }
+ can_ok( $mod, @methods );
+}
+
+sub nocap
+{
+ my $method = shift;
+ return $method if grep( { $_ eq $method } @SPEC_METHODS );
+ $method =~ s/(?<=[a-z])([A-Z]+)/"_" . lc($1)/eg;
+ return lc($method);
+}
+
More information about the Rt-commit
mailing list