- if ( -f $full_path ) {
- if ( $full_path =~ m/.storable$/ ) { # check storable first to catch files copied from /tmp/
- $data->{generated}++;
- warn "open $full_path ", -s $full_path, " bytes";
- open(my $pipe, "<", $full_path) || die $!;
- while ( my $o = eval { Storable::fd_retrieve $pipe } ) {
- if ( exists $o->{item} ) {
- # stream of storable objects
- push @{ $data->{items} }, $o->{item};
- } elsif ( exists $o->{data}->{items} ) {
- # /tmp/mojofacets.*.storable
- $data->{items} = $o->{data}->{items};
- $data->{header} = $o->{header};
- delete $data->{generated};
- } else {
- warn "SKIP ",dump($o);
- }
- }
- close($pipe);
- warn "loaded ", $#{ $data->{items} } + 1, " items from $full_path\n";
- } elsif ( $full_path =~ m/.csv/i ) {
- $data = MojoFacets::Import::CSV->new( full_path => $full_path )->data;
- } elsif ( $full_path =~ m/.sql/i ) {
- $data = MojoFacets::Import::SQL->new( full_path => $full_path )->data;
- } elsif ( $full_path =~ m/.couchdb/i ) {
- $data = MojoFacets::Import::CouchDB->new( full_path => $full_path )->data;
- } else {
- $data = MojoFacets::Import::File->new( full_path => $full_path, path => $path )->data;
- }
- } elsif ( -d $full_path && $full_path =~ m/.html/ ) {
- $data = MojoFacets::Import::HTMLTable->new( dir => $full_path )->data;