<commit_before># Copyright (C) 2008-2009, <NAME>.

package Mojo::Home;

use strict;
use warnings;

use base 'Mojo::Base';
use overload '""' => sub { shift->to_string }, fallback => 1;

use File::Spec;
use FindBin;
use Mojo::Script;

__PACKAGE__->attr(app_class => (chained => 1));
__PACKAGE__->attr(parts => (chained => 1, default => sub { [] }));

# I'm normally not a praying man, but if you're up there,
# please save me Superman.
sub new {
    my $self = shift->SUPER::new();

    # Parse
    if (@_) { $self->parse(@_) }

    # Detect
    else {
        my $class = (caller())[0];
        $self->detect($class);
    }

    return $self;
}

sub detect {
    my ($self, $class) = @_;

    $self->app_class($class) if $class;
    $class ||= $self->app_class;

    # Environment variable
    if ($ENV{MOJO_HOME}) {
        my @parts = File::Spec->splitdir($ENV{MOJO_HOME});
        return $self->parts(\@parts);
    }

    my $name = $self->_class_to_file($class);

    # Try to find executable from lib directory
    if ($class) {
        my $file = $self->_class_to_path($class);

        if (my $entry = $INC{$file}) {
            my $path = $entry;
            $path =~ s/$file$//;
            my @home = File::Spec->splitdir($path);

            if (@home) {

                # Remove "lib" and "blib"
                pop @home while $home[-1] =~ /^b?lib$/ || $home[-1] eq '';

                # Check for executable
                return $self->parts(\@home)
                  if -f File::Spec->catfile(@home, 'bin', $name)
                      || -f File::Spec->catfile(@home, 'bin', 'mojo');
            }
        }
    }

    # Try to find executable from t directory
    my $path;
    my @base = File::Spec->splitdir($FindBin::Bin);
    my @uplevel;
    for (1 .. 5) {
        push @uplevel, '..';

        # executable in bin directory
        $path = File::Spec->catfile(@base, @uplevel, 'bin', $name);
        last if -f $path;

        # "mojo" in bin directory
        $path = File::Spec->catfile(@base, @uplevel, 'bin', 'mojo');
        last if -f $path;
    }

    # Found
    if (-f $path) {
        my @parts = File::Spec->splitdir($path);
        pop @parts;
        pop @parts;
        $self->parts(\@parts);
    }

    return $self;
}<commit_msg>fixed small error in home detection<commit_after># Copyright (C) 2008-2009, <NAME>.

package Mojo::Home;

use strict;
use warnings;

use base 'Mojo::Base';
use overload '""' => sub { shift->to_string }, fallback => 1;

use File::Spec;
use FindBin;
use Mojo::Script;

__PACKAGE__->attr(app_class => (chained => 1));
__PACKAGE__->attr(parts => (chained => 1, default => sub { [] }));

# I'm normally not a praying man, but if you're up there,
# please save me Superman.
sub new {
    my $self = shift->SUPER::new();

    # Parse
    if (@_) { $self->parse(@_) }

    # Detect
    else {
        my $class = (caller())[0];
        $self->detect($class);
    }

    return $self;
}

sub detect {
    my ($self, $class) = @_;

    $self->app_class($class) if $class;
    $class ||= $self->app_class;

    # Environment variable
    if ($ENV{MOJO_HOME}) {
        my @parts = File::Spec->splitdir($ENV{MOJO_HOME});
        return $self->parts(\@parts);
    }

    my $name = $self->_class_to_file($class);

    # Try to find executable from lib directory
    if ($class) {
        my $file = $self->_class_to_path($class);

        if (my $entry = $INC{$file}) {
            my $path = $entry;
            $path =~ s/$file$//;
            my @home = File::Spec->splitdir($path);

            # Remove "lib" and "blib"
            while (@home) {
                last unless $home[-1] =~ /^b?lib$/ || $home[-1] eq '';
                pop @home;
            }

            # Check for executable
            return $self->parts(\@home)
              if -f File::Spec->catfile(@home, 'bin', $name)
                  || -f File::Spec->catfile(@home, 'bin', 'mojo');
        }
    }

    # Try to find executable from t directory
    my $path;
    my @base = File::Spec->splitdir($FindBin::Bin);
    my @uplevel;
    for (1 .. 5) {
        push @uplevel, '..';

        # executable in bin directory
        $path = File::Spec->catfile(@base, @uplevel, 'bin', $name);
        last if -f $path;

        # "mojo" in bin directory
        $path = File::Spec->catfile(@base, @uplevel, 'bin', 'mojo');
        last if -f $path;
    }

    # Found
    if (-f $path) {
        my @parts = File::Spec->splitdir($path);
        pop @parts;
        pop @parts;
        $self->parts(\@parts);
    }

    return $self;
}
{'fraction_non_alphanumeric': 0.17881374480192602, 'fraction_numerical': 0.007003720726636025, 'mean_word_length': 2.0589022757697455, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '2307733', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1500, 'n_words': 400}