Skip to content

Commit 4ac43de

Browse files
committed
Modified test so that it worked with an array being returned, which was original intention.
Added use of the module to bin/generate-configs.pl Also moved current templates to vendor/oclc. This isn't strictly correct as there were some templates I downloaded from elsewhere, but we can sort those out later.
1 parent c289648 commit 4ac43de

File tree

483 files changed

+26
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

483 files changed

+26
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*cfg
33
*stanza
44
conf.d
5+
local

bin/generate-configs.pl

+23-14
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
use Config::General ;
88
use File::Spec ;
99

10+
use lib 'lib' ;
11+
use lib '../lib' ;
12+
use TemplatePaths ;
1013

11-
########################################
14+
15+
#######################################
1216
## Start config setup
1317

1418
my $conf = Config::General->new('ezproxy-collaborate.cfg');
@@ -37,35 +41,40 @@
3741
or die "Could not open $config{INCLUDE_FILE} $!" ;
3842

3943

40-
opendir(my $template_dir, $config{TEMPLATE_DIR}) or die "Can't open template directory ( $config{TEMPLATE_DIR} ) $!" ;
41-
42-
FILE: while( my $filepath = readdir( $template_dir ) ) {
44+
#opendir(my $template_dir, $config{TEMPLATE_DIR}) or die "Can't open template directory ( $config{TEMPLATE_DIR} ) $!" ;
4345

44-
if( $filepath !~ /\.template$/) {
45-
next FILE ;
46-
}
46+
my @template_filepaths = TemplatePaths::template_paths_array() ;
4747

48-
my $id = $filepath ;
48+
FILE: while( my $template_info = shift @template_filepaths ) {
49+
50+
# if( $filepath !~ /\.template$/) {
51+
# next FILE ;
52+
# }
53+
54+
my $id = $template_info->{name} ;
4955
$id =~ s/(_i)?\.template// ;
5056

5157
# Setup the template
52-
my $template_filepath
53-
= File::Spec->catfile( $config{ TEMPLATE_DIR },
54-
$filepath ) ;
58+
my $template_filepath = $template_info->{path} ;
59+
5560
my $template
5661
= Text::Template->new( TYPE => 'FILE',
5762
SOURCE => $template_filepath ) ;
5863

5964

60-
if( $filepath =~ /_i.template$/ && !defined($stanzas_config_ref->{ $id } ) ) {
61-
warn "Institutional information needed for $id, but nothing found in stanza.cfg\n";
65+
if( $template_info->{name} =~ /_i.template$/ && !defined($stanzas_config_ref->{ $id } ) ) {
66+
warn "Institutional information needs to be added to stanza.cfg to correspond with the variables in the template file at $template_info->{path} \n";
6267
}
6368

6469
my $text = $template->fill_in( HASH => $stanzas_config_ref->{ $id } ) ;
6570

71+
if(! defined($text) ) {
72+
warn( $template_info->{path} . " seems to be an empty file, skipping " ) ;
73+
next FILE ;
74+
}
6675

6776
# Setup the output file
68-
my $target_filepath_init = $filepath ;
77+
my $target_filepath_init = $template_info->{name} ;
6978
$target_filepath_init =~ s/\.template$/.stanza/ ;
7079

7180
my $target_filepath = File::Spec->catfile($config{CONFIG_DIR},

t/TemplatePaths.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use lib "$FindBin::Bin/lib" ;
1313
use TemplatePaths ;
1414

1515

16-
my $templates_ref
16+
my @template_paths
1717
= TemplatePaths::template_paths_array({vendor_dir => 't/vendor',
1818
local_dir => 't/local',
1919
});
@@ -48,7 +48,7 @@ use Data::Dumper ;
4848
#diag( "Results of call: " . Dumper( $templates_ref ) . "\n\n") ;
4949
#diag( "Results of call: " . Dumper( $expected_ref ) . "\n\n") ;
5050

51-
is_deeply( $templates_ref, $expected_ref ) ;
51+
is_deeply( \@template_paths, $expected_ref ) ;
5252

5353

5454

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)