File Coverage

blib/lib/Genome/Site.pm
Criterion Covered Total %
statement 21 26 80.7
branch 2 6 33.3
condition n/a
subroutine 5 5 100.0
pod n/a
total 28 37 75.6


line stmt bran cond sub pod time code
1             package Genome::Site;
2              
3 2     2   83 use strict;
  2         5  
  2         84  
4 2     2   9 use warnings;
  2         3  
  2         182  
5              
6             our $VERSION = $Genome::VERSION;
7              
8             BEGIN {
9 2 50   2   18 if (my $config = $ENV{GENOME_CONFIG}) {
10             # call the specified configuration module;
11 0         0 eval "use $config";
12 0 0       0 die $@ if $@;
13             }
14             else {
15             # look for a config module matching all or part of the hostname
16 2     2   11 use Sys::Hostname;
  2         4  
  2         333  
17 2         11 my $hostname = Sys::Hostname::hostname();
18 2         15 my @hwords = reverse split('\.',$hostname);
19 2         12 while (@hwords) {
20 2         7 my $pkg = 'Genome::Site::' . join("::",@hwords);
21 2         9 local $SIG{__DIE__};
22 2         6 local $SIG{__WARN__};
23 2     2   153 eval "use $pkg";
  2         953  
  0            
  0            
24 2 50       10 if ($@) {
25 2         4 pop @hwords;
26 2         178 next;
27             }
28             else {
29 0         0 last;
30             }
31             }
32             }
33             }
34              
35             # This module potentially conflicts to the perl-supplied Config.pm if you've
36             # set up your @INC or -I options incorrectly. For example, you used -I /path/to/modules/Genome/
37             # instead of -I /path/to/modules/. Many modules use the real Config.pm to get info and
38             # you'll get wierd failures if it loads this module instead of the right one.
39             {
40             my @caller_info = caller(0);
41             if ($caller_info[3] eq '(eval)' and $caller_info[6] eq 'Config.pm') {
42             die "package Genome::Config was loaded from a 'use Config' statement, and is not want you wanted. Are your \@INC and -I options correct?";
43             }
44             }
45              
46             1;
47              
48             =pod
49              
50             =head1 NAME
51              
52             Genome::Site - hostname oriented site-based configuration
53              
54             =head1 DESCRIPTION
55              
56             Use the fully-qualified hostname to look up site-based configuration.
57              
58             =head1 AUTHORS
59              
60             This software is developed by the analysis and engineering teams at
61             The Genome Center at Washington Univiersity in St. Louis, with funding from
62             the National Human Genome Research Institute.
63              
64             =head1 LICENSE
65              
66             This software is copyright Washington University in St. Louis. It is released under
67             the Lesser GNU Public License (LGPL) version 3. See the associated LICENSE file in
68             this distribution.
69              
70             =head1 BUGS
71              
72             For defects with any software in the genome namespace,
73             contact genome-dev@genome.wustl.edu.
74              
75             =cut
76