File Coverage

blib/lib/Rose/DBx/MoreConfig.pm
Criterion Covered Total %
statement 36 42 85.7
branch 4 8 50.0
condition 3 8 37.5
subroutine 8 8 100.0
pod 1 1 100.0
total 52 67 77.6


line stmt bran cond sub pod time code
1             #!perl
2              
3 4     4   5240 use strict;
  4         10  
  4         121  
4 4     4   15 use warnings;
  4         7  
  4         142  
5              
6             package Rose::DBx::MoreConfig;
7              
8 4     4   444 use parent 'Rose::DB';
  4         227  
  4         22  
9              
10 4     4   668180 use File::Basename qw(dirname);
  4         7  
  4         281  
11 4     4   17 use File::Spec;
  4         3  
  4         57  
12 4     4   13 use Scalar::Util qw(blessed);
  4         3  
  4         1030  
13              
14             our ($VERSION) = '1.01';
15              
16             sub auto_load_fixups {
17 3     3 1 2865 my ( $self, @args ) = @_;
18 3         5 my $tried = 0;
19             my $home = eval {
20             require File::HomeDir;
21             File::HomeDir->my_home;
22             }
23             || $ENV{HOME}
24             || $ENV{LOGDIR}
25 3   0     3 || eval { ( getpwuid($<) )[7] }
26             || '__ALAS_NO_IDEA__';
27 3         52 $home = File::Spec->catfile( $home, '.rosedbrc' );
28 3         8 my $classpm = blessed($self);
29 3 50       9 if ($classpm) {
30              
31             # Clear the suffix Rose::DB adds to make a generated implementation class
32 0         0 $classpm =~ s[::__RoseDBPrivate__::.*\.pm$][.pm];
33 0         0 $classpm =~ s[::][/]g;
34 0   0     0 $classpm = $INC{$classpm} || $classpm;
35             }
36             else {
37 3         8 $classpm = (caller)[1];
38             }
39 3         258 $classpm = File::Spec->catfile( dirname($classpm), '.rosedbrc' );
40              
41             # Hush warnings from Rose::DB::load_yaml_fixup_file() about data
42             # sources the current class doesn't implement
43 3         7 my $warnhook = $SIG{__WARN__};
44             local $SIG{__WARN__} = sub {
45 12     12   60337 my $msg = $_[0];
46 12 50       87 return if $msg =~ /^No \S+ data source found/;
47 0 0       0 if ( defined $warnhook ) { return $warnhook => (@_); }
  0         0  
48 0         0 else { warn @_; }
49 3         18 };
50              
51             # First, give Rose::DB (or other parent) a chance to do its thing,
52             # so ROSEDB_DEVINIT is handled.
53 3         21 $self->SUPER::auto_load_fixups(@args);
54              
55 3         2519 foreach my $cand ( '/etc/rosedbrc',
56             File::Spec->catfile( dirname( $INC{'Rose/DB.pm'} ), '.rosedbrc' ),
57             $home, $classpm, $ENV{ROSEDBRC} )
58             {
59 15 100 100     270 next unless defined($cand) && -r $cand;
60 5         7 $tried++;
61 5         34 $self->load_yaml_fixup_file( $cand, @args );
62             }
63              
64 3         40 return $tried;
65             }
66              
67             1;
68              
69             __END__