leanback 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -7
- data/VERSION +1 -1
- data/leanback.gemspec +3 -3
- data/lib/leanback.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 607f66bb87596d4933f4018cb2b52c45ec3610e0
|
4
|
+
data.tar.gz: 077dbf53fcaac90c9c3a82e3038d12616aea48c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5631435bdbdd372e2c8d35c12cfcb0ac1ff1e9cbb9e8364d6a1f575df780bc1cb0bd37925d98f2950db22a7378db21985347f543d5905784c80c32c3c1c9c64e
|
7
|
+
data.tar.gz: 1100a6f839ec35fe741e3e2b6d206ba1825d56ad34f36b972b01c0fe65036694928cc3babf2ba1610a73e726dd150d17a2909cf7bc648afed818415f1931a1a5
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
###Leanback
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/obi-a/leanback.svg?branch=master)](https://travis-ci.org/obi-a/leanback)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/leanback.svg)](http://badge.fury.io/rb/leanback)
|
4
5
|
|
5
|
-
Simple Ruby Interface to CouchDB. This current version is a complete re-write with a new API.
|
6
|
+
Simple Ruby Interface to CouchDB. This current version is a complete re-write with a new API. I wrote this to use in my projects, I hope you find it useful.
|
6
7
|
|
7
8
|
### Installation:
|
8
9
|
```
|
@@ -375,9 +376,10 @@ Subsequent method calls will simply query the view and return the documents. whe
|
|
375
376
|
###Security Object:
|
376
377
|
To set the security object for the database:
|
377
378
|
```ruby
|
378
|
-
security_settings = {
|
379
|
-
|
380
|
-
|
379
|
+
security_settings = {
|
380
|
+
admins: {names: ["david"], roles: ["admin"]},
|
381
|
+
readers: {names: ["david"],roles: ["admin"]}
|
382
|
+
}
|
381
383
|
|
382
384
|
my_database.security_object = security_settings
|
383
385
|
#=> {:admins=>{:names=>["david"], :roles=>["admin"]},
|
@@ -421,6 +423,21 @@ config.set_config("admins", username = "james", password = '"abc123"')
|
|
421
423
|
```
|
422
424
|
This will add a CouchDB admin with username james, and password abc123. If couchDB was in admin party mode, this would end the party.
|
423
425
|
|
426
|
+
##Exception handling
|
427
|
+
For CouchDB errors Leanback raises a Leanback::Exception object. This object has a response attribute which is a hash that contains the details of the error response from CouchDB. See an example below
|
428
|
+
```ruby
|
429
|
+
begin
|
430
|
+
my_database.get_doc('dontexist')
|
431
|
+
rescue Leanback::CouchdbException => e
|
432
|
+
puts e.response.inspect
|
433
|
+
#=> {:error=>"not_found", :reason=>"missing"}
|
434
|
+
puts e.response[:error].inspect
|
435
|
+
#=> "not_found"
|
436
|
+
puts e.response[:reason].inspect
|
437
|
+
#=> "missing"
|
438
|
+
end
|
439
|
+
```
|
440
|
+
|
424
441
|
##API Specification
|
425
442
|
|
426
443
|
```ruby
|
@@ -457,9 +474,10 @@ design_doc_name = "_design/my_doc"
|
|
457
474
|
view_name = "get_emails"
|
458
475
|
c.view design_doc_name, view_name, options
|
459
476
|
|
460
|
-
security_settings = {
|
461
|
-
|
462
|
-
|
477
|
+
security_settings = {
|
478
|
+
admins: {names: ["david"], roles: ["admin"]},
|
479
|
+
readers: {names: ["david"],roles: ["admin"]}
|
480
|
+
}
|
463
481
|
|
464
482
|
c.security_object = security_settings
|
465
483
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/leanback.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: leanback 0.5.
|
5
|
+
# stub: leanback 0.5.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "leanback"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Obi Akubue"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-08-11"
|
15
15
|
s.description = "Simple Ruby interface to CouchDB"
|
16
16
|
s.email = "obioraakubue@yahoo.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/leanback.rb
CHANGED
@@ -135,12 +135,12 @@ module Leanback
|
|
135
135
|
def generate_json(data)
|
136
136
|
JSON.generate(data)
|
137
137
|
end
|
138
|
-
def raise_error(
|
139
|
-
if
|
140
|
-
response = parse_json(
|
138
|
+
def raise_error(exception)
|
139
|
+
if exception.respond_to?('response')
|
140
|
+
response = parse_json(exception.response) rescue exception.response
|
141
141
|
raise(CouchdbException.new(response), response)
|
142
142
|
else
|
143
|
-
raise(
|
143
|
+
raise(exception)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
def auth_session
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leanback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Obi Akubue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|