File Coverage

blib/lib/WE_Frontend/MainAny.pm
Criterion Covered Total %
statement 9 42 21.4
branch 0 18 0.0
condition 0 6 0.0
subroutine 3 5 60.0
pod 0 1 0.0
total 12 72 16.6


line stmt bran cond sub pod time code
1             # -*- perl -*-
2              
3             #
4             # $Id: MainAny.pm,v 1.4 2003/12/16 15:21:23 eserte Exp $
5             # Author: Slaven Rezic
6             #
7             # Copyright (C) 2002 Online Office Berlin. All rights reserved.
8             # Copyright (C) 2002 Slaven Rezic.
9             # This is free software; you can redistribute it and/or modify it under the
10             # terms of the GNU General Public License, see the file COPYING.
11              
12             #
13             # Mail: slaven@rezic.de
14             # WWW: http://we-framework.sourceforge.net
15             #
16              
17             package WE_Frontend::MainAny;
18              
19 3     3   2711 use strict;
  3         8  
  3         117  
20 3     3   15 use vars qw($VERSION $VERBOSE);
  3         6  
  3         581  
21             $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/);
22              
23             $VERBOSE = 0 if !defined $VERBOSE;
24              
25             sub new {
26 0     0 0   my($class, $root) = @_;
27              
28             my $get_wesiteinfo = sub {
29 0     0     my $wesiteinfo = $INC{"WEsiteinfo.pm"};
30 0 0         if (!defined $wesiteinfo) {
31 0           die "Strange: WEsiteinfo can be required, but is not recorded in \%INC";
32             }
33 0 0         if (!-r $wesiteinfo) {
34 0           die "Strange: WEsiteinfo can be required, but the file $wesiteinfo is not accessible";
35             }
36 0           $wesiteinfo;
37 0           };
38              
39             # try for new implementation:
40 3     3   16 use vars qw($c);
  3         4  
  3         915  
41 0           require File::Spec;
42 0           my $err;
43             {
44 0 0         unless ($VERBOSE) {
  0            
45 0           open(OLDERR, ">&STDERR");
46 0 0         open(STDERR, ">".File::Spec->devnull) or die $!;
47             }
48 0           eval 'use WEsiteinfo qw($c)';
49 0           $err = $@;
50 0 0 0       if ($VERBOSE && $err) {
51 0           warn "warn at line " . __LINE__ . ": " . $err;
52             }
53 0 0         unless ($VERBOSE) {
54 0           open(STDERR, ">&OLDERR");
55 0           close OLDERR;
56             }
57             }
58 0 0         if (!$err) {
59 0           my $wesiteinfo = $get_wesiteinfo->();
60 0           require WE_Frontend::Main2;
61 0           return WE_Frontend::Main->new(-root => $root, -config => $c);
62             }
63              
64             # try for old implementation
65 0           eval 'use WEsiteinfo qw($rootdir)';
66 0           $err = $@;
67 0 0 0       if ($VERBOSE && $err) {
68 0           warn "warn at line " . __LINE__ . ": " . $err;
69             }
70 0 0         if (!$err) {
71 0           require WE_Frontend::Main;
72 0           return WE_Frontend::Main->new($root);
73             }
74              
75 0           die $err;
76             }
77              
78             1;
79              
80             __END__