In progress commit
This commit is contained in:
parent
1d22da2bed
commit
bea1301475
19 changed files with 478 additions and 79 deletions
46
lib/Pear/LocalLoop/Import/Role/CSV.pm
Normal file
46
lib/Pear/LocalLoop/Import/Role/CSV.pm
Normal 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;
|
19
lib/Pear/LocalLoop/Import/Role/ExternalName.pm
Normal file
19
lib/Pear/LocalLoop/Import/Role/ExternalName.pm
Normal 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;
|
11
lib/Pear/LocalLoop/Import/Role/Schema.pm
Normal file
11
lib/Pear/LocalLoop/Import/Role/Schema.pm
Normal 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;
|
Reference in a new issue