summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Chilton <andychilton@gmail.com>2008-07-05 15:52:40 +1200
committerAndrew Chilton <andychilton@gmail.com>2008-07-05 15:52:40 +1200
commit68c0b1e19dd90db236a5b9dd862ab3251c0817a0 (patch)
tree3ac48050b8aa948f88cbf4492799ed3856e0a1fd /lib
parentf6649a52ff5610af925818cddd720fa5945bd6b3 (diff)
Imported Upstream version 0.5.0upstream/0.5.0
Diffstat (limited to 'lib')
-rw-r--r--lib/CIL.pm26
-rw-r--r--lib/CIL/Utils.pm2
2 files changed, 19 insertions, 9 deletions
diff --git a/lib/CIL.pm b/lib/CIL.pm
index ee85064..9a87bf9 100644
--- a/lib/CIL.pm
+++ b/lib/CIL.pm
@@ -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 );
}