/[webpac2]/trunk/lib/WebPAC/Common.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Common.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 887 by dpavlin, Mon Sep 3 15:26:46 2007 UTC revision 948 by dpavlin, Thu Nov 1 00:16:46 2007 UTC
# Line 1  Line 1 
1  package WebPAC::Common;  package WebPAC::Common;
2    use Exporter 'import';
3    @EXPORT = qw/
4            force_array
5    /;
6    
7  use warnings;  use warnings;
8  use strict;  use strict;
# Line 7  use Log::Log4perl qw/get_logger :levels/ Line 11  use Log::Log4perl qw/get_logger :levels/
11  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
12  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
13  use File::Spec;  use File::Spec;
14    use Cwd qw/abs_path/;
15    
16  use base qw/Class::Accessor/;  use base qw/Class::Accessor/;
17  __PACKAGE__->mk_accessors( qw/log_debug no_log debug/ );  __PACKAGE__->mk_accessors( qw/log_debug no_log debug/ );
# Line 163  sub fill_in { Line 168  sub fill_in {
168    
169  =cut  =cut
170    
171    my $abs_path;
172    
173  sub var_path {  sub var_path {
174          my $self = shift;          my $self = shift;
175    
176          return File::Spec->catfile('var', @_);          if ( ! $abs_path ) {
177    #               $abs_path = abs_path( $0 );
178    #               $abs_path =~ s!/WebPAC/Common\.pm!!;
179                    $abs_path = '/data/webpac2';
180            }
181    
182            return File::Spec->catfile($abs_path, 'var', @_);
183    }
184    
185    =head1 EXPORTED NETHODS
186    
187    =head2 force_array
188    
189      my @array = force_array( $ref, sub {
190            warn "reference is undefined!";
191      });
192    
193    =cut
194    
195    sub force_array {
196            my ( $what, $error ) = @_;
197            my @result;
198            if ( ref( $what ) eq 'ARRAY' ) {
199                    @result = @{ $what };
200            } elsif ( defined $what ) {
201                    @result =  ( $what );
202            } else {
203                    $error->() if ref($error) eq 'CODE';
204            }
205            return @result;
206  }  }
207    
208    
# Line 231  sub _init_logger { Line 267  sub _init_logger {
267          my $conf = q( );          my $conf = q( );
268          if ($self->no_log) {          if ($self->no_log) {
269                  warn "# $name disabled logging\n" if $self->log_debug;                  warn "# $name disabled logging\n" if $self->log_debug;
270                    $Log::Log4perl::Config::CONFIG_INTEGRITY_CHECK = 0;
271          } elsif ($self->debug) {          } elsif ($self->debug) {
272                  $conf = << '_log4perl_';                  $conf = << '_log4perl_';
273    

Legend:
Removed from v.887  
changed lines
  Added in v.948

  ViewVC Help
Powered by ViewVC 1.1.26