| Catalyst-Plugin-ConfigLoader-Remote documentation | Contained in the Catalyst-Plugin-ConfigLoader-Remote distribution. |
Catalyst::Plugin::ConfigLoader::Remote - Load (remote) URIs into config
Version 0.01
This module provides support for fetching remote configuration files over HTTP, FTP or other remote methods.
It will fetch any blessed URI object in the files config entry for the
package via File::Fetch
package MyApp;
use Catalyst qw/ConfigLoader::Remote/;
use URI;
__PACKAGE__->config(
'Plugin::ConfigLoader::Remote' => {
files => [
URI->new("https://secure.example.com/config/basic.yml"),
URI->new("https://secure.example.com/config/database.conf"),
]
}
);
find_files will download each file to a temporary directory that is purged on program exit. It is then passed to Catalyst::Plugin::ConfigLoader for actual configuration loading and processing.
J. Shirley, <jshirley at gmail.com>
Eden Cardim
Please report any bugs or feature requests to
bug-catalyst-plugin-configloader-remote at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-ConfigLoader-Remote.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Catalyst::Plugin::ConfigLoader::Remote
You can also look for information at:
http://annocpan.org/dist/Catalyst-Plugin-ConfigLoader-Remote
http://cpanratings.perl.org/d/Catalyst-Plugin-ConfigLoader-Remote
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-ConfigLoader-Remote
http://search.cpan.org/dist/Catalyst-Plugin-ConfigLoader-Remote
Copyright 2007 J. Shirley and PictureTrail.com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-Plugin-ConfigLoader-Remote documentation | Contained in the Catalyst-Plugin-ConfigLoader-Remote distribution. |
package Catalyst::Plugin::ConfigLoader::Remote; use warnings; use strict; use File::Fetch; use Scalar::Util qw(blessed); use File::Temp qw/tempdir/; use MRO::Compat; use base qw/Catalyst::Plugin::ConfigLoader/;
our $VERSION = '0.02';
sub find_files { my $c = shift; my $tempdir = tempdir( CLEANUP => 1 ); # Load up the other files that are coming in. my @files = $c->next::method(); my $config = $c->config->{'Plugin::ConfigLoader::Remote'}; return @files unless ref $config eq 'HASH' and ref $config->{files} eq 'ARRAY'; my @incoming_files = @{ $config->{files} }; # replace everything in @files that is a URI object with a downloaded copy foreach my $arg ( @incoming_files ) { if ( blessed $arg and $arg->isa('URI') ) { # Fetch a blessed URI my $ff = File::Fetch->new( uri => $arg->as_string ); if ( $ff ) { my $file = $ff->fetch( to => $tempdir ); if ( $file and -f $file ) { push @files, $file; } } } else { push @files, $arg; } } return @files; }
1; # End of Catalyst::Plugin::ConfigLoader::Remote