Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Detect module_name from dist_name or dist_version_from only

git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@13664 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information...
commit 51f69e0b115055cee52cb220b3541153bc7fea9b 1 parent 86cdbe9
@dagolden dagolden authored
View
3  Changes
@@ -4,6 +4,9 @@ Revision history for Perl extension Module::Build.
Bug fixes:
+ - If not set, the 'module_name' is detected from 'dist_version_from'
+ or from 'dist_name'. The directory is no longer used.
+
- The 'share_dir' property no longer defaults to 'share' and must be
explicitly set instead; this fixes problems for CPAN distributions that
already have a 'share' directory for whatever reason
View
2  lib/Module/Build/Base.pm
@@ -1090,7 +1090,7 @@ sub _guess_module_name {
$p->{module_name} = $mi->name;
}
else {
- my $mod_path = my $mod_name = File::Basename::basename($self->base_dir);
+ my $mod_path = my $mod_name = $p->{dist_name};
$mod_name =~ s{-}{::}g;
$mod_path =~ s{-}{/}g;
$mod_path .= ".pm";
View
11 t/lib/DistGen.pm
@@ -312,7 +312,7 @@ sub name { shift()->{name} }
sub dirname {
my $self = shift;
- my $dist = join( '-', split( /::/, $self->{name} ) );
+ my $dist = $self->{distdir} || join( '-', split( /::/, $self->{name} ) );
return File::Spec->catdir( $self->{dir}, $dist );
}
@@ -645,14 +645,19 @@ dist name.
=item dir
The (parent) directory in which to create the distribution directory. The
-distribution will be created under this according to the "dist" form of C<name>
-(e.g. "Foo-Bar".) Defaults to a temporary directory.
+distribution will be created under this according to C<distdir> parameter
+below. Defaults to a temporary directory.
$dist = DistGen->new( dir => '/tmp/MB-test' );
$dist->regen;
# distribution files have been created in /tmp/MB-test/Simple
+=item distdir
+
+The name of the distribution directory to create. Defaults to the dist form of
+C<name>, e.g. 'Foo-Bar' if C<name> is 'Foo::Bar'.
+
=item xs
If true, generates an XS based module.
View
14 t/properties/module_name.t
@@ -10,22 +10,26 @@ plan tests => 4;
# Ensure any Module::Build modules are loaded from correct directory
blib_load('Module::Build');
-# enter the directory and generate the skeleton files
-my $dist = DistGen->new( name => "Not::So::Simple" )->chdir_in;
+my $dist;
#--------------------------------------------------------------------------#
-# try getting module_name from dist directory name
+# try getting module_name from dist_name
#--------------------------------------------------------------------------#
+$dist = DistGen->new(
+ name => "Not::So::Simple",
+ distdir => 'Random-Name',
+)->chdir_in;
+
$dist->change_build_pl(
- dist_name => 'Random-Name',
+ dist_name => 'Not-So-Simple',
dist_version => 1,
)->regen;
my $mb = $dist->new_from_context();
isa_ok( $mb, "Module::Build" );
is( $mb->module_name, "Not::So::Simple",
- "module_name guessed from directory name"
+ "module_name guessed from dist_name"
);
#--------------------------------------------------------------------------#
Please sign in to comment.
Something went wrong with that request. Please try again.