<commit_before>package Tangerine::hook::inline;

use 5.010;
use strict;
use warnings;
use parent 'Tangerine::Hook';
use List::MoreUtils qw(any);
use Tangerine::HookData;
use Tangerine::Occurence;
use Tangerine::Utils qw(stripquotelike);

my %langmap = (
    (map { $_ => 'ASM' } qw/nasm NASM gasp GASP as AS asm/),
    (map { $_ => 'Awk' } qw/AWK awk/),
    basic => 'Basic',
    (map { $_ => 'BC' } qw/bc Bc/),
    (map { $_ => 'Befunge' } qw/befunge BEFUNGE bef BEF/),
    c => 'C',
    (map { $_ => 'CPP' } qw/cpp C++ c++ Cplusplus cplusplus CXX cxx/),
    GUILE => 'Guile',
    (map { $_ => 'Java' } qw/JAVA java/),
    lua => 'Lua',
    MZSCHEME => 'MzScheme',
    nouse => 'Nouse',
    octave => 'Octave',
    (map { $_ => 'Pdlpp' } qw/pdlpp PDLPP/),
    perl => 'Perl',
    (map { $_ => 'Python' } qw/py python PYTHON/),
    (map { $_ => 'Ruby' } qw/rb ruby RUBY/),
    (map { $_ => 'SLang' } qw/sl slang/),
    (map { $_ => 'SMITH' } qw/Smith smith/),
    (map { $_ => 'Tcl' } qw/tcl tk/),
    (map { $_ => 'TT' } qw/tt template/),
    webchat => 'WebChat',
);

sub run {
    my ($self, $s) = @_;
    if ((any { $s->[0] eq $_ } qw(use no)) && scalar(@$s) > 2 &&
        $s->[1] eq 'Inline') {
        my ($version) = $s->[2] =~ /^(\d.*)$/o;
        $version //= '';
        my $voffset = $version ? 3 : 2;
        my @args;
        if (scalar(@$s) > $voffset) {
            return if $s->[$voffset] eq ';';
            @args = @$s;
            @args = @args[($voffset) .. $#args];
            @args = stripquotelike(@args);
        }
        my @modules;
        if ($args[0] =~ /config/io) {
            return
        } elsif ($args[0] =~ /with/io) {
            shift @args;
            push @modules, @args;
        } else {
            push @modules, 'Inline::'.($langmap{$args[0]} // $args[0])
        }
        return Tangerine::HookData->new(
            modules => {
                map {
                    ( $_ => Tangerine::Occurence->new() )
                    } @modules,
                },
            );
    }
    return;
}

1;

__END__

=pod

=encoding utf8

=head1 NAME

Tangerine::hook::inline - Process Inline module use statements

=head1 DESCRIPTION

This hook parses L<Inline> arguments and attempts to report required
C<Inline> language modules or non-C<Inline> modules used for
configuration, usually loaded via the C<with> syntax.

=head1 AUTHOR

<NAME> <<EMAIL>>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2014-2015 <NAME>

See LICENSE for licensing details.

=cut
<commit_msg>Add support for Inline::Filters<commit_after>package Tangerine::hook::inline;

use 5.010;
use strict;
use warnings;
use parent 'Tangerine::Hook';
use List::MoreUtils qw(any);
use Tangerine::HookData;
use Tangerine::Occurence;
use Tangerine::Utils qw(stripquotelike);

my %langmap = (
    (map { $_ => 'ASM' } qw/nasm NASM gasp GASP as AS asm/),
    (map { $_ => 'Awk' } qw/AWK awk/),
    basic => 'Basic',
    (map { $_ => 'BC' } qw/bc Bc/),
    (map { $_ => 'Befunge' } qw/befunge BEFUNGE bef BEF/),
    c => 'C',
    (map { $_ => 'CPP' } qw/cpp C++ c++ Cplusplus cplusplus CXX cxx/),
    GUILE => 'Guile',
    (map { $_ => 'Java' } qw/JAVA java/),
    lua => 'Lua',
    MZSCHEME => 'MzScheme',
    nouse => 'Nouse',
    octave => 'Octave',
    (map { $_ => 'Pdlpp' } qw/pdlpp PDLPP/),
    perl => 'Perl',
    (map { $_ => 'Python' } qw/py python PYTHON/),
    (map { $_ => 'Ruby' } qw/rb ruby RUBY/),
    (map { $_ => 'SLang' } qw/sl slang/),
    (map { $_ => 'SMITH' } qw/Smith smith/),
    (map { $_ => 'Tcl' } qw/tcl tk/),
    (map { $_ => 'TT' } qw/tt template/),
    webchat => 'WebChat',
);

sub run {
    my ($self, $s) = @_;
    if ((any { $s->[0] eq $_ } qw(use no)) && scalar(@$s) > 2 &&
        $s->[1] eq 'Inline') {
        my ($version) = $s->[2] =~ /^(\d.*)$/o;
        $version //= '';
        my $voffset = $version ? 3 : 2;
        my @args;
        if (scalar(@$s) > $voffset) {
            return if $s->[$voffset] eq ';';
            @args = @$s;
            @args = @args[($voffset) .. $#args];
            @args = stripquotelike(@args);
        }
        my @modules;
        if ($args[0] =~ /config/io) {
            return
        } elsif ($args[0] =~ /with/io) {
            shift @args;
            push @modules, @args;
        } else {
            push @modules, 'Inline::'.($langmap{$args[0]} // $args[0])
        }
        if (any { $_ eq 'FILTERS' } @args) {
            push @modules, 'Inline::Filters'
        }
        return Tangerine::HookData->new(
            modules => {
                map {
                    ( $_ => Tangerine::Occurence->new() )
                    } @modules,
                },
            );
    }
    return;
}

1;

__END__

=pod

=encoding utf8

=head1 NAME

Tangerine::hook::inline - Process Inline module use statements

=head1 DESCRIPTION

This hook parses L<Inline> arguments and attempts to report required
C<Inline> language modules or non-C<Inline> modules used for
configuration, usually loaded via the C<with> syntax.  This hook
also reports L<Inline::Filters> if C<FILTERS> are invoked.

=head1 AUTHOR

<NAME> <<EMAIL>>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2014-2015 <NAME>

See LICENSE for licensing details.

=cut

{'fraction_non_alphanumeric': 0.18908045977011495, 'fraction_numerical': 0.010727969348659003, 'mean_word_length': 2.1003562945368173, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 85, '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': '1526544', 'n_tokens_mistral': 2003, 'n_tokens_neox': 1945, 'n_words': 486}