AnyEvent-Groonga

 view release on metacpan or  search on metacpan

lib/AnyEvent/Groonga.pm  view on Meta::CPAN

    my $cv = AnyEvent->condvar;

    $self->_set_timeout( $cv, $args_ref->{timeout} ) if $args_ref->{timeout};

    http_get(
        $url,
        sub {
            my $json = shift;
            my $result;
            try {
                my $data = JSON->new->utf8->decode($json);
                $result = AnyEvent::Groonga::Result->new(
                    posted_command => $command,
                    data           => $data
                );
            }
            catch {
                $result = $_;
            };
            $cv->send($result);
        }

lib/AnyEvent/Groonga.pm  view on Meta::CPAN


    my $cmd_cv = run_cmd $groonga_command,
        '>'  => \my $stdout,
        '2>' => \my $stderr;

    $cmd_cv->cb(
        sub {
            my $json = $stdout;
            my $result;
            try {
                my $data = JSON->new->utf8->decode($json);
                $result = AnyEvent::Groonga::Result->new(
                    posted_command => $command,
                    data           => $data
                );
            }
            catch {
                $result = $_;
            };
            $cv->send($result);
        }

lib/AnyEvent/Groonga.pm  view on Meta::CPAN

        push @array, ( $key, $value );
    }
    $groonga_command .= join( " ", @array ) . '"';
    warn($groonga_command) if $self->debug;
    return $groonga_command;
}

sub _select_filter {
    my $self = shift;
    my $data = shift;
    $data = decode( "utf8", $data ) unless utf8::is_utf8($data);
    $data =~ /(^|[^\\])"|'/;
    if ($1) {
        $data =~ s/(^|[^\\])"|'/$1\\"/g;
    }
    else {
        $data =~ s/(^|[^\\])"|'/\\"/g;
    }
    return '\'' . $data . '\'';
}

lib/AnyEvent/Groonga/Result.pm  view on Meta::CPAN

    return $self;
}

sub dump {
    my $self = shift;
    {
        no warnings 'redefine';
        local *Data::Dumper::qquote = sub { return shift; };
        local $Data::Dumper::Useperl = 1;

        return encode( "utf8", decode( "utf8", Dumper( $self->data ) ) );
    }
}

sub status {
    my $self   = shift;
    my $status = $self->data->[0]->[0];
    return $status ? 0 : 1;
}

sub start_time {

lib/AnyEvent/Groonga/Result.pm  view on Meta::CPAN

=head1 SYNOPSIS

  my $result = $groonga->call( $command => $args_ref )->recv;
  
  my $status     = $result->status;
  my $start_time = $result->start_time;
  my $elapsed    = $result->elapsed;
  
  print $result->body; # main body contents of result data
  
  print $result->dump; # it dumps the results by un-flagged utf8


=head1 DESCRIPTION

Result class AnyEvent::Groonga.
It is easy to use groonga results for perlish.

=head1 METHOD

=head2 new

t/05_regression.t  view on Meta::CPAN

use strict;
use warnings;
use utf8;
use lib '../lib';
use AnyEvent::Groonga;
use Test::More;
use FindBin;
use File::Spec;

unlink $_ for glob( File::Spec->catfile( $FindBin::RealBin, "data", "*") );

my $g = AnyEvent::Groonga->new( debug => 0 );
my $groonga_path = $g->groonga_path;



( run in 1.040 second using v1.01-cache-2.11-cpan-49f99fa48dc )