Changeset 765
- Timestamp:
- 05/17/06 18:19:18
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger.pm
r745 r765 41 41 if (-e $opt{config} && -r _) { 42 42 $config = YAML::LoadFile($opt{config}); 43 $self->load_include($config);44 $self->{conf} = $config->{global};45 $self->{conf}->{log} ||= { level => 'debug' };46 43 $self->{config_path} = $opt{config}; 44 } elsif (ref($opt{config}) && ref($opt{config}) eq 'SCALAR') { 45 $config = YAML::Load(${$opt{config}}); 46 } elsif (ref($opt{config}) && ref($opt{config}) eq 'HASH') { 47 $config = $opt{config}; 47 48 } else { 48 49 croak "Plagger->bootstrap: $opt{config}: $!"; 49 50 } 51 52 $self->load_include($config); 53 $self->{conf} = $config->{global}; 54 $self->{conf}->{log} ||= { level => 'debug' }; 50 55 51 56 local *Plagger::context = sub { $self }; … … 65 70 sub rewrite_config { 66 71 my $self = shift; 72 73 unless ($self->{config_path}) { 74 $self->log(warn => "config is not loaded from file. Ignoring rewrite tasks."); 75 return; 76 } 67 77 68 78 open my $fh, $self->{config_path} or $self->error("$self->{config_path}: $!"); … … 234 244 $module = "Plagger::Plugin::$module"; 235 245 236 if ( my $path = $self->plugins_path->{$module}) {237 eval { require $path } or die $@;246 if ($module->isa('Plagger::Plugin')) { 247 $self->log(debug => "$module is loaded elsewhere ... maybe .t script?"); 238 248 } else { 239 $module->require or die $@; 249 if (my $path = $self->plugins_path->{$module}) { 250 eval { require $path } or die $@; 251 } else { 252 $module->require or die $@; 253 } 240 254 } 241 255
