In progress commit

This commit is contained in:
Thomas Bloor 2019-07-02 15:21:01 +01:00
parent 1d22da2bed
commit bea1301475
No known key found for this signature in database
GPG key ID: 4657C7EBE42CC5CC
19 changed files with 478 additions and 79 deletions

View file

@ -0,0 +1,46 @@
package Pear::LocalLoop::Import::Role::CSV;
use strict;
use warnings;
use Moo::Role;
use Text::CSV;
requires 'csv_required_columns';
has csv_file => (
is => 'ro',
required => 1,
);
has _csv_filehandle => (
is => 'lazy',
builder => sub {
open my $fh, '<', $self->csv_file;
return $fh;
}
);
has text_csv_options => (
is => 'lazy',
builder => sub {
return {
binary => 1,
allow_whitespace => 1,
};
}
);
has _text_csv => (
is => 'lazy',
builder => sub {
return Text::CSV->new(shift->text_csv_options);
}
);
has csv_data => (
is => 'lazy',
builder => sub {
my $self = shift;
}
);
1;

View file

@ -0,0 +1,19 @@
package Pear::LocalLoop::Import::Role::ExternalName;
use strict;
use warnings;
use Moo::Role;
requires qw/
external_name
schema
/;
has external_result => (
is => 'lazy',
builder => sub {
my $self = shift;
return $self->resultset('ExternalReference')->find_or_create({ name => $self->external_name });
}
);
1;

View file

@ -0,0 +1,11 @@
package Pear::LocalLoop::Import::Role::Schema;
use strict;
use warnings;
use Moo::Role;
has schema => (
is => 'ro',
required => 1,
);
1;