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

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

  ViewVC Help
Powered by ViewVC 1.1.26