Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/michal-josef-spacek/mets-files

Get page files from METS specification
https://github.com/michal-josef-spacek/mets-files

mets perl

Last synced: 25 days ago
JSON representation

Get page files from METS specification

Awesome Lists containing this project

README

        

NAME
METS::Files - Class for METS files manipulation.

SYNOPSIS
use METS::Files;

my $obj = METS::Files->new(
'mets_data' => $mets_data,
);
my @files = $obj->get_use_files($use);
my @types = $obj->get_use_types;

METHODS
"new"
my $obj = METS::Files->new(
'mets_data' => $mets_data,
);

Constructor.

* "mets_data"

METS data.

Parameter is required.

Returns instance of object.

"get_use_files"
my @files = $obj->get_use_files($use);

Get "USE" files defined by $use variable.

Returns array with files.

"get_use_types"
my @types = $obj->get_use_types;

Get "USE" types.

Returns array with types.

ERRORS
new():
Parameter 'mets_data' is required.
From Class::Utils::set_params():
Unknown parameter '%s'.

EXAMPLE1
use strict;
use warnings;

use Data::Printer;
use METS::Files;
use Perl6::Slurp qw(slurp);

# Arguments.
if (@ARGV < 1) {
print STDERR "Usage: $0 mets_file\n";
exit 1;
}
my $mets_file = $ARGV[0];

# Get mets data.
my $mets_data = slurp($mets_file);

# Object.
my $obj = METS::Files->new(
'mets_data' => $mets_data,
);

# Get files.
my $files_hr;
foreach my $use ($obj->get_use_types) {
$files_hr->{$use} = [$obj->get_use_files($use)];
}

# Dump to output.
p $files_hr;

# Output without arguments like:
# Usage: __SCRIPT__ mets_file

EXAMPLE2
use strict;
use warnings;

use Data::Printer;
use METS::Files;

# Example METS data.
my $mets_data = <<'END';





















END

# Object.
my $obj = METS::Files->new(
'mets_data' => $mets_data,
);

# Get files.
my $files_hr;
foreach my $use ($obj->get_use_types) {
$files_hr->{$use} = [$obj->get_use_files($use)];
}

# Dump to output.
p $files_hr;

# Output:
# \ {
# Images [
# [0] "file://./003855/003855r.tif",
# [1] "file://./003855/003855v.tif"
# ],
# PDF [
# [0] "file://./003855/003855r.pdf",
# [1] "file://./003855/003855v.pdf"
# ]
# }

DEPENDENCIES
Class::Utils, Error::Pure, METS::Parse::Simple, Readonly.

REPOSITORY

AUTHOR
Michal Josef Špaček

LICENSE AND COPYRIGHT
© 2015-2024 Michal Josef Špaček

BSD 2-Clause License

VERSION
0.04