NAME

Data::AnyXfer::Elastic::Import::Storage::Directory - Filesystem directory-based import storage

SYNOPSIS

my $storage =
    Data::AnyXfer::Elastic::Import::Storage::Directory->new;

$storage->set(
    company => 'Limited',
    address =>
        'Building One, Chiswick Park, 566 Chiswick High Road, London W4 5BE',
    regno => 1680058,
);

$storage->save;

DESCRIPTION

This module implements Data::AnyXfer::Elastic::Import::Storage, based on filesystem directories.

It uses temporary working directories, with persistence to an optional final target directory on "save" in Data::AnyXfer::Elastic::Import::Storage.

It represents items as single files, and can only store printable characters (i.e. any complex content should be serialised to a representable format before being passed to this module to store).

ATTRIBUTES

dir

Optional. The final target directory that data should be persisted to.

working_dir

Optional. The temporary directory data should be written to as operations are performed on this instance.

item_file_suffix

Optional. A string that will be appended to the end of every item name transparently when written to storage (will not be visible through the storage interface).

You can also use this for file extensions.

item_file_prefix

Optional. A string that will be prepended to the start of every item name transparently when written to storage (will not be visible through the storage interface).

STORAGE INTERFACE

Please see Data::AnyXfer::Elastic::Import::Storage for the interface definition and information.

ADDITIONAL METHODS

my @item_names = $storage->search('test');
# e.g. returns ( 'a_test_item', 'this_has_test_in_the_name_also' )

Searches the storage instance for any item names containing the supplied substring.

Returns a list of matching item names.

create_file_item

my ( $status, $fh ) = $self->create_file_item('item_1', 'Hello World!');

Adds a new item, containing the supplied content. Fails if an item under the specified name already exists.

In scalar context returns a boolean indicating success or failure. In list context returns the boolean status value followed by a Path::Class::File object pointing to the underlying file.

convert_item_name

my $item =
    $self->convert_item_name('some_random_string_with_unknown_chars');

Converts an arbritrary string to a format safe to be used by this storage backend as an item name.

This is not necessary on storage interface methods as this is handled transparently for you.

CAVEATS

This convertion is most likely one-way (lossy). Because of the normalisation, different strings can point to the same item, e.g. 'some_string' and 'some-string' are considered the same item.

COPYRIGHT

This software is copyright (c) 2019, Anthony Lucas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.