Changeset 32812


Ignore:
Timestamp:
2019-02-25T22:06:06+13:00 (5 years ago)
Author:
davidb
Message:

Refactored to use inheritance

Location:
main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/CSVPlugin.pm

    r32810 r32812  
    2929use SplitTextFile;
    3030use MetadataRead;
     31use CSVFieldSeparator;
     32
    3133use strict;
    3234no strict 'refs'; # allow filehandles to be variables and viceversa
     
    3638# CSVPlugin is a sub-class of SplitTextFile.
    3739sub BEGIN {
    38     @CSVPlugin::ISA = ('MetadataRead', 'SplitTextFile');
     40    @CSVPlugin::ISA = ('MetadataRead', 'SplitTextFile', 'CSVFieldSeparator');
    3941}
    4042
     
    4244my $arguments =
    4345    [
    44       { 'name' => "separate_char",
    45     'desc' => "{CSVPlugin.separate_char}",
    46     'type' => "string",
    47     'deft' => "auto",
    48     'reqd' => "no" },
    4946      { 'name' => "process_exp",
    5047    'desc' => "{BaseImporter.process_exp}",
     
    9087    push(@{$hashArgOptLists->{"OptList"}}, $options);
    9188
     89    new CSVFieldSeparator($pluginlist, $inputargs, $hashArgOptLists);
    9290    my $self = new SplitTextFile($pluginlist, $inputargs, $hashArgOptLists);
    9391
     
    120118    my $separate_char = $self->{'separate_char'};
    121119    if ($separate_char =~ m/^auto$/i) {
    122     $separate_char = CSVSeparateChar::resolve_auto($csv_file_field_line,$self->{'plugin_type'},$self->{'outhandle'},$self->{'verbosity'});
     120    $separate_char = $self->resolve_auto($csv_file_field_line,$self->{'plugin_type'},$self->{'outhandle'},$self->{'verbosity'});
    123121    # Replace the 'auto' setting the resolved value (for use later on)
    124122    $self->{'separate_char'} = $separate_char;
  • main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/MetadataCSVPlugin.pm

    r32810 r32812  
    3030use BaseImporter;
    3131use MetadataRead;
     32use CSVFieldSeparator;
    3233
    3334use strict;
     
    3839use util;
    3940
    40 use CSVSeparateChar;
    41 
    4241use Encode;
     42use Text::CSV;
    4343
    4444# methods with identical signatures take precedence in the order given in the ISA list.
    4545sub BEGIN {
    46     @MetadataCSVPlugin::ISA = ('MetadataRead', 'BaseImporter');
     46    @MetadataCSVPlugin::ISA = ('MetadataRead', 'BaseImporter', 'CSVFieldSeparator');
    4747}
    4848
     
    5050
    5151my $arguments = [
    52       { 'name' => "separate_char",
    53     'desc' => "{CSVPlugin.separate_char}",
    54     'type' => "string",
    55     'deft' => "auto",
    56     'reqd' => "no" },
    5752      { 'name' => "process_exp",
    5853    'desc' => "{BaseImporter.process_exp}",
     
    8075    push(@{$hashArgOptLists->{"OptList"}},$options);
    8176
     77    new CSVFieldSeparator($pluginlist, $inputargs, $hashArgOptLists);
    8278    my $self = new BaseImporter($pluginlist, $inputargs, $hashArgOptLists);
    8379
     
    154150
    155151    if ($separate_char =~ m/^auto$/i) {
    156     $separate_char = CSVSeparateChar::resolve_auto($csv_file_field_line,$self->{'plugin_type'},$outhandle,$self->{'verbosity'});
     152    $separate_char = $self->resolve_auto($csv_file_field_line,$self->{'plugin_type'},$outhandle,$self->{'verbosity'});
    157153    }
    158154
Note: See TracChangeset for help on using the changeset viewer.