Changeset 177
- Timestamp:
- 02/25/07 11:03:39 (2 years ago)
- Files:
-
- trunk/src/core/Kwiki/lib/Kwiki/Boot/V1.pm (modified) (1 diff)
- trunk/src/core/Spoon/lib/Spoon/Config.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/core/Kwiki/lib/Kwiki/Boot/V1.pm
r175 r177 16 16 $self->config->add_file('config.yaml'); 17 17 for my $filepath (glob 'config*.*') { 18 $self->config->add_ override_filepath($filepath);18 $self->config->add_config($filepath, 1); 19 19 } 20 20 } trunk/src/core/Spoon/lib/Spoon/Config.pm
r175 r177 4 4 const class_id => 'config'; 5 5 field plugin_classes => []; 6 field overrides => {};7 6 8 7 sub all { 9 8 return %$self; 10 }11 12 sub add_override_filepath {13 my $filepath = shift;14 my $hash = $self->hash_from_file($filepath);15 my $overrides = $self->overrides;16 $overrides->{$_} = $hash->{$_} for keys %$hash;17 $self->add_config($hash);18 9 } 19 10 … … 22 13 for my $dir ($self->hub->paths->all_filepaths('config')) { 23 14 my $filepath = "$dir/$file"; 24 $self->add_ filepath($filepath)15 $self->add_config($filepath, @_) 25 16 if -f $filepath; 26 17 } 27 18 } 28 19 29 sub add_filepath {30 my $filepath = shift;31 my $hash = $self->hash_from_file($filepath);32 $self->add_config($hash);33 $self->add_config($self->overrides);34 }35 36 # sub add_field {37 # my ($field, $value) = @_;38 # field $field;39 # $self->{$field} = $value;40 # }41 42 20 sub add_config { 43 21 my $config = shift; 22 my $override = shift || 0; 44 23 my $hash = ref $config 45 24 ? $config … … 47 26 for my $key (keys %$hash) { 48 27 field $key; 49 $self->{$key} = $hash->{$key}; 28 if ($override || not defined $self->{$key}) { 29 $self->{$key} = $hash->{$key}; 30 } 50 31 } 51 32 return $hash;
