Author: dagolden
Date: Wed Dec 16 21:16:45 2009
New Revision: 13664

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/t/lib/DistGen.pm
   Module-Build/trunk/t/properties/module_name.t

Log:
Detect module_name from dist_name or dist_version_from only


Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Wed Dec 16 21:16:45 2009
@@ -4,6 +4,9 @@
 
  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

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Wed Dec 16 21:16:45 2009
@@ -1090,7 +1090,7 @@
     $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";

Modified: Module-Build/trunk/t/lib/DistGen.pm
==============================================================================
--- Module-Build/trunk/t/lib/DistGen.pm (original)
+++ Module-Build/trunk/t/lib/DistGen.pm Wed Dec 16 21:16:45 2009
@@ -312,7 +312,7 @@
 
 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 @@
 =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.

Modified: Module-Build/trunk/t/properties/module_name.t
==============================================================================
--- Module-Build/trunk/t/properties/module_name.t       (original)
+++ Module-Build/trunk/t/properties/module_name.t       Wed Dec 16 21:16:45 2009
@@ -10,22 +10,26 @@
 # 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"
 );
 
 #--------------------------------------------------------------------------#

Reply via email to