Show
Ignore:
Timestamp:
05/11/08 11:28:08 (5 years ago)
Author:
tomyhero
Message:

lang/perl/Catalyst-Plugin-ConfigLoader?-Multi : fix bug

Location:
lang/perl/Catalyst-Plugin-ConfigLoader-Multi/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Catalyst-Plugin-ConfigLoader-Multi/trunk/Changes

    r9013 r11385  
    11Revision history for Catalyst-Plugin-ConfigLoader-Multi 
     2 
     30.06    2008-05-17/11:21 
     4        - loal only myapp_local.yaml insetad of myapp*_local.yaml. because the specific may generate bug for your application when you set same key in your each local files. 
     5        - fix POD 
    26 
    370.05    2008-04-06/20:24 
  • lang/perl/Catalyst-Plugin-ConfigLoader-Multi/trunk/lib/Catalyst/Plugin/ConfigLoader/Multi.pm

    r9013 r11385  
    99use NEXT; 
    1010 
    11 our $VERSION = 0.05; 
     11our $VERSION = 0.06; 
     12 
    1213 
    1314sub find_files { 
    1415    my $c = shift; 
     16    my ( $path, $extension ) = $c->get_config_path; 
     17    my $suffix     = $c->get_config_local_suffix; 
     18    my @extensions = @{ Config::Any->extensions }; 
    1519 
    16     my @files    = $c->SUPER::find_files(); 
     20    my $prefix = Catalyst::Utils::appprefix( ref $c || $c ); 
     21    my $config_key_name = uc($prefix) . '_CONFIG_MULTI'; 
     22 
     23    my @files; 
     24    if ( $extension ) { 
     25        die "Unable to handle files with the extension '${extension}'" 
     26            unless grep { $_ eq $extension } @extensions; 
     27        ( my $local = $path ) =~ s{\.$extension}{_$suffix.$extension}; 
     28        push @files, $path, $local; 
     29    } 
     30    else { 
     31        # do not append lcoal suffix 
     32        if ($ENV{ $config_key_name } ) { 
     33            @files = map { ( "$path.$_" ) } @extensions; 
     34        } 
     35        else { 
     36            @files = map { ( "$path.$_", "${path}_${suffix}.$_" ) } @extensions; 
     37        } 
     38    } 
    1739    my @my_files = $c->_find_my_files(); 
    1840 
    19     return ( @files, @my_files ); 
     41    push @my_files , $ENV{$config_key_name} if $ENV{$config_key_name} ; 
     42 
     43    return @my_files, @files; 
    2044} 
    2145 
     
    3559    my $dh         = DirHandle->new($path); 
    3660 
    37     my $config_key_name = uc($prefix) . '_CONFIG_MULTI'; 
    38  
    3961 
    4062    while ( my $file = $dh->read() ) { 
    4163        next unless $file =~ /^$prefix\_(.+)\.\w+$/ && $suffix ne $1; 
    4264 
    43  
    44         if ( $ENV{ $config_key_name } ) { 
    45             push @my_files, ( 
    46                 map { 
    47                     (   "${path_prefix}_${1}.$_",) 
    48                     } @extensions 
    49             ); 
    50         } 
    51         else { 
    52             push @my_files, ( 
    53                 map { 
    54                     (   "${path_prefix}_${1}.$_", 
    55                         "${path_prefix}_${1}_${suffix}.$_" 
    56                         ) 
    57                     } @extensions 
    58             ); 
    59         } 
     65        push @my_files, ( map { ( "${path_prefix}_${1}.$_", ) } @extensions ); 
    6066    } 
    6167 
    62     push @my_files ,  $ENV{ $config_key_name } if $ENV{ $config_key_name }; 
    6368 
    6469    return @my_files; 
     
    134139=head1 ENV 
    135140 
    136 you can specify local file with this setting. 
     141you can specify local file with this setting.( you must use local_sufix for the file name ) 
    137142 
    138143 $ENV{MYAPP_CONFIG_MULTI} = '/tmp/foo/your_own_local.yaml' 
  • lang/perl/Catalyst-Plugin-ConfigLoader-Multi/trunk/t/spelling.t

    r9160 r11385  
    22use Test::Spelling; 
    33$ENV{LANG} = 'C'; 
     4 
     5$ENV{TEST_SPELLING} or  plan skip_all => "no test for spelling. you must set TEST_SPELLING env for activate this test"; 
    46 
    57my $spell_cmd;