The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
Changes 010
MANIFEST 02
META.json 1012
META.yml 711
Makefile.PL 154
README 1814
lib/Import/Into.pm 1918
maint/Makefile.include 011
maint/bump-version 039
t/import_into.t 06
10 files changed (This is a version diff) 55177
@@ -1,5 +1,15 @@
 Revision history for Import-Into
 
+1.002004 - 2014-07-09
+  - fix prerequisite declarations for older toolchain
+
+1.002003 - 2014-07-09
+  - module loading is now done while importing, making it unnecessary to load
+    them beforehand (RT#96995, Christian Walde)
+
+1.002002 - 2014-05-06
+  - minor metadata updates
+
 1.002001 - 2014-03-04
   - fix tests and Makefile.PL to support perl 5.6
 
@@ -1,5 +1,7 @@
 Changes
 lib/Import/Into.pm
+maint/bump-version
+maint/Makefile.include
 maint/Makefile.PL.include
 Makefile.PL
 MANIFEST			This list of files
@@ -1,10 +1,10 @@
 {
-   "abstract" : "import packages into other packages",
+   "abstract" : "Import packages into other packages",
    "author" : [
       "mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>"
    ],
    "dynamic_config" : 0,
-   "generated_by" : "ExtUtils::MakeMaker version 6.9, CPAN::Meta::Converter version 2.133380",
+   "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141520",
    "license" : [
       "perl_5"
    ],
@@ -20,18 +20,20 @@
       ]
    },
    "prereqs" : {
-      "build" : {
+      "runtime" : {
          "requires" : {
-            "ExtUtils::MakeMaker" : "0"
+            "Module::Runtime" : "0",
+            "perl" : "5.006",
+            "strict" : "0",
+            "warnings" : "0"
          }
       },
-      "configure" : {
+      "test" : {
          "requires" : {
-            "ExtUtils::MakeMaker" : "0"
+            "Exporter" : "0",
+            "Test::More" : "0",
+            "base" : "0"
          }
-      },
-      "runtime" : {
-         "requires" : {}
       }
    },
    "release_status" : "stable",
@@ -46,5 +48,5 @@
          "web" : "http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/Import-Into.git"
       }
    },
-   "version" : "1.002001"
+   "version" : "1.002004"
 }
@@ -1,13 +1,13 @@
 ---
-abstract: 'import packages into other packages'
+abstract: 'Import packages into other packages'
 author:
   - 'mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>'
 build_requires:
-  ExtUtils::MakeMaker: '0'
-configure_requires:
-  ExtUtils::MakeMaker: '0'
+  Exporter: '0'
+  Test::More: '0'
+  base: '0'
 dynamic_config: 0
-generated_by: 'ExtUtils::MakeMaker version 6.9, CPAN::Meta::Converter version 2.133380'
+generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141520'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -17,8 +17,12 @@ no_index:
   directory:
     - t
     - inc
-requires: {}
+requires:
+  Module::Runtime: '0'
+  perl: '5.006'
+  strict: '0'
+  warnings: '0'
 resources:
   bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Import-Into
   repository: git://git.shadowcat.co.uk/p5sagit/Import-Into.git
-version: '1.002001'
+version: '1.002004'
@@ -3,7 +3,7 @@ use warnings FATAL => 'all';
 use ExtUtils::MakeMaker;
 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
 
-WriteMakefile(
+my %WriteMakefileArgs = (
   NAME => 'Import::Into',
   VERSION_FROM => 'lib/Import/Into.pm',
   PREREQ_PM => { },
@@ -24,6 +24,59 @@ WriteMakefile(
           web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Import-Into',
       },
     },
+  },
 
+  META_ADD => {
+    prereqs => {
+      runtime => {
+        requires => {
+          'strict' => '0',
+          'warnings' => '0',
+          'Module::Runtime' => '0',
+          'perl' => '5.006',
+        },
+      },
+      test => {
+        requires => {
+          'Exporter' => '0',
+          'base' => '0',
+          'Test::More' => '0',
+        },
+      },
+    },
   },
+
+  realclean => { FILES => [ 'Distar/', 'MANIFEST*' ] },
 );
+
+my $eumm_version  = eval $ExtUtils::MakeMaker::VERSION;
+
+for (qw(configure build test runtime)) {
+  my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES';
+  next unless exists $WriteMakefileArgs{META_ADD}{prereqs}{$_}
+           or exists $WriteMakefileArgs{$key};
+  my $r = $WriteMakefileArgs{$key} = {
+    %{$WriteMakefileArgs{META_ADD}{prereqs}{$_}{requires} || {}},
+    %{delete $WriteMakefileArgs{$key} || {}},
+  };
+  defined $r->{$_} or delete $r->{$_} for keys %$r;
+}
+
+# dynamic prereqs get added here.
+
+$WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0;
+
+$WriteMakefileArgs{BUILD_REQUIRES} = {
+    %{$WriteMakefileArgs{BUILD_REQUIRES} || {}},
+    %{delete $WriteMakefileArgs{TEST_REQUIRES}}
+} if $eumm_version < 6.63_03;
+
+$WriteMakefileArgs{PREREQ_PM} = {
+    %{$WriteMakefileArgs{PREREQ_PM}},
+    %{delete $WriteMakefileArgs{BUILD_REQUIRES}}
+} if $eumm_version < 6.55_01;
+
+delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
+  if $eumm_version < 6.51_03;
+
+WriteMakefile(%WriteMakefileArgs);
@@ -1,14 +1,11 @@
 NAME
