<<

NAME

Koha::Devel::Files - A utility module for managing and filtering file lists in the Koha codebase

SYNOPSIS

    use Koha::Devel::Files;

    my $file_manager = Koha::Devel::Files->new( { context => 'tidy' } );

    my @perl_files = $file_manager->ls_perl_files();
    my @js_files   = $file_manager->ls_js_files();
    my @tt_files   = $file_manager->ls_tt_files();

    my $filetype = $file_manager->get_filetype($filename);

DESCRIPTION

Koha::Devel::Files is a utility module designed to assist in managing and filtering lists of files in the Koha codebase. It provides methods to list Perl, JavaScript, and Template Toolkit files, with options to exclude specific files based on a given context.

EXCEPTIONS

The module defines a set of exceptions for different file types and contexts. These exceptions are used to exclude specific files or directories from the file listings.

METHODS

new

    my $file_manager = Koha::Devel::Files->new( { context => 'tidy' } );

Creates a new instance of Koha::Devel::Files. The constructor accepts a hash reference with a 'context' key, which specifies the context for file exclusions.

build_git_exclude

    my $exclude_pattern = $file_manager->build_git_exclude($filetype);

Builds a Git exclude pattern for a given file type based on the context provided during object creation.

remove_exceptions

    @files = $file_manager->remove_exceptions($files, $filetype);

Remove from exceptions from the original file list.

ls_files

    my @files = $file_manager->ls_files( $filetype, $git_range );

Lists files that have been modified within a specified Git range. If no range is provided, it lists all Perl files, excluding those specified in the exceptions.

ls_perl_files

    my @perl_files = $file_manager->ls_perl_files();

Lists Perl files (with extensions .pl, .PL, .pm, .t) in the repository, excluding those specified in the exceptions.

ls_dbrev_files

    my @dbrev_files = $file_manager->ls_dbrev_files;

Lists all dbrevs files.

ls_js_files

    my @js_files = $file_manager->ls_js_files();

Lists JavaScript and TypeScript files (with extensions .js, .ts, .vue) in the repository, excluding those specified in the exceptions.

ls_tt_files

    my @tt_files = $file_manager->ls_tt_files();

Lists Template Toolkit files (with extensions .tt, .inc) in the repository, excluding those specified in the exceptions.

ls_yml_files

    my @yml_files = $file_manager->ls_yml_files();

Lists YAML files (with extensions .yml, .yaml) in the repository, excluding those specified in the exceptions.

ls_css_files

    my @css_files = $file_manager->ls_css_files();

Lists CSS files (with extensions .css) in the repository, excluding those specified in the exceptions.

ls_all_files

    my @files = $file_manager->ls_all_files([$extension_list_to_exclude]);

Lists all files in the repository. Accept a list of extension to exclude.

get_filetype

    my $filetype = $file_manager->get_filetype($filename);

Determines the file type of a given file based on its extension or path. Returns 'pl' for Perl files, 'js' for JavaScript/TypeScript files, and 'tt' for Template Toolkit files. Dies with an error message if the file type cannot be determined.

<<