File Coverage

blib/lib/lib/ini.pm
Criterion Covered Total %
statement 25 26 96.1
branch 3 4 75.0
condition 2 3 66.6
subroutine 6 6 100.0
pod n/a
total 36 39 92.3


line stmt bran cond sub pod time code
1             package lib::ini;
2             {
3             $lib::ini::VERSION = '0.002';
4             }
5              
6             # ABSTRACT: Plugin-based @INC mangling
7              
8 1     1   133698 use strict;
  1         3  
  1         40  
9 1     1   6 use warnings;
  1         2  
  1         87  
10              
11 1     1   856 use Class::Load;
  1         33925  
  1         43  
12 1     1   554 use Config::INI::Reader::LibIni;
  1         11  
  1         46  
13 1     1   904 use String::RewritePrefix;
  1         982  
  1         10  
14              
15             sub import {
16 5     5   6322 my $config_filename = 'lib.ini';
17 5         10 my $plugin_prefix = 'lib::ini::plugin::';
18              
19 5 100 66     198 return unless -e $config_filename && -f $config_filename;
20              
21 4         46 my $ini = Config::INI::Reader::LibIni->read_file($config_filename);
22              
23 4         301 foreach my $section (@$ini) {
24 6         30 my ($name, $data) = @$section;
25              
26 6 50       20 if ($name eq '_') {
27 0         0 next; # ignore root-level options for now
28             } else {
29 6         51 my $package = String::RewritePrefix->rewrite(
30             { '' => $plugin_prefix, '+' => '' }, $name,
31             );
32 6         361 Class::Load::load_class($package);
33 6         482 $package->import(%$data);
34             }
35             }
36             }
37              
38             1;
39              
40             __END__