Fix unicodeness in POD
[p5sagit/Sub-Exporter-Progressive.git] / lib / Sub / Exporter / Progressive.pm
index d945936..5cb4e7d 100644 (file)
@@ -1,11 +1,9 @@
 package Sub::Exporter::Progressive;
 
-# ABSTRACT: Only use Sub::Exporter if you need it
-
 use strict;
 use warnings;
 
-# VERSION
+our $VERSION = '0.001005';
 
 use List::Util 'first';
 
@@ -15,36 +13,32 @@ sub import {
    my $inner_target = caller(0);
    my ($TOO_COMPLICATED, $export_data) = sub_export_options(@args);
 
-   if ($TOO_COMPLICATED) {
-      warn <<'WARNING';
+   die <<'DEATH' if $TOO_COMPLICATED;
 You are using Sub::Exporter::Progressive, but the features your program uses from
 Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well
 just use vanilla Sub::Exporter
-WARNING
-      require Sub::Exporter;
-      goto \&Sub::Exporter::import;
-   }
-   else {
-      my $full_exporter;
-      no strict;
-      @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}};
-      @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}};
-      *{"${inner_target}::import"} = sub {
-         use strict;
-         my ($self, @args) = @_;
-
-         if (first { ref || !m/^\w+$/ } @args) {
-            require Sub::Exporter;
-            $full_exporter ||=
-               Sub::Exporter::build_exporter($export_data->{original});
-
-            goto $full_exporter;
-         } else {
-            require Exporter;
-            goto \&Exporter::import;
-         }
-      };
-   }
+DEATH
+
+   my $full_exporter;
+   no strict;
+   @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}};
+   @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}};
+   *{"${inner_target}::import"} = sub {
+      use strict;
+      my ($self, @args) = @_;
+
+      if (first { ref || !m/^\w+$/ } @args) {
+         die 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed'
+            unless eval { require Sub::Exporter };
+         $full_exporter ||=
+            Sub::Exporter::build_exporter($export_data->{original});
+
+         goto $full_exporter;
+      } else {
+         require Exporter;
+         goto \&Exporter::import;
+      }
+   };
 }
 
 sub sub_export_options {
@@ -81,7 +75,7 @@ sub sub_export_options {
             last OPTIONS
          }
       }
-      @defaults = @exports if $defaults[0] eq '-all';
+      @defaults = @exports if @defaults && $defaults[0] eq '-all';
    }
 
    return $TOO_COMPLICATED, {
@@ -93,6 +87,12 @@ sub sub_export_options {
 
 1;
 
+=encoding utf8
+
+=head1 NAME
+
+Sub::Exporter::Progressive - Only use Sub::Exporter if you need it
+
 =head1 SYNOPSIS
 
  package Syntax::Keyword::Gather;
@@ -127,3 +127,25 @@ Note that this module will export C<@EXPORT> and C<@EXPORT_OK> package
 variables for C<Exporter> to work.  Additionally, if your package uses advanced
 C<Sub::Exporter> features like currying, this module will only ever use
 C<Sub::Exporter>, so you might as well use it directly.
+
+=head1 AUTHOR
+
+frew - Arthur Axel Schmidt (cpan:FREW) <frioux+cpan@gmail.com>
+
+=head1 CONTRIBUTORS
+
+ilmari - Dagfinn Ilmari MannsÃ¥ker (cpan:ILMARI) <ilmari@ilmari.org>
+
+mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2012 the Sub::Exporter::Progressive L</AUTHOR> and
+L</CONTRIBUTORS> as listed above.
+
+=head1 LICENSE
+
+This library is free software and may be distributed under the same terms
+as perl itself.
+
+=cut