Koha::Devel::Files - A utility module for managing and filtering file lists in the Koha codebase
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);
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.
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.
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.
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.
@files = $file_manager->remove_exceptions($files, $filetype);
Remove from exceptions from the original file list.
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.
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.
my @dbrev_files = $file_manager->ls_dbrev_files;
Lists all dbrevs 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.
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.
my @yml_files = $file_manager->ls_yml_files();
Lists YAML files (with extensions .yml, .yaml) in the repository, excluding those specified in the exceptions.
my @css_files = $file_manager->ls_css_files();
Lists CSS files (with extensions .css) in the repository, excluding those specified in the exceptions.
my @files = $file_manager->ls_all_files([$extension_list_to_exclude]);
Lists all files in the repository. Accept a list of extension to exclude.
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.