Skip to content

Commit

Permalink
Merge pull request #2193 from Grinnz/apostrophe-separator-removal
Browse files Browse the repository at this point in the history
Deprecate accepting old apostrophe package separator in Mojo::Loader
  • Loading branch information
mergify[bot] authored Aug 13, 2024
2 parents 6330775 + a4e7257 commit e8d65dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/Mojo/Loader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Mojo::Base -strict;
use Exporter qw(import);
use Mojo::Exception;
use Mojo::File qw(path);
use Mojo::Util qw(b64_decode class_to_path);
use Mojo::Util qw(b64_decode class_to_path deprecated);

our @EXPORT_OK = qw(data_section file_is_binary find_modules find_packages load_class load_classes);

Expand Down Expand Up @@ -42,6 +42,9 @@ sub load_class {

# Invalid class name
return 1 if ($class || '') !~ /^\w(?:[\w:']*\w)?$/;
deprecated
q{Calling Mojo::Loader::load_class with a class name using the old package separator "'" is deprecated; use "::"}
if $class =~ m/'/;

# Load if not already loaded
return undef if $class->can('new') || eval "require $class; 1";
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/base.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package Mojo::BaseTestTest;
use Mojo::Base 'Mojo::BaseTest';

package Mojo::BaseTestTestTest;
use Mojo::Base "Mojo'BaseTestTest";
use Mojo::Base 'Mojo::BaseTestTest';

package Mojo::BaseTest::Weak1;
use Mojo::Base -base;
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/loader.t
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ subtest 'Search packages' => sub {
};

subtest 'Load' => sub {
ok !load_class("Mojo'LoaderTest::A"), 'loaded successfully';
ok !!Mojo::LoaderTest::A->can('new'), 'loaded successfully';
ok !load_class('Mojo::LoaderTest::A'), 'loaded successfully';
ok !!Mojo::LoaderTest::A->can('new'), 'loaded successfully';
load_class $_ for find_modules 'Mojo::LoaderTest';
ok !!Mojo::LoaderTest::B->can('new'), 'loaded successfully';
ok !!Mojo::LoaderTest::C->can('new'), 'loaded successfully';
Expand Down

0 comments on commit e8d65dc

Please sign in to comment.