diff options
author | Andrew Chilton <andychilton@gmail.com> | 2008-07-05 15:52:40 +1200 |
---|---|---|
committer | Andrew Chilton <andychilton@gmail.com> | 2008-07-05 17:50:58 +1200 |
commit | a3f13e665421896f16859628d0876530b4cc210e (patch) | |
tree | bfb59e57eb15fe5e02bfa85111f2dbe0e46bb822 /lib | |
parent | c3e2ac27a81aa8020165d27f0b7eab4fee079354 (diff) |
Imported Upstream version 0.5.0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CIL.pm | 26 | ||||
-rw-r--r-- | lib/CIL/Utils.pm | 2 |
2 files changed, 19 insertions, 9 deletions
@@ -30,6 +30,7 @@ __PACKAGE__->mk_accessors(qw( IssueDir StatusStrict StatusAllowed StatusOpen StatusClosed LabelStrict LabelAllowed + VCS UserName UserEmail )); @@ -217,19 +218,26 @@ sub read_config_file { } # set some defaults if we don't have any of these - foreach my $key ( keys %$defaults ) { - $cfg->{$key} ||= $defaults->{$key}; - } + %$cfg = (%$defaults, %$cfg); # for some things, make a hash out of them foreach my $hash_name ( @config_hashes ) { - my $h = {}; - my @list = ref $cfg->{"${hash_name}List"} eq 'ARRAY' ? @{$cfg->{"${hash_name}List"}} : $cfg->{"${hash_name}List"}; - foreach my $thing ( @list ) { - $h->{$thing} = 1; + # if we have nothing in the cfg hash already, set it to empty and move on + unless ( exists $cfg->{"${hash_name}List"} ) { + $cfg->{$hash_name} = {}; + next; } + + # if we only have a single item, turn it into an array first + my $key = "${hash_name}List"; + $cfg->{$key} = [ $cfg->{$key} ] unless ref $cfg->{$key} eq 'ARRAY'; + + # loop through all the items making up the hash + my $h = {}; + $h->{$_} = 1 + for @{ $cfg->{$key} }; $cfg->{$hash_name} = $h; - undef $cfg->{"${hash_name}List"}; + undef $cfg->{$key}; } # set each config item @@ -242,6 +250,8 @@ sub read_config_file { $self->LabelStrict( $cfg->{LabelStrict} ); $self->LabelAllowed( $cfg->{LabelAllowed} ); + + $self->VCS( $cfg->{VCS} ); } ## ---------------------------------------------------------------------------- diff --git a/lib/CIL/Utils.pm b/lib/CIL/Utils.pm index e9611cf..47f7ada 100644 --- a/lib/CIL/Utils.pm +++ b/lib/CIL/Utils.pm @@ -41,7 +41,7 @@ sub parse_cil_file { my ($class, $filename, $last_field) = @_; my @lines = read_file($filename); - return unless @lines; + return {} unless @lines; return $class->parse_from_lines( $last_field, @lines ); } |