| 1 | package App::Followme::UploadData; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use 5.008005; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use integer; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use lib '../..'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | ▶ | use base qw(App::Followme::FolderData); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 2 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 2 | ▶ | use App::Followme::FIO; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 2 | ▶ | use App::Followme::Web; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 2 | our $VERSION = "2.03"; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 18 | # Read the default parameter values | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 12 | ▶ | sub parameters { | ||||||||||||||||||
|
Subroutine
parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 21 | 12 | my ($self) = @_; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | return ( | ||||||||||||||||||||
| 24 | 12 | ); | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 28 | # Calculate the check sum for a file | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 12 | ▶ | sub calculate_checksum { | ||||||||||||||||||
|
Subroutine
calculate_checksum: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 31 | 12 | my ($self, $filename) = @_; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 12 | my $page = fio_read_page($filename, ':raw'); | |||||||||||||||||||
| 34 | 12 | ▶ | return '' unless $page; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 12 | my $md5 = Digest::MD5->new; | |||||||||||||||||||
| 37 | 12 | $md5->add($page); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 12 | return $md5->hexdigest; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 43 | # Return true if this is an included file | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 9 | ▶ | sub match_file { | ||||||||||||||||||
|
Subroutine
match_file: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||
| 46 | 9 | my ($self, $filename) = @_; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 9 | ▶ | $self->{exclude_file_patterns} ||= fio_glob_patterns($self->{exclude}); | ||||||||||||||||||
|
Condition66%2/3
$self->{"exclude_file_patterns"} ||= fio_glob_patterns($self->{"exclude"})
MC/DC0%0/2
$self->{"exclude_file_patterns"} ||= fio_glob_patterns($self->{"exclude"})
$self->{"exclude_file_patterns"}
fio_glob_patterns($self->{"exclude"})
Truth table66%2/3
A ||= B
A= $self->{"exclude_file_patterns"}B= fio_glob_patterns($self->{"exclude"})
| |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 9 | my ($dir, $file) = fio_split_filename($filename); | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 9 | ▶ | return if $self->match_patterns($file, $self->{exclude_file_patterns}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 9 | return 1; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 2 | 1; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =pod | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | =encoding utf-8 | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head1 NAME | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | App::Followme::UploadData | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =head1 SYNOPSIS | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | use App::Followme::UploadData; | ||||||||||||||||||||
| 69 | my $meta = App::Followme::UploadData->new(exclude => '*.cfg'); | ||||||||||||||||||||
| 70 | my $index_file = $self->to_file($self->{base_directory}); | ||||||||||||||||||||
| 71 | my $files = App::Followme::Template->build('files', $index_file); | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =head1 DESCRIPTION | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | This module generates the list of files and folders to be uploaded to the | ||||||||||||||||||||
| 76 | remote site and the checksums for each file. | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =head1 METHODS | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | All data classes are first instantiated by calling new and data items are | ||||||||||||||||||||
| 81 | retrieved by calling the build method with the item name as the first argument | ||||||||||||||||||||
| 82 | and the file or folder as the second argument. | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | =head1 VARIABLES | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | The file metadata class can evaluate the following variables. When passing | ||||||||||||||||||||
| 87 | a name to the build method, the sigil should not be used. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =over 4 | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =item @files | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | The list of files to be uploaded from a folder. | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =item @folders | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | The list of folders contining files to be uploaded | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | =item $checksum | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | The MD5 hash of the file contents, used for determining if file has changed | ||||||||||||||||||||
| 102 | and needs to be uploaded. | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =back | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =head1 CONFIGURATION | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | This class has the following configuration variables: | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =over 4 | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =item excluded | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | A filename pattern or comma separated list of filename patterns that match files | ||||||||||||||||||||
| 115 | that should not be uploaded. The default value is '*.cfg' which matches | ||||||||||||||||||||
| 116 | configuration files. | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =item exclude_dirs | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | A filename pattern or comma separated list of filename patterns that match | ||||||||||||||||||||
| 121 | folders that should not be uploaded/ The default value is '.*,_*' which | ||||||||||||||||||||
| 122 | matches folders starting with a dot (hiddern folders) and starting with an | ||||||||||||||||||||
| 123 | underscore character. | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | =back | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | =head1 LICENSE | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | Copyright (C) Bernie Simon. | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 132 | it under the same terms as Perl itself. | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =head1 AUTHOR | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | Bernie Simon E<lt>bernie.simon@gmail.comE<gt> | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||