| | 59 | } |
|---|
| | 60 | |
|---|
| | 61 | sub load_include { |
|---|
| | 62 | my($self, $config) = @_; |
|---|
| | 63 | |
|---|
| | 64 | return unless $config->{include}; |
|---|
| | 65 | for (@{ $config->{include} }) { |
|---|
| | 66 | my $include = YAML::LoadFile($_); |
|---|
| | 67 | |
|---|
| | 68 | for my $key (keys %{ $include }) { |
|---|
| | 69 | my $add = $include->{$key}; |
|---|
| | 70 | unless ($config->{$key}) { |
|---|
| | 71 | $config->{$key} = $add; |
|---|
| | 72 | next; |
|---|
| | 73 | } |
|---|
| | 74 | if (ref($config->{$key}) eq 'HASH') { |
|---|
| | 75 | next unless ref($add) eq 'HASH'; |
|---|
| | 76 | for (keys %{ $include->{$key} }) { |
|---|
| | 77 | $config->{$key}->{$_} = $include->{$key}->{$_}; |
|---|
| | 78 | } |
|---|
| | 79 | } elsif (ref($include->{$key}) eq 'ARRAY') { |
|---|
| | 80 | $add = [ $add ] unless ref($add) eq 'ARRAY'; |
|---|
| | 81 | push(@{ $config->{$key} }, @{ $include->{$key} }); |
|---|
| | 82 | } elsif ($add) { |
|---|
| | 83 | $config->{$key} = $add; |
|---|
| | 84 | } |
|---|
| | 85 | } |
|---|
| | 86 | } |
|---|
| | 87 | } |
|---|
| | 88 | |
|---|
| | 89 | sub load_recipes { |
|---|
| | 90 | my($self, $config) = @_; |
|---|
| | 91 | |
|---|
| | 92 | for (@{ $config->{define_recipes} }) { |
|---|
| | 93 | $self->error("no such recipe to $_") unless $config->{recipe}->{$_}; |
|---|
| | 94 | my $plugin = $config->{recipe}->{$_}; |
|---|
| | 95 | $plugin = [ $plugin ] unless ref($plugin) eq 'ARRAY'; |
|---|
| | 96 | push(@{ $config->{plugins} }, @{ $plugin }); |
|---|
| | 97 | } |
|---|