Wallflower - Stick Plack applications to the wallpaper
version 1.015
use Wallflower; my $w = Wallflower->new( application => $app, # a PSGI app destination => $dir, # target directory ); # dump all URL from $app to files in $dir $w->get( $_ ) for @urls;
Given a URL and a Plack application, a Wallflower object will save the corresponding response to a file.
my $w = Wallflower->new( %args );
Create a new Wallflower object.
The parameters are:
application
The PSGI/Plack application, as a CODE reference.
This parameter is required.
destination
The destination directory. Default is the current directory.
The destination directory must exist.
env
Additional environment key/value pairs.
index
The default filename for URLs ending in /. The default value is index.html.
/
url
URL where the root of the application will be reachable in production.
If the URL has a path component, the application will be "mounted" at that position.
my $response = $w->get( $url );
Perform a GET request for $url through the application, and if successful, save the result to a filename derived from $url by the target() method.
GET
$url
target()
$url can be either a string or a URI object, representing an absolute URL (the path must start with a /). The scheme, host, port, and query string are ignored if present.
The return value is very similar to a Plack application response:
[ $status, $headers, $file ]
where $status and $headers are those returned by the application itself for the given $url, and $file is the name of the file where the content has been saved.
$status
$headers
$file
If an error is encountered when trying to open the file, $status will be set to 999 (an invalid HTTP status code), and a warning will be emitted.
999
If the application sends the Last-Modified header in its response, the modification date of the target file will be modified accordingly.
Last-Modified
If a file exists at the location pointed to by the target, a If-Modified-Since header is added to the Plack environment, with the modification timestamp for this file as the value. If the application sends a 304 Not modified in response, the target file will not be modified.
If-Modified-Since
304 Not modified
my $target = $w->target($uri);
Return the filename where the content of $uri will be saved.
$uri
The path component of $uri is concatenated to the destination attribute. If the URL ends with a /, the index attribute is appended to create a file path.
path
Note that target() assumes $uri is a URI object, and that it must be absolute.
Accessors (getters only) exist for all parameters to new() and bear the same name.
new()
Philippe Bruhat (BooK) <book@cpan.org>
Copyright 2012-2018 by Philippe Bruhat (BooK).
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install App::Wallflower, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Wallflower
CPAN shell
perl -MCPAN -e shell install App::Wallflower
For more information on module installation, please visit the detailed CPAN module installation guide.