Subject: | #PATCH#: cross-platform handling of typemap creation |
The why the typemap file name is created is not robust cross platform; it
wouldn't work on my Windows machine because paths have '\' instead of '/'.
Instead of doing a regex replacement on the filename, it is better to let
some other module worry about correct naming. This patch fixes the problem
using Class::Path. The patch is for XSimple.pm.
Subject: | fixTypenameFileName.diff |
diff --git a/lib/Module/Starter/XSimple.pm b/lib/Module/Starter/XSimple.pm
index 79b3684..5fbe4e3 100644
--- a/lib/Module/Starter/XSimple.pm
+++ b/lib/Module/Starter/XSimple.pm
@@ -7,6 +7,7 @@ use version; $VERSION = qv('0.0.1');
use warnings;
use strict;
use Carp;
+use Path::Class;
# Other recommended modules (uncomment to use):
# use IO::Prompt;
@@ -163,11 +164,13 @@ sub _create_typemap {
my ($manifest_file, $typemap_file) =
$self->module_path_create($module, '');
- $manifest_file =~ s:/\w+$:/typemap:;
- $typemap_file =~ s:/\w+$:/typemap:;
+ #change typemap file name to 'typemap'
+ $manifest_file = Path::Class::File->new($manifest_file)->parent->file('typemap');
+ $typemap_file = Path::Class::File->new($typemap_file)->parent->file('typemap');
open( my $fh, ">", $typemap_file )
or die "Can't create $typemap_file: $!\n";
+ print "open $typemap_file to print typemap to\n";
print $fh $self->typemap_guts($module);
close $fh;
$self->progress( "Created typemap" );