NAME

Wallflower - Stick Plack applications to the wallpaper

SYNOPSIS

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;

DESCRIPTION

Given a URL and a Plack application, a Wallflower object will save the corresponding response to a file.

METHODS

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. By default, will use the current directory.

env

Additional environment key/value pairs.

index

The default file name for URL ending with a /. The default value is index.html.

get( $url )

Perform a GET request for $url through the application, and in case of success, save the result to a file, whose name is obtained via the target() method.

$url may be either a string or a URI object, representing an absolute URL (the path must start with a /). The scheme, host and port elements are optional. The query string will be ignored.

The return value is very similar those of a Plack application:

[ $status, $headers, $file ]

where $status and $headers are those return by the application itself for the given $url, and $file is the name of the file where the content has been saved.

target( $uri )

Return the filename where the content of $uri will be saved.

The path component of $uri is concatenated to the destination attribute. If the URI ends with a /, the index attribute is appended to create a file path.

Note that target() assumes $uri is a URI object, and that it must be absolute.

ACCESSORS

Accessors (that are both getters and setters) exist for all parameters to new() and bear the same name.

AUTHOR

Philippe Bruhat (BooK)

COPYRIGHT

Copyright 2010-2012 Philippe Bruhat (BooK), all rights reserved.

LICENSE

This program is free software and is published under the same terms as Perl itself.