The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

File::AptFetch::Simple - simplifing wrapper above F::AF

SYNOPSIS

# TODO:

DESCRIPTION

# TODO:

API

request()

Has two modes: constructor and utility. In either case a F::AF::S blessed object is returned. Unless base F::AF object reported any problem, then croaks.

Constructor Mode
    # complete CM -- cCM
    $fafs = File::AptFetch::Simple->request( { %options }, @uris );
    # simplified CM -- sCM
    $fafs = File::AptFetch::Simple->request( $method, @uris );

%options are some parameters what will be somehow processed upon construction and mostly saved for later use. However, if defaults are ok then only one required parameter (that is $options{method}) can be passed as first scalar. Known keys (and $method) are described a bit later.

@uris is a list of scalars. If empty, then constructor just blows through construction and returns (it doesn't mean it's in vein, the requested method is initialized). In detail description of %options a bit later.

Utility Mode
    # complete UM -- cUM
    $fafs->request( { %options }, @uris );
    # simplified UM -- sUM
    $fafs->request( @uris );

If first argument isn't a HASH, then reqeust() believes that %options is omitted. However, there's a quirk. Due implementation idiosyncrasy, if first argument is FALSE it's ignored completely. Consider those are reserved (even if they are not). Are we cool now?

If @uris is empty then silently succeedes. In detail description of @uris a bit later.

%options
$options{location}

Optional. Defaults to CWD. Sets dirname where acquired file will be placed. Set in cUM leaves set in cCM (if any) intact.

(caveat) When applied $options{location} will be expanded to be absolute (as required by APT method API). However, that expansion is performed with each request() and, as mentioned above, transparently. Thus if *you* set $options{location} to non-absolute dirname, than request() once, then *your* script changes CWD, then request() again, then those request()s will put results in two different dirctories.

(bug) Neither checks nor makes sure $options{location} is anyway usable.

$options{method}
$method

In [cs]CM required, otherwise silently ignored. If there's no such method installed croaks immeidately. file is silengtly replaced with copy; copy is passed through.

(note) You should understand. F::AF::S is a convenience wrapper about F::AF. Second, F::AF interfaces with APT methods what are all Debian. It's reasonable to foresee that URIs will be constructed from those found in /etc/apt/sources.list (and, probably, nothing else). But there's no URI of copy: type, you should do that substitution yourself. Else F::AF::S could do it for you.

@uris

Requirements for %source described in F::AF still apply. Shortly: full pathnames, no schema, one (local mehtods) or two (remote methods) leading slashes. (bug) That's not convinient in any reasonable way.

$target (of underlying request() of F::AF) isn't required. It's constructed from requested URI: current value of $options{location} will be concatenated with a basename of currently processed $uris[]. The separator is slash. (What else, it's *nix, for kernel's sake.) ((bug) As a matter of fact there's no way it can be anyhow affected.

SEE ALSO

File::AptFetch

AUTHOR

Eric Pozharski, <whynot@cpan.org>

COPYRIGHT & LICENSE

Copyright 2014 by Eric Pozharski

This library is free in sense: AS-IS, NO-WARANRTY, HOPE-TO-BE-USEFUL. This library is released under GNU LGPLv3.