<commit_before>package AnyJob::Utils;

###############################################################################
# Various utility functions.
#
# Author:       LightStar
# Created:      27.10.2017
# Last update:  04.12.2017
#

use strict;
use warnings;
use utf8;

use base 'Exporter';

our @EXPORT_OK = qw(
    getModuleName
    requireModule
    getFileContent
    );

###############################################################################
# Get canonical module name from some name in config.
#
# Returns:
#     string module name.
#
sub getModuleName {
    my $name = shift;
    return join('', map {ucfirst($_)} split(/_/, $name));
}

###############################################################################
# Load module by name using eval and throwing exception on error.
#
# Arguments:
#     module - string module name.
#
sub requireModule {
    my $module = shift;

    eval 'require ' . $module;
    if ($@) {
        require Carp;
        Carp::confess('Can\'t load module \'' . $module . '\': ' . $@);
    }
}<commit_msg>Add support for complex module names.<commit_after>package AnyJob::Utils;

###############################################################################
# Various utility functions.
#
# Author:       LightStar
# Created:      27.10.2017
# Last update:  04.12.2017
#

use strict;
use warnings;
use utf8;

use base 'Exporter';

our @EXPORT_OK = qw(
    getModuleName
    requireModule
    getFileContent
    );

###############################################################################
# Get canonical module name from some name in config.
#
# Returns:
#     string module name.
#
sub getModuleName {
    my $name = shift;
    return join('::', map {ucfirst($_)} split(/\//, join('', map {ucfirst($_)} split(/_/, $name))));
}

###############################################################################
# Load module by name using eval and throwing exception on error.
#
# Arguments:
#     module - string module name.
#
sub requireModule {
    my $module = shift;

    eval 'require ' . $module;
    if ($@) {
        require Carp;
        Carp::confess('Can\'t load module \'' . $module . '\': ' . $@);
    }
}
{'fraction_non_alphanumeric': 0.3270555810748737, 'fraction_numerical': 0.015617822691777675, 'mean_word_length': 3.7245119305856833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '308802', 'n_tokens_mistral': 628, 'n_tokens_neox': 584, 'n_words': 173}