App-Followme

 view release on metacpan or  search on metacpan

lib/App/Followme/UploadSite.pm  view on Meta::CPAN

# Read the default parameter values

sub parameters {
    my ($pkg) = @_;

    return (
            verbose => 0,
            max_errors => 5,
            remote_url => '',
            hash_file => 'upload.hash',
            credentials => 'upload.cred',
            state_directory => '_state',
            data_pkg => 'App::Followme::UploadData',
            upload_pkg => 'App::Followme::UploadFtp',
           );
}

#----------------------------------------------------------------------
# Upload changed files in a directory tree

sub run {

lib/App/Followme/UploadSite.pm  view on Meta::CPAN


#----------------------------------------------------------------------
# GET_WORD -- Say the secret word, the duck comes down and you win $100

sub get_word {
    my ($self) = @_;

    my $filename = catfile(
                            $self->{top_directory},
                            $self->{state_directory},
                            $self->{credentials}
                           );

    my ($user, $pass);
    if (-e $filename) {
        ($user, $pass) = $self->read_word($filename);
    } else {
        ($user, $pass) = $self->ask_word();
        $self->write_word($filename, $user, $pass);
    }

lib/App/Followme/UploadSite.pm  view on Meta::CPAN

If there is a checksum, but no local file, the file is deleted from the remote
site. If this module is run in quick mode, only files whose modification date is
later then the last time it was run are checked.

=head1 CONFIGURATION

The following fields in the configuration file are used:

=over 4

=item credentials

The name of the file which holds the user name and password for the remote site
in obfuscated form. Te default name is 'upload.cred'.

=item hash_file

The name of the file containing all the checksums for files on the site. The
default name is 'upload.hash'.

=item max_errors

The number of upload errors the module tolerate before quitting. The default
value is 5.

=item remote_url

The url of the remote website, e.g. http://www.cloudhost.com.

=item state_directory

The name of the directory containing the credentials and hash file. This
directory name is relative to the top directory of the site. The default
name is '_state'.

=item upload_pkg

The name of the package with methods that add and delete files on the remote
site. The default is L<App::Followme::UploadFtp>. Other packages can be
written, the methods a package must support can be found in
L<App::Followme::UploadNone>.

t/UploadSite.t  view on Meta::CPAN


do {
    my $up = App::Followme::UploadSite->new(%configuration);

    my $user_ok = 'gandalf';
    my $password_ok = 'wizzard';

    my $cred_file = catfile(
                            $up->{top_directory},
                            $up->{state_directory},
                            $up->{credentials},
                           );

    $up->write_word($cred_file, $user_ok, $password_ok);

    my ($user, $pass) = $up->read_word($cred_file);
    is($user, $user_ok, 'Read user name'); # test 1
    is($pass, $password_ok, 'Read password'); # test 2

    my $hash_file = catfile($up->{top_directory},
                            $up->{state_directory},



( run in 0.239 second using v1.01-cache-2.11-cpan-a5abf4f5562 )