| 21 | | my $dir = $self->assets_dir; |
|---|
| 22 | | my $dh = DirHandle->new($dir) or Plagger->context->error("$dir: $!"); |
|---|
| 23 | | for my $file (grep -f $_->[0] && $_->[1] =~ /\.yaml$/, |
|---|
| 24 | | map [ File::Spec->catfile($dir, $_), $_ ], sort $dh->read) { |
|---|
| 25 | | $self->load_plugin(@$file); |
|---|
| 26 | | } |
|---|
| 27 | | } |
|---|
| 28 | | |
|---|
| 29 | | sub load_plugin { |
|---|
| 30 | | my($self, $file, $base) = @_; |
|---|
| 31 | | |
|---|
| 32 | | Plagger->context->log(debug => "loading $file"); |
|---|
| 33 | | my $data = YAML::LoadFile($file); |
|---|
| 34 | | if (ref($data) eq 'ARRAY') { |
|---|
| 35 | | # redirectors.yaml ... make it backward compatible to ignore |
|---|
| 36 | | } else { |
|---|
| 37 | | push @{$self->{plugins}}, $data; |
|---|
| 38 | | } |
|---|
| | 21 | $self->load_assets( |
|---|
| | 22 | File::Find::Rule->name('*.yaml'), |
|---|
| | 23 | sub { |
|---|
| | 24 | my $file = shift; |
|---|
| | 25 | Plagger->context->log(debug => "loading $file"); |
|---|
| | 26 | my $data = YAML::LoadFile($file); |
|---|
| | 27 | if (ref($data) eq 'ARRAY') { |
|---|
| | 28 | # redirectors.yaml ... make it backward compatible to ignore |
|---|
| | 29 | } else { |
|---|
| | 30 | push @{$self->{plugins}}, $data; |
|---|
| | 31 | } |
|---|
| | 32 | }, |
|---|
| | 33 | ); |
|---|