CatalystX::Features::Plugin::ConfigLoader - Makes ConfigLoader know about features


CatalystX-Features documentation Contained in the CatalystX-Features distribution.

Index


Code Index:

NAME

Top

CatalystX::Features::Plugin::ConfigLoader - Makes ConfigLoader know about features

VERSION

Top

version 0.20

SYNOPSIS

Top

	/MyApp/features/my.simple.feature_1.23/my.simple.feature.conf

DESCRIPTION

Top

Loads config files from features. The feature config file should have the feature name, plus the regular your usual C::P::ConfigLoaded config extensions.

The config values will be merged into the main app config hash. That means the feature is allowed to change the main app config values.

TODO

Top

* Warn when there are duplicate values.

AUTHORS

Top

	Rodrigo de Oliveira (rodrigolive), C<rodrigolive@gmail.com>

LICENSE

Top

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.


CatalystX-Features documentation Contained in the CatalystX-Features distribution.

package CatalystX::Features::Plugin::ConfigLoader;
$CatalystX::Features::Plugin::ConfigLoader::VERSION = '0.20';
use warnings;
use strict;
use Carp;
use base qw/Catalyst::Plugin::ConfigLoader/; 
use MRO::Compat;

sub find_files {
    my $c = shift;
    my @files = $c->next::method(@_);

    my $appname = ref $c || $c;

    foreach my $feature ( $c->features->list ) {
        my $suffix = Catalyst::Utils::env_value( $appname, 'CONFIG_LOCAL_SUFFIX' )
            || $c->config->{ 'Plugin::ConfigLoader' }->{ config_local_suffix }
            || 'local';

        my @normal = map { $feature->name.".".$_ }  @{ Config::Any->extensions };
        my @local = map { $feature->name."_${suffix}.".$_ }  @{ Config::Any->extensions };
        push @files, map { Path::Class::dir($feature->path, $_)->stringify } @normal, @local;
    }
    return @files;
}

1;