summaryrefslogtreecommitdiff
path: root/cpan/File-Fetch
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-07-06 22:17:46 +0100
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-07-12 09:34:06 +0100
commitea8337ba3382e650133fb4941d3d1372437b631e (patch)
tree249cab911edfc6a7a2a6d18113c03a4300b0c7d4 /cpan/File-Fetch
parent122b9bf4fd0633cb11e00a8136e8039f0a14ecd6 (diff)
downloadperl-ea8337ba3382e650133fb4941d3d1372437b631e.tar.gz
Update File-Fetch to CPAN version 0.36
[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)
Diffstat (limited to 'cpan/File-Fetch')
-rw-r--r--cpan/File-Fetch/lib/File/Fetch.pm21
1 files changed, 17 insertions, 4 deletions
diff --git a/cpan/File-Fetch/lib/File/Fetch.pm b/cpan/File-Fetch/lib/File/Fetch.pm
index 8a540a41b7..99f1f795fe 100644
--- a/cpan/File-Fetch/lib/File/Fetch.pm
+++ b/cpan/File-Fetch/lib/File/Fetch.pm
@@ -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;