--- /dev/null
+package Catalyst::Plugin::ConfigLoader::General;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::General - Load Config::General files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads Config::General files. Example:\r
+\r
+ name = TestApp\r
+ <Component Controller::Foo>\r
+ foo bar\r
+ </Component>\r
+ <Model Baz>\r
+ qux xyzzy\r
+ </Model>\r
+\r
+=head1 METHODS\r
+\r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<cnf>, C<conf>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+ return qw( cnf conf );\r
+}\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> via Config::General.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $file = shift;\r
+\r
+ require Config::General;\r
+ my $configfile = Config::General->new( $file );\r
+ my $config = { $configfile->getall };\r
+ \r
+ return $config;\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=item * L<Config::General>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file
--- /dev/null
+package Catalyst::Plugin::ConfigLoader::INI;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::INI - Load INI config files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads INI files. Example:\r
+\r
+ name=TestApp\r
+ \r
+ [Controller::Foo]\r
+ foo=bar\r
+ \r
+ [Model::Baz]\r
+ qux=xyzzy\r
+\r
+=head1 METHODS\r
+\r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<ini>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+ return qw( ini );\r
+}\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> as an INI file.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $file = shift;\r
+\r
+ require Config::Tiny;\r
+ my $config = Config::Tiny->read( $file );\r
+ my $main = delete $config->{ _ };\r
+ \r
+ $config->{ $_ } = $main->{ $_ } for keys %$main;\r
+\r
+ return $config;\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=item * L<Config::Tiny>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file
--- /dev/null
+package Catalyst::Plugin::ConfigLoader::JSON;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::JSON - Load JSON config files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads JSON files. Example:\r
+\r
+ {\r
+ "name": "TestApp",\r
+ "Controller::Foo": {\r
+ "foo": "bar"\r
+ },\r
+ "Model::Baz": {\r
+ "qux": "xyzzy"\r
+ }\r
+ }\r
+\r
+=head1 METHODS\r
+\r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<json>, C<jsn>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+ return qw( json jsn );\r
+}\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> as a JSON file.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $file = shift;\r
+\r
+ open( my $fh, $file ) or die $!;\r
+ my $content = do { local $/; <$fh> };\r
+ close $fh;\r
+\r
+ eval { require JSON::Syck; };\r
+ if( $@ ) {\r
+ require JSON;\r
+ JSON->import;\r
+ return jsonToObj( $content );\r
+ }\r
+ else {\r
+ return JSON::Syck::Load( $content );\r
+ }\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=item * L<JSON>\r
+\r
+=item * L<JSON::Syck>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file
--- /dev/null
+package Catalyst::Plugin::ConfigLoader::Perl;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::Perl - Load Perl config files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads Perl files. Example:\r
+\r
+ {\r
+ name => 'TestApp',\r
+ 'Controller::Foo' => {\r
+ foo => 'bar'\r
+ },\r
+ 'Model::Baz' => {\r
+ qux => 'xyzzy'\r
+ }\r
+ }\r
+\r
+=head1 METHODS\r
+\r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<pl>, C<perl>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+ return qw( pl perl );\r
+}\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> as a Perl file.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $file = shift;\r
+\r
+ return eval { require $file };\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file
--- /dev/null
+package Catalyst::Plugin::ConfigLoader::XML;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::XML - Load XML config files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads XML files. Example:\r
+\r
+ <config>\r
+ <name>TestApp</name>\r
+ <component name="Controller::Foo">\r
+ <foo>bar</foo>\r
+ </component>\r
+ <model name="Baz">\r
+ <qux>xyzzy</qux>\r
+ </model>\r
+ </config>\r
+\r
+=head1 METHODS\r
+\r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<xml>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+ return qw( xml );\r
+}\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> as an XML file.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $file = shift;\r
+\r
+ require XML::Simple;\r
+ XML::Simple->import;\r
+ my $config = XMLin( $file, ForceArray => [ qw( component model view controller ) ] );\r
+\r
+ return $config;\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=item * L<XML::Simple>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file
--- /dev/null
+package Catalyst::Plugin::ConfigLoader::YAML;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::YAML - Load YAML config files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads YAML files. Example:\r
+\r
+ ---\r
+ name: TestApp\r
+ Controller::Foo:\r
+ foo: bar\r
+ Model::Baz:\r
+ qux: xyzzy\r
+ \r
+\r
+=head1 METHODS\r
+\r
+=head2 extensions( )\r
+\r
+return an array of valid extensions (C<yml>, C<yaml>).\r
+\r
+=cut\r
+\r
+sub extensions {\r
+ return qw( yml yaml );\r
+}\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> as a YAML file.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $file = shift;\r
+\r
+ eval { require YAML::Syck; };\r
+ if( $@ ) {\r
+ require YAML;\r
+ return YAML::LoadFile( $file );\r
+ }\r
+ else {\r
+ open( my $fh, $file ) or die $!;\r
+ my $content = do { local $/; <$fh> };\r
+ close $fh;\r
+ return YAML::Syck::Load( $content );\r
+ }\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=item * L<YAML>\r
+\r
+=item * L<YAML::Syck>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file