DBR/Admin/Utility.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 61 CC 5 SCAR 21.0
CC
5
Cov
0%
get_dbrh
20.0
get_dbr
6.0
BEGIN
2.0
CRAP 8.2
1 # the contents of this file are Copyright (c) 2004-2009 David Blood
2 # This program is free software; you can redistribute it and/or
3 # modify it under the terms of the GNU General Public License as
4 # published by the Free Software Foundation.
5  
6  
7  
8 package DBR::Admin::Utility;
9 use Exporter;
10  
11 use lib '/drj/tools/perl-dbr/lib';
12 use DBR;
13 use DBR::Util::Logger; # Any object that implements log, logErr, logDebug, logDebug2 and logDebug3 will do
14 use DBR::Util::Operator; # Imports operator functions
15 use DBR::Admin::Exception;
16  
17 #############
18 # globals here
19 @ISA = qw(Exporter);
20 @EXPORT = qw(
21  
22 );
23  
24 use strict;
25  
26  
27 #############
28 # local globals here
29  
30 my $dbr;
31 my $conf;
32  
33 ############
34 sub get_dbrh {
35  
36 if (!$conf) {
37 $conf = shift;
38 }
39  
40 if (!$conf) {
41 die "No conf file passed in at run time";
42 }
43  
44  
45
46 if (!defined $dbr) {
47 get_dbr();
48 }
49  
50 my $dbrh = $dbr->connect('dbrconf') ||
51 throw DrException(
52 message => "failed to connect to dbrconf: $!",
53 );
54  
55  
56  
57 return ($dbrh);
58  
59 }
60  
61 #################
62 sub get_dbr {
63  
64
65 if (!defined($dbr)) {
66  
67  
68  
69 my $logger = new DBR::Util::Logger(
70 -logpath => '/tmp/dbr_example.log',
71 -logLevel => 'debug3'
72 );
73  
74 $dbr = new DBR(
75 -logger => $logger,
76 -conf => $conf,
77  
78 );
79 }
80  
81 return $dbr;
82  
83 }
84  
85  
86 1;