| 1 | package Kwiki::WebFile; | ||||||||||
| 2 | 6 | ▶ | use Kwiki::Base -Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 6 | ▶ | use Spoon::Base 'conf'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 6 | our @EXPORT = qw(conf); | |||||||||
| 6 | |||||||||||
| 7 | 6 | field path => []; | |||||||||
| 8 | 6 | field files => []; | |||||||||
| 9 | 6 | const default_path_method => 'default_path'; | |||||||||
| 10 | |||||||||||
| 11 | 6 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | 6 | my $method = $self->default_path_method; | |||||||||
| 13 | 6 | $self->add_path(@{$self->$method}); | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 6 | ▶ | sub add_file { | ||||||||
|
Subroutine
add_file: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||
| 17 | 6 | ▶ | my $file = shift | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | or return; | ||||||||||
| 19 | 6 | my $file_path = ''; | |||||||||
| 20 | 6 | for (@{$self->path}) { | |||||||||
| 21 | 6 | ▶ | $file_path = "$_/$file", last | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | if -f "$_/$file"; | ||||||||||
| 23 | } | ||||||||||
| 24 | 6 | my $files = $self->files; | |||||||||
| 25 | 0 | @$files = grep { not /\/$file$/ } @$files; | |||||||||
| 26 | 6 | push @$files, $file_path; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub files_which_exist { | ||||||||
|
Subroutine
files_which_exist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 30 | 0 | grep {io->file($_)->exists} @{$self->files}; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 6 | ▶ | sub add_path { | ||||||||
|
Subroutine
add_path: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | 6 | unshift @{$self->path}, @_; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub clear_files { | ||||||||
|
Subroutine
clear_files: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | 0 | $self->files([]); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 6 | __DATA__ | |||||||||