Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 23, 2012
1 parent 4e7318a commit acd645f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
15 changes: 1 addition & 14 deletions lib/Mojo/Home.pm
Expand Up @@ -11,7 +11,6 @@ use File::Find 'find';
use File::Spec::Functions qw(abs2rel catdir catfile splitdir);
use FindBin;
use Mojo::Asset::File;
use Mojo::Loader;
use Mojo::Util 'class_to_path';

has app_class => 'Mojo::HelloWorld';
Expand All @@ -35,25 +34,13 @@ sub detect {

# Try to find home from lib directory
if ($class) {

# Load
my $file = class_to_path $class;
unless ($INC{$file}) {
if (my $e = Mojo::Loader->new->load($class)) { die $e if ref $e }
}

# Detect
if (my $path = $INC{$file}) {

# Directory
$path =~ s/$file$//;
my @home = splitdir $path;

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

# Turn into absolute path
$self->{parts} = [splitdir(abs_path(catdir(@home) || '.'))];
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/cookiejar.t
Expand Up @@ -6,8 +6,8 @@ use Test::More tests => 85;
# Okay Mr. Burns, what's your first name.
# I don't know."
use Mojo::Cookie::Response;
use Mojo::UserAgent::CookieJar;
use Mojo::URL;
use Mojo::UserAgent::CookieJar;

# Session cookie
my $jar = Mojo::UserAgent::CookieJar->new;
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/home.t
Expand Up @@ -5,12 +5,12 @@ BEGIN { $ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll' }

use Test::More tests => 15;

# "Uh, no, you got the wrong number. This is 9-1... 2"
use Cwd qw(cwd realpath);
use File::Spec::Functions qw(canonpath catdir splitdir);
use FindBin;
use List::Util 'first';

# "Uh, no, you got the wrong number. This is 9-1... 2"
use Mojo::HelloWorld;
use Mojo::Home;

# ENV detection
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/psgi.t
Expand Up @@ -5,8 +5,8 @@ use Test::More tests => 19;
# "We need some more secret sauce. Put the mayonnaise in the sun."
use Mojo::JSON;
use Mojo::Server::PSGI;
use Mojolicious::Lite;
use Mojolicious::Command::psgi;
use Mojolicious::Lite;

# Silence
app->log->level('fatal');
Expand Down
2 changes: 1 addition & 1 deletion t/mojolicious/dispatch.t
Expand Up @@ -27,9 +27,9 @@ use utf8;

use Test::More tests => 85;

use Mojo::Transaction::HTTP;
use Mojo::Upload;
use Mojolicious;
use Mojo::Transaction::HTTP;
use Mojolicious::Controller;
use Mojolicious::Routes;

Expand Down

0 comments on commit acd645f

Please sign in to comment.