Skip to content

Commit

Permalink
find_modules should return a list
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 20, 2015
1 parent 8dcb287 commit e7041d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/Mojo/Loader.pm
Expand Up @@ -36,7 +36,7 @@ sub find_modules {
}
}

return [keys %modules];
return sort keys %modules;
}

# DEPRECATED in Tiger Face!
Expand Down Expand Up @@ -65,7 +65,7 @@ sub new {
}

# DEPRECATED in Tiger Face!
sub search { shift; find_modules(@_) }
sub search { shift; [find_modules(@_)] }

sub _all {
my $class = shift;
Expand Down Expand Up @@ -109,7 +109,7 @@ Mojo::Loader - Loader
use Mojo::Loader qw(data_section find_modules load_class);
# Find modules in a namespace
for my $module (@{find_modules 'Some::Namespace'}) {
for my $module (find_modules 'Some::Namespace') {
# Load them safely
my $e = load_class $module;
Expand Down Expand Up @@ -146,7 +146,7 @@ Check if embedded file from the C<DATA> section of a class was Base64 encoded.
=head2 find_modules
my $modules = find_modules 'MyApp::Namespace';
my @modules = find_modules 'MyApp::Namespace';
Search for modules in a namespace non-recursively.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Commands.pm
Expand Up @@ -62,7 +62,7 @@ sub run {
my %all;
for my $ns (@{$self->namespaces}) {
$all{substr $_, length "${ns}::"} //= $_->new->description
for grep { _command($_) } @{find_modules $ns};
for grep { _command($_) } find_modules $ns;
}

my @rows = map { [" $_", $all{$_}] } sort keys %all;
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/loader.t
Expand Up @@ -50,11 +50,11 @@ is $e->lines_after->[1][1], '1;', 'right line';
like "$e", qr/Exception/, 'right message';

# Search
my @modules = sort @{find_modules 'Mojo::LoaderTest'};
my @modules = find_modules 'Mojo::LoaderTest';
is_deeply \@modules,
[qw(Mojo::LoaderTest::A Mojo::LoaderTest::B Mojo::LoaderTest::C)],
'found the right modules';
is_deeply [sort @{find_modules "Mojo'LoaderTest"}],
is_deeply [find_modules "Mojo'LoaderTest"],
[qw(Mojo'LoaderTest::A Mojo'LoaderTest::B Mojo'LoaderTest::C)],
'found the right modules';

Expand Down

0 comments on commit e7041d9

Please sign in to comment.