-    Import::Into - import packages into other packages
+    Import::Into - Import packages into other packages
 
 SYNOPSIS
       package My::MultiExporter;
 
       use Import::Into;
 
-      use Thing1 ();
-      use Thing2 ();
-
       # simple
       sub import {
         Thing1->import::into(scalar caller);
@@ -60,8 +57,9 @@ DESCRIPTION
 
 METHODS
   $package->import::into( $target, @arguments );
-    A global method, callable on any package. Imports the given package into
-    $target. @arguments are passed along to the package's import method.
+    A global method, callable on any package. Loads and imports the given
+    package into $target. @arguments are passed along to the package's
+    import method.
 
     $target can be an package name to export to, an integer for the caller
     level to export to, or a hashref with the following options:
@@ -134,7 +132,8 @@ WHY USE THIS MODULE
 
     So, a solution for that is:
 
-      my $sub = eval "package $target; sub { shift->import(\@_) }";
+      use Module::Runtime;
+      my $sub = eval "package $target; sub { use_module(shift)->import(\@_) }";
       $sub->($thing, @import_args);
 
     which means that import is called from the right place for pragmas to
@@ -152,12 +151,12 @@ WHY USE THIS MODULE
       my $sub = eval qq{
         package $target;
       #line $line "$file"
-        sub { shift->import(\@_) }
+        sub { use_module(shift)->import(\@_) }
       };
       $sub->($thing, @import_args);
 
     And you need to switch between these implementations depending on if you
-    are targetting a specific package, or something in your call stack.
+    are targeting a specific package, or something in your call stack.
 
     Remembering all this, however, is excessively irritating. So I wrote a
     module so I didn't have to anymore. Loading Import::Into creates a
@@ -196,17 +195,12 @@ WHY USE THIS MODULE
     <http://shadow.cat/blog/matt-s-trout/madness-with-methods> which covers
     coderef abuse and the "${\...}" syntax.
 
-    Final note: You do still need to ensure that you already loaded $thing -
-    if you're receiving this from a parameter, I recommend using
-    Module::Runtime:
-
-      use Import::Into;
-      use Module::Runtime qw(use_module);
-
-      use_module($thing)->import::into($target, @import_args);
-
     And that's it.
 
+SEE ALSO
+    I gave a lightning talk on this module (and curry and Safe::Isa) at
+    YAPC::NA 2013 <https://www.youtube.com/watch?v=wFXWV2yY7gE&t=46m05s>.
+
 ACKNOWLEDGEMENTS
     Thanks to Getty for asking "how can I get "use strict; use warnings;"
     turned on for all consumers of my code?" and then "why is this not a
@@ -218,6 +212,8 @@ AUTHOR
 CONTRIBUTORS
     haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
 
+    Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@gmail.com>
+
 COPYRIGHT
     Copyright (c) 2012 the Import::Into "AUTHOR" and "CONTRIBUTORS" as
     listed above.
@@ -2,8 +2,9 @@ package Import::Into;
 
 use strict;
 use warnings FATAL => 'all';
+use Module::Runtime;
 
-our $VERSION = '1.002001'; # 1.2.1
+our $VERSION = '1.002004';
 
 sub _prelude {
   my $target = shift;
@@ -24,8 +25,9 @@ sub _prelude {
 sub _make_action {
   my ($action, $target) = @_;
   my $version = ref $target && $target->{version};
-  my $ver_check = $version ? '$_[0]->VERSION($version);' : '';
-  eval _prelude($target).qq{sub { $ver_check shift->$action(\@_) }}
+  my $ver_check = $version ? ', $version' : '';
+  eval _prelude($target)
+    . qq{sub { Module::Runtime::use_module( shift$ver_check )->$action(\@_) }}
     or die "Failed to build action sub to ${action} for ${target}: $@";
 }
 
@@ -45,7 +47,7 @@ __END__
 
 =head1 NAME
 
-Import::Into - import packages into other packages
+Import::Into - Import packages into other packages
 
 =head1 SYNOPSIS
 
@@ -53,9 +55,6 @@ Import::Into - import packages into other packages
 
   use Import::Into;
 
-  use Thing1 ();
-  use Thing2 ();
-
   # simple
   sub import {
     Thing1->import::into(scalar caller);
@@ -109,8 +108,8 @@ C<Import::Into> provides global methods to make this painless.
 
 =head2 $package->import::into( $target, @arguments );
 
-A global method, callable on any package.  Imports the given package into
-C<$target>.  C<@arguments> are passed along to the package's import method.
+A global method, callable on any package.  Loads and imports the given package
+into C<$target>.  C<@arguments> are passed along to the package's import method.
 
 C<$target> can be an package name to export to, an integer for the
 caller level to export to, or a hashref with the following options:
@@ -192,7 +191,8 @@ an exporter and a pragma.
 
 So, a solution for that is:
 
-  my $sub = eval "package $target; sub { shift->import(\@_) }";
+  use Module::Runtime;
+  my $sub = eval "package $target; sub { use_module(shift)->import(\@_) }";
   $sub->($thing, @import_args);
 
 which means that import is called from the right place for pragmas to take
@@ -209,12 +209,12 @@ in the directive then need to be fetched using C<caller>:
   my $sub = eval qq{
     package $target;
   #line $line "$file"
-    sub { shift->import(\@_) }
+    sub { use_module(shift)->import(\@_) }
   };
   $sub->($thing, @import_args);
 
 And you need to switch between these implementations depending on if you are
-targetting a specific package, or something in your call stack.
+targeting a specific package, or something in your call stack.
 
 Remembering all this, however, is excessively irritating. So I wrote a module
 so I didn't have to anymore. Loading L<Import::Into> creates a global method
@@ -252,15 +252,12 @@ For more craziness of this order, have a look at the article I wrote at
 L<http://shadow.cat/blog/matt-s-trout/madness-with-methods> which covers
 coderef abuse and the C<${\...}> syntax.
 
-Final note: You do still need to ensure that you already loaded C<$thing> - if
-you're receiving this from a parameter, I recommend using L<Module::Runtime>:
-
-  use Import::Into;
-  use Module::Runtime qw(use_module);
+And that's it.
 
-  use_module($thing)->import::into($target, @import_args);
+=head1 SEE ALSO
 
-And that's it.
+I gave a lightning talk on this module (and L<curry> and L<Safe::Isa>) at
+L<YAPC::NA 2013|https://www.youtube.com/watch?v=wFXWV2yY7gE&t=46m05s>.
 
 =head1 ACKNOWLEDGEMENTS
 
@@ -276,6 +273,8 @@ mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
 
 haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
 
+Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@gmail.com>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2012 the Import::Into L</AUTHOR> and L</CONTRIBUTORS>
@@ -0,0 +1,11 @@
+bump:
+	maint/bump-version
+	rm Makefile
+bumpminor:
+	maint/bump-version minor
+	rm Makefile
+bumpmajor:
+	maint/bump-version major
+	rm Makefile
+upload: $(DISTVNAME).tar$(SUFFIX)
+	cpan-upload $<
@@ -0,0 +1,39 @@
+#!/usr/bin/env perl
+
+use 5.010;
+use strict;
+use warnings FATAL => 'all';
+use autodie;
+
+chomp(my $LATEST = qx(grep '^[0-9]' Changes | head -1 | awk '{print \$1}'));
+
+my @parts = map { m/(\d{1,3})/g } split /\./, $LATEST;
+push @parts, 0, 0;
+
+my $OLD_DECIMAL = sprintf('%i.%03i%03i', @parts);
+
+my %bump_part = (major => 0, minor => 1, bugfix => 2);
+
+my $bump_this = 
+  $bump_part{$ARGV[0]||'bugfix'}
+    // die "no idea which part to bump - $ARGV[0] means nothing to me";
+
+my @new_parts = @parts;
+
+$new_parts[$bump_this]++;
+
+my $NEW_DECIMAL = sprintf('%i.%03i%03i', @new_parts);
+
+my @PM_FILES = ( 'lib/Import/Into.pm' );
+
+foreach my $filename (@PM_FILES) {
+  warn "Bumping $OLD_DECIMAL -> $NEW_DECIMAL in $filename\n";
+
+  my $file = do { local (@ARGV, $/) = ($filename); <> };
+
+  $file =~ s/(?<=\$VERSION = ')${\quotemeta $OLD_DECIMAL}/${NEW_DECIMAL}/;
+
+  open my $out, '>', $filename;
+
+  print $out $file;
+}
@@ -12,6 +12,8 @@ BEGIN {
 
   sub thing { 'thing' }
 
+  $INC{"MyExporter.pm"} = 1;
+
   package MultiExporter;
 
   use Import::Into;
@@ -84,3 +86,7 @@ is $checkcaller[0], 'ExplicitPackage',  'import with hash has correct package';
 is $checkcaller[1], 'explicit-file.pl', 'import with hash has correct file';
 is $checkcaller[2], 42,                 'import with hash has correct line';
 is $checkversion, 219,                  'import with hash has correct version';
+
+ok( !IPC::Open3->can("open3"), "IPC::Open3 is unloaded" );
+IPC::Open3->import::into("TestPackage");
+ok( TestPackage->can("open3"), "IPC::Open3 was use'd and import::into'd" );