CouchDB-Client
view release on metacpan or search on metacpan
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: CouchDB-Client
no_index:
directory:
- inc
- t
requires:
HTTP::Request: 0
JSON::Any: 1.17
LWP::UserAgent: 0
MIME::Base64: 0
URI::Escape: 0
perl: 5.6.0
resources:
homepage: http://github.com/maverick/couchdb-client
license: http://dev.perl.org/licenses/
repository: git://github.com/maverick/couchdb-client.git
version: 0.09
Makefile.PL view on Meta::CPAN
license 'perl';
all_from 'lib/CouchDB/Client.pm';
# override the default author detection behavior
author 'Maverick Edwards <maverick @t smurfbane d.t org>';
resources 'repository' => 'git://github.com/maverick/couchdb-client.git';
resources 'homepage' => 'http://github.com/maverick/couchdb-client';
requires 'JSON::Any' => '1.17';
requires 'LWP::UserAgent';
requires 'HTTP::Request';
requires 'URI::Escape';
requires 'MIME::Base64';
# we need a JSON module that isn't Syck (no UTF-8 support makes it useless)
sub check_json () {
my @order = qw(XS JSON DWIW);
foreach my $testmod (@order) {
$testmod = "JSON::$testmod" unless $testmod eq "JSON";
eval "require $testmod";
return unless $@;
lib/CouchDB/Client.pm view on Meta::CPAN
package CouchDB::Client;
use strict;
use warnings;
our $VERSION = '0.09';
use JSON::Any qw(XS JSON DWIW);
use LWP::UserAgent qw();
use HTTP::Request qw();
use Encode qw(encode);
use Carp qw(confess);
use CouchDB::Client::DB;
sub new {
my $class = shift;
my %opt = @_ == 1 ? %{$_[0]} : @_;
my %self;
lib/CouchDB/Client.pm view on Meta::CPAN
my $self = shift;
my $meth = shift;
my $path = shift;
my $content = shift;
my $headers = undef;
if (ref $content) {
$content = encode('utf-8', $self->{json}->encode($content));
$headers = HTTP::Headers->new('Content-Type' => 'application/json');
}
my $res = $self->{ua}->request( HTTP::Request->new($meth, $self->uriForPath($path), $headers, $content) );
my $ret = {
status => $res->code,
msg => $res->status_line,
success => 0,
};
if ($res->is_success) {
$ret->{success} = 1;
$ret->{json} = $self->{json}->decode($res->content);
}
return $ret;
lib/CouchDB/Client/Doc.pm view on Meta::CPAN
package CouchDB::Client::Doc;
use strict;
use warnings;
our $VERSION = $CouchDB::Client::VERSION;
use HTTP::Request qw();
use URI::Escape qw(uri_escape_utf8);
use MIME::Base64 qw(encode_base64);
use Carp qw(confess);
sub new {
my $class = shift;
my %opt = @_ == 1 ? %{$_[0]} : @_;
confess "Doc needs a database" unless $opt{db};
lib/CouchDB/Client/Doc.pm view on Meta::CPAN
$self->{attachments} = {};
return $self;
}
sub fetchAttachment {
my $self = shift;
my $attName = shift;
confess("No such attachment: '$attName'") unless exists $self->{attachments}->{$attName};
my $res = $self->{db}->{client}->{ua}->request(
HTTP::Request->new('GET', $self->{db}->{client}->uriForPath($self->uriName . '/' . uri_escape_utf8($attName)))
);
return $res->content if $res->is_success;
confess("Object not found: $res->{msg}");
}
sub addAttachment {
my $self = shift;
my $name = shift;
my $ctype = shift;
my $data = shift;
( run in 0.827 second using v1.01-cache-2.11-cpan-de7293f3b23 )