return $self->{config}->{use_indexer} || $default;
}
+=head2 get
+
+ $config->get('top-level_key');
+
+=cut
+
+sub get {
+ my $self = shift;
+ my $what = shift || return;
+ return $self->{config}->{$what};
+}
+
+=head2 webpac
+
+Return C<< config -> webpac >> parts
+
+ my @supported_inputs = $config->webpac('inputs');
+ my $inputs_hash = $config->webpac('inputs');
+
+=cut
+
+sub webpac {
+ my $self = shift;
+
+ $self->_get_logger()->logdie("can't find config->webpac") unless defined( $self->{config}->{webpac} );
+
+ my $what = shift || return $self->{config}->{webpac};
+
+ if (wantarray) {
+ return keys %{ $self->{config}->{webpac}->{$what} };
+ } else {
+ return $self->{config}->{webpac}->{$what};
+ }
+
+}
+
=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
#!/usr/bin/perl -w
use strict;
-use Test::More tests => 8;
+use Test::More tests => 12;
use Test::Exception;
use blib;
my $path = "$abs_path/conf/test.yml";
-ok(my $c = new WebPAC::Config( path => $path ), "new");
+ok(my $config = new WebPAC::Config( path => $path ), "new");
-cmp_ok($c->{path}, 'eq', $path, "path $path");
+cmp_ok($config->{path}, 'eq', $path, "path $path");
-ok($c->{config}, "config exist");
+ok($config->{config}, "config exist");
-isa_ok($c->databases, 'HASH', "databases");
-
-my @names = $c->databases;
+# $config->databases
+isa_ok($config->databases, 'HASH', "databases");
+my @names = $config->databases;
isa_ok(\@names, 'ARRAY', "databases names");
-
cmp_ok(@names, '==', 3, "got 3 names");
+isa_ok($config->databases, 'HASH', "databases");
+
+diag '$config->webpac = ', dump($config->webpac) if ($debug);
+
+isa_ok($config->webpac, 'HASH', "webpac");
+my @inputs = $config->webpac('inputs');
+diag "inputs = ",dump( @inputs ) if ($debug);
+isa_ok(\@inputs, 'ARRAY', "inputs");
+cmp_ok(@inputs, '==', 2, "got 2 webpac inputs");
--- /dev/null
+--- #YAML:1.0
+# DO NOT USE TABS FOR INDENTATION OR label/value SEPARATION!!!
+
+webpac:
+ inputs:
+ isis: 'WebPAC::Input::ISIS'
+ marc: 'WebPAC::Input::MARC'
+
+databases:
+ foo:
+ name: 'foo name'
+ input:
+ name: 'foo-input1'
+ type: isis
+ path: '/backup/isis_backup/A105-1/ISIS/latest/LIBRI/LIBRI'
+ encoding: 'cp852'
+ #limit: 10
+ normalize:
+ path: 'conf/normalize/foo.pl'
+
+ bar:
+ name: 'bar name'
+ input:
+ name: 'bar-input1'
+ type: isis
+ path: '/backup/isis_backup/A105-1/ISIS/latest/LIBRI/LIBRI'
+ encoding: 'cp852'
+ #limit: 10
+ normalize:
+ path: 'conf/normalize/bar.pl'
+
+ baz:
+ name: 'baz name'
+ input:
+ name: 'baz-input1'
+ type: isis
+ path: '/backup/isis_backup/A105-1/ISIS/latest/LIBRI/LIBRI'
+ encoding: 'cp852'
+ #limit: 10
+ normalize:
+ path: 'conf/normalize/baz.pl'