Skip to content
Snippets Groups Projects
Commit 40186ccf authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- refactor: encapsulated title check

parent cddd4282
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,7 @@ package SLUB::LZA::SIPBuilderBagIt;
use File::Copy::Recursive qw(dircopy dirmove);
use File::Basename;
use File::Find;
use List::Util qw(none);
use LWP::UserAgent; # to get MARC data
use MARC::Record;
use Path::Tiny;
......@@ -568,6 +569,18 @@ PATCH
SLUB::LZA::SIPBuilderBagIt::create_slub_bagit($bagPath, \@addBagInfo);
}
sub checkForTitle($){
my $key_hash_list_aref = shift;
# collect all bag-info keys for easy check
my @keys;
for my $hash (@{$key_hash_list_aref}) {
push @keys, keys %{$hash};
}
# check for title
print_scalar_data("", "WARNING: No Title given. Please consider adding a human-readable title with '--add_key_value=Title:YOUR-TITLE'", "", "yellow")
if none { $_ =~ m/^[Tt][Ii][Tt][Ll][Ee]/ } @keys;
}
# end package
package main;
......@@ -587,7 +600,6 @@ use Getopt::Long;
use Path::Tiny;
use Carp; # confess()
use Pod::Usage; # pod2usage()
use List::Util qw(none);
my $save;
my $ieDirectory;
......@@ -768,12 +780,7 @@ sub main{
my $bagNameDir = SLUB::LZA::SIPBuilderBagIt::generateBagName($exportToArchiveDate, $ppn, $noppn);
# user hints
my @keys;
for my $hash (@addBagInfo) {
push @keys, keys %{$hash};
}
SLUB::LZA::SIPBuilderBagIt::print_scalar_data("", "WARNING: No Title given. Please consider adding a human-readable title with '--add_key_value=Title:YOUR-TITLE'", "", "yellow")
if none { $_ =~ m/^[Tt][Ii][Tt][Ll][Ee]/ } @keys;
SLUB::LZA::SIPBuilderBagIt::checkForTitle(\@addBagInfo);
# save options
if($save eq "copy") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment