Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feature_path
- Loading branch information
Showing
12 changed files
with
233 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package Catmandu::Fix::Namespace; | ||
|
||
use Catmandu::Sane; | ||
|
||
our $VERSION = '1.09'; | ||
|
||
use Moo::Role; | ||
use namespace::clean; | ||
|
||
requires 'load'; | ||
|
||
has name => (is => 'ro', required => 1); | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package Catmandu::Fix::Namespace::perl; | ||
|
||
use Catmandu::Sane; | ||
|
||
our $VERSION = '1.09'; | ||
|
||
use Catmandu::Util qw(is_instance require_package); | ||
use String::CamelCase qw(camelize); | ||
use Moo; | ||
use namespace::clean; | ||
|
||
with 'Catmandu::Fix::Namespace'; | ||
|
||
sub load { | ||
my ($self, $name, $args, $type) = @_; | ||
my $ns = join('::', map {camelize($_)} split(/\./, $self->name)); | ||
$ns = join('::', $ns, $type) if $type; | ||
|
||
my $pkg; | ||
try { | ||
$pkg = require_package($name, $ns); | ||
} | ||
catch_case [ | ||
'Catmandu::NoSuchPackage' => sub { | ||
Catmandu::NoSuchFixPackage->throw( | ||
message => "No such fix package: $name", | ||
package_name => $_->package_name, | ||
fix_name => $name, | ||
); | ||
}, | ||
]; | ||
try { | ||
$pkg->new(@$args); | ||
} | ||
catch { | ||
$_->throw if is_instance($_, 'Catmandu::Error'); | ||
Catmandu::BadFixArg->throw( | ||
message => $_, | ||
package_name => $pkg, | ||
fix_name => $name, | ||
); | ||
}; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.