bump version
[p5sagit/App-FatPacker.git] / lib / App / FatPacker.pm
index ec006a4..84f3910 100644 (file)
@@ -14,7 +14,7 @@ use File::Copy qw(copy);
 use File::Path qw(mkpath rmtree);
 use B qw(perlstring);
 
-our $VERSION = '0.009018'; # 0.009.017
+our $VERSION = '0.010002'; # 0.10.2
 
 $VERSION = eval $VERSION;
 
@@ -117,7 +117,8 @@ sub trace {
   my $output = $opts{output};
   my $trace_opts = join ',', $output||'>&STDOUT', @{$opts{use}||[]};
 
-  local $ENV{PERL5OPT} = '-MApp::FatPacker::Trace='.$trace_opts;
+  local $ENV{PERL5OPT} = join ' ',
+    ($ENV{PERL5OPT}||()), '-MApp::FatPacker::Trace='.$trace_opts;
 
   my @args = @{$opts{args}||[]};
 
@@ -142,8 +143,11 @@ sub script_command_packlists_for {
 sub packlists_containing {
   my ($self, $targets) = @_;
   my @targets = @$targets;
-  foreach my $t (@targets) {
-    require $t;
+  {
+    local @INC = ('lib', @INC);
+    foreach my $t (@targets) {
+      require $t;
+    }
   }
   my @search = grep -d $_, map catdir($_, 'auto'), @INC;
   my %pack_rev;
@@ -268,24 +272,37 @@ sub fatpack_end {
   return stripspace <<'  END_END';
     s/^  //mg for values %fatpacked;
 
-    unshift @INC, sub {
-      if (my $fat = $fatpacked{$_[1]}) {
-        if ($] < 5.008) {
-          return sub {
-            return 0 unless length $fat;
-            $fat =~ s/^([^\n]*\n?)//;
-            $_ = $1;
-            return 1;
-          };
+    my $class = 'FatPacked::'.(0+\%fatpacked);
+    no strict 'refs';
+    *{"${class}::files"} = sub { keys %{$_[0]} };
+
+    if ($] < 5.008) {
+      *{"${class}::INC"} = sub {
+         if (my $fat = $_[0]{$_[1]}) {
+           return sub {
+             return 0 unless length $fat;
+             $fat =~ s/^([^\n]*\n?)//;
+             $_ = $1;
+             return 1;
+           };
+         }
+         return;
+      };
+    }
+
+    else {
+      *{"${class}::INC"} = sub {
+        if (my $fat = $_[0]{$_[1]}) {
+          open my $fh, '<', \$fat
+            or die "FatPacker error loading $_[1] (could be a perl installation issue?)";
+          return $fh;
         }
-        open my $fh, '<', \$fat
-          or die "FatPacker error loading $_[1] (could be a perl installation issue?)";
-        return $fh;
-      }
-      return
-    };
+        return;
+      };
+    }
 
-    } # END OF FATPACK CODE
+    unshift @INC, bless \%fatpacked, $class;
+  } # END OF FATPACK CODE
   END_END
 }
 
@@ -295,7 +312,7 @@ sub fatpack_code {
     (my $stub = $_) =~ s/\.pm$//;
     my $name = uc join '_', split '/', $stub;
     my $data = $files->{$_}; $data =~ s/^/  /mg; $data =~ s/(?<!\n)\z/\n/;
-    '$fatpacked{'.perlstring($_).qq!} = <<'${name}';\n!
+    '$fatpacked{'.perlstring($_).qq!} = '#line '.(1+__LINE__).' "'.__FILE__."\\"\\n".<<'${name}';\n!
     .qq!${data}${name}\n!;
   } sort keys %$files;
 
@@ -321,7 +338,7 @@ Or, with more step-by-step control:
 
 See the documentation for the L<fatpack> script itself for more information.
 
-The programmatic API for this code is not yet fully decided, hence the 0.9
+The programmatic API for this code is not yet fully decided, hence the 0.x
 release version. Expect that to be cleaned up for 1.0.
 
 =head1 SEE ALSO
@@ -330,7 +347,7 @@ L<article for Perl Advent 2012|http://www.perladvent.org/2012/2012-12-14.html>
 
 =head1 SUPPORT
 
-Your current best avenue is to come annoy annoy mst on #toolchain on
+Your current best avenue is to come annoy mst on #toolchain on
 irc.perl.org. There should be a non-IRC means of support by 1.0.
 
 =head1 AUTHOR
@@ -355,6 +372,12 @@ ether - Karen Etheridge (cpan:ETHER) <ether@cpan.org>
 
 Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@googlemail.com>
 
+dolmen - Olivier MenguĂ© (cpan:DOLMEN) <dolmen@cpan.org>
+
+djerius - Diab Jerius (cpan:DJERIUS) <djerius@cpan.org>
+
+haarg - Graham Knop (cpan:HAARG> <haarg@haarg.org>
+
 Many more people are probably owed thanks for ideas. Yet
 another doc nit to fix.