Update File-Fetch to CPAN version 0.36
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Fri, 6 Jul 2012 21:17:46 +0000 (22:17 +0100)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Thu, 12 Jul 2012 08:34:06 +0000 (09:34 +0100)
  [DELTA]

  Changes for 0.36        Thu Jun 28 13:41:31 2012
  =================================================
  * Added 'file_default' option for URLs that do
    not have a file component (Andrew Kirkpatrick)

Porting/Maintainers.pl
cpan/File-Fetch/lib/File/Fetch.pm

index 0b30770..3f0ce08 100755 (executable)
@@ -807,7 +807,7 @@ use File::Glob qw(:case);
 
     'File::Fetch' => {
         'MAINTAINER'   => 'kane',
-        'DISTRIBUTION' => 'BINGOS/File-Fetch-0.34.tar.gz',
+        'DISTRIBUTION' => 'BINGOS/File-Fetch-0.36.tar.gz',
         'FILES'        => q[cpan/File-Fetch],
         'UPSTREAM'     => 'cpan',
     },
index 8a540a4..99f1f79 100644 (file)
@@ -22,7 +22,7 @@ use vars    qw[ $VERBOSE $PREFER_BIN $FROM_EMAIL $USER_AGENT
                 $FTP_PASSIVE $TIMEOUT $DEBUG $WARN
             ];
 
-$VERSION        = '0.34';
+$VERSION        = '0.36';
 $VERSION        = eval $VERSION;    # avoid warnings with development releases
 $PREFER_BIN     = 0;                # XXX TODO implement
 $FROM_EMAIL     = 'File-Fetch@example.com';
@@ -139,6 +139,13 @@ The path from the uri, will be at least a single '/'.
 The name of the remote file. For the local file name, the
 result of $ff->output_file will be used.
 
+=item $ff->file_default
+
+The name of the default local file, that $ff->output_file falls back to if
+it would otherwise return no filename. For example when fetching a URI like
+http://www.abc.net.au/ the contents retrieved may be from a remote file called
+'index.html'. The default value of this attribute is literally 'file_default'.
+
 =cut
 
 
@@ -156,6 +163,7 @@ result of $ff->output_file will be used.
         uri             => { required => 1 },
         vol             => { default => '' }, # windows for file:// uris
         share           => { default => '' }, # windows for file:// uris
+        file_default    => { default => 'file_default' },
         _error_msg      => { no_override => 1 },
         _error_msg_long => { no_override => 1 },
     };
@@ -182,7 +190,7 @@ result of $ff->output_file will be used.
                 "Hostname required when fetching from '%1'",$args->scheme));
         }
 
-        for (qw[path file]) {
+        for (qw[path]) {
             unless( $args->$_() ) { # 5.5.x needs the ()
                 return $class->_error(loc("No '%1' specified",$_));
             }
@@ -212,6 +220,8 @@ sub output_file {
 
     $file =~ s/\?.*$//g;
 
+    $file ||= $self->file_default;
+
     return $file;
 }
 
@@ -267,9 +277,10 @@ sub new {
     my $class = shift;
     my %hash  = @_;
 
-    my ($uri);
+    my ($uri, $file_default);
     my $tmpl = {
-        uri => { required => 1, store => \$uri },
+        uri          => { required => 1, store => \$uri },
+        file_default => { required => 0, store => \$file_default },
     };
 
     check( $tmpl, \%hash ) or return;
@@ -277,6 +288,8 @@ sub new {
     ### parse the uri to usable parts ###
     my $href    = $class->_parse_uri( $uri ) or return;
 
+    $href->{file_default} = $file_default if $file_default;
+
     ### make it into a FFI object ###
     my $ff      = $class->_create( %$href ) or return;