-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r37256@bricas-laptop (orig r8347): bricas | 2008-09-03 10:53:01 -0300
branch for new feature r37257@bricas-laptop (orig r8348): bricas | 2008-09-03 10:55:06 -0300 when use_ext is true, we will check to see if there are no supported modules for a particular file. instead of the file being skipped, an error will be thrown. officially support multiple loaders per extension. add a Config::Any::Base for all loaders to inherit from, plus add a new dependency mechanism: requires_any_of() and requires_all_of(). r37293@bricas-laptop (orig r8354): bricas | 2008-09-04 10:52:33 -0300 when use_ext is true, a fatal error will be thrown if there are no loaders available that understand the file extension r40211@bricas-laptop (orig r8589): bricas | 2008-11-12 10:36:43 -0400 filter out loaders that don't inherit from Config::Any::Base (RT #40830) r40212@bricas-laptop (orig r8590): bricas | 2008-11-12 10:40:32 -0400 add RT number
- Loading branch information
Showing
21 changed files
with
233 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package Config::Any::Base; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
=head1 NAME | ||
Config::Any::Base - Base class for loaders | ||
=head1 DESCRIPTION | ||
This is a base class for all loaders. It currently handles the specification | ||
of dependencies in order to ensure the subclass can load the config file | ||
format. | ||
=head1 METHODS | ||
=head2 is_supported( ) | ||
Allows us to determine if the file format can be loaded. The can be done via | ||
one of two subclass methds: | ||
=over 4 | ||
=item * C<requires_all_of()> - returns an array of items that must all be present in order to work | ||
=item * C<requires_any_of()> - returns an array of items in which at least one must be present | ||
=back | ||
You can specify a module version by passing an array reference in the return. | ||
sub requires_all_of { [ 'My::Module', '1.1' ], 'My::OtherModule' } | ||
Lack of specifying these subs will assume you require no extra modules to function. | ||
=cut | ||
|
||
sub is_supported { | ||
my ( $class ) = shift; | ||
if ( $class->can( 'requires_all_of' ) ) { | ||
eval join( '', map { _require_line( $_ ) } $class->requires_all_of ); | ||
return $@ ? 0 : 1; | ||
} | ||
if ( $class->can( 'requires_any_of' ) ) { | ||
for ( $class->requires_any_of ) { | ||
eval _require_line( $_ ); | ||
return 1 unless $@; | ||
} | ||
return 0; | ||
} | ||
|
||
# requires nothing! | ||
return 1; | ||
} | ||
|
||
sub _require_line { | ||
my ( $input ) = shift; | ||
my ( $module, $version ) = ( ref $input ? @$input : $input ); | ||
return "require $module;" | ||
. ( $version ? "${module}->VERSION('${version}');" : '' ); | ||
} | ||
|
||
=head1 AUTHOR | ||
Brian Cassidy E<lt>[email protected]E<gt> | ||
=head1 COPYRIGHT AND LICENSE | ||
Copyright 2008 by Brian Cassidy | ||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
=head1 SEE ALSO | ||
=over 4 | ||
=item * L<Config::Any> | ||
=back | ||
=cut | ||
|
||
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
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ package Config::Any::Perl; | |
use strict; | ||
use warnings; | ||
|
||
use base 'Config::Any::Base'; | ||
|
||
my %cache; | ||
|
||
=head1 NAME | ||
|
@@ -54,16 +56,6 @@ sub load { | |
return $content; | ||
} | ||
|
||
=head2 is_supported( ) | ||
Returns true. | ||
=cut | ||
|
||
sub is_supported { | ||
return 1; | ||
} | ||
|
||
=head1 AUTHOR | ||
Brian Cassidy E<lt>[email protected]E<gt> | ||
|
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
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.