Apache-Tika-Async

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

        update_file( $example_file, $examples );
    };
};

sub update_file {
    my( $filename, $new_content ) = @_;
    my $content;
    if( -f $filename ) {
        open my $fh, '<', $filename
            or die "Couldn't read '$filename': $!";
        binmode $fh;
        local $/;
        $content = <$fh>;
    };

    if( $content ne $new_content ) {
        if( open my $fh, '>', $filename ) {
            binmode $fh;
            print $fh $new_content;
        } else {
            warn "Couldn't (re)write '$filename': $!";
        };
    };
}

lib/Apache/Tika/Async.pm  view on Meta::CPAN

    return $self->_tika_config_xml(
        logLevel => $self->loglevel,
        %entries
    );
}

sub tika_config_temp_file {
    my( $self, %entries ) = @_;

    my( $fh, $name ) = tempfile();
    binmode $fh;
    print {$fh} $self->tika_config(%entries);
    close $fh;

    return $name;
}

sub best_jar_file {
    my( $package, @files ) = @_;
    # Do a natural sort on the dot-version
    (sort { my $ad; $a =~ /\bserver-(?:standard-|)(\d+)\.(\d+)/ and $ad=sprintf '%02d.%04d', $1, $2;

lib/Apache/Tika/Server.pm  view on Meta::CPAN

#    hello world
sub fetch {
    my( $self, %options )= @_;
    $options{ type }||= 'text';
    my $url= $self->url( $options{ type } );

    if(! $options{ content } and $options{ filename }) {
        # read $options{ filename }
        open my $fh, '<', $options{ filename }
            or croak "Couldn't read '$options{ filename }': $!";
        binmode $fh;
        local $/;
        $options{ content } = <$fh>;
    };

    my $method;
    if( 'test' eq $options{ type } ) {
        $method= 'get';

    } else {
        $method= 'put';

xt/99-unix-text.t  view on Meta::CPAN


sub wanted {
  push @files, $File::Find::name if /\.p(l|m|od)$/;
}

sub unix_file_ok {
  my ($filename) = @_;
  local $/;
  open F, "< $filename"
    or die "Couldn't open '$filename' : $!\n";
  binmode F;
  my $content = <F>;

  my $i;
  my @lines = grep { /\x0D\x0A$/sm } map { sprintf "%s: %s\x0A", $i++, $_ } split /\x0A/, $content;
  unless (is(scalar @lines, 0,"'$filename' contains no windows newlines")) {
    diag $_ for @lines;
  };
  close F;
};



( run in 0.337 second using v1.01-cache-2.11-cpan-8d75d55dd25 )