cloudant 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/cloudant/client.rb +13 -8
- data/lib/cloudant/query_builder.rb +9 -2
- data/lib/cloudant/version.rb +1 -1
- 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: 617903591a37ae1748f18b5eae04fa09b888e1c9
|
4
|
+
data.tar.gz: f63d86f9d26940307786fcd17cb4bdf55c0c3ac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24f9c643c868ec3cbc735640bc226b8ff92e5325bad4093c7c71b05743faa5f6be9100533841890fe7ddc9244b9261d90b322b015d69b1c2385bffae32edc844
|
7
|
+
data.tar.gz: d73ed0447c65737c12f60c0793edc85eff2c77185e917196c126be47ba3b23a6b8203092b6512ef35dd7d8fc94e6189eac129a9234c1b772c98b63f31c349694
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Ruby Cloudant is a simple Ruby interface for [IBM Cloudant's](https://cloudant.com/) API. Cloudant is a NoSQL database built on [CouchDB](http://couchdb.apache.org/).
|
8
8
|
|
9
|
-
This gem is still in [development](
|
9
|
+
This gem is still in [development](#contributing) and is a work in progress.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -102,7 +102,7 @@ client.update_docs(docs)
|
|
102
102
|
# Deleting multiple docs
|
103
103
|
client.delete_docs(docs)
|
104
104
|
```
|
105
|
-
`:delete_docs` is a convenience method;
|
105
|
+
`:delete_docs` is a convenience method; this performs an update, adding `['_deleted']` to each document. [Bulk operations](https://docs.cloudant.com/document.html#bulk-operations)
|
106
106
|
|
107
107
|
**Indices, Design Docs**
|
108
108
|
```ruby
|
@@ -147,6 +147,7 @@ client.view(database,view_to_query, :reduce => false, :include_docs => true)
|
|
147
147
|
```
|
148
148
|
|
149
149
|
## To Do
|
150
|
+
|
150
151
|
- Add database replication functionality - `/_replicator`
|
151
152
|
- Allow new user creation - `/_security`
|
152
153
|
- Add more robust options handling for various queries (expanding the `QueryBuilder` module, as used in view querying)
|
data/lib/cloudant/client.rb
CHANGED
@@ -14,17 +14,19 @@ module Cloudant
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# Retrieve all docs from the database
|
17
|
-
|
18
|
-
def all_docs(*include_docs)
|
17
|
+
def all_docs(*opts)
|
19
18
|
q = "#{database}/_all_docs"
|
20
|
-
q << "
|
19
|
+
q << QueryBuilder.build(opts.first,"all_docs") if opts && opts.any? && opts.first.is_a?(Hash)
|
21
20
|
|
22
21
|
@conn.query({url_path: q, method: :get})
|
23
22
|
end
|
24
23
|
|
25
24
|
# Accepts a single document id and returns it if found
|
26
|
-
def get_doc(id)
|
27
|
-
|
25
|
+
def get_doc(id,*opts)
|
26
|
+
q = "#{database}/#{id}"
|
27
|
+
q << QueryBuilder.build(opts.first,"doc") if opts && opts.any? && opts.first.is_a?(Hash)
|
28
|
+
|
29
|
+
@conn.query({url_path: q, method: :get})
|
28
30
|
end
|
29
31
|
alias_method :get, :get_doc
|
30
32
|
alias_method :doc, :get_doc
|
@@ -90,8 +92,11 @@ module Cloudant
|
|
90
92
|
end
|
91
93
|
|
92
94
|
# Get a hash {"results" => []}, containing a hash of seq, id, changes
|
93
|
-
def changes
|
94
|
-
|
95
|
+
def changes(*opts)
|
96
|
+
q = "#{database}/_changes"
|
97
|
+
q << QueryBuilder.build(opts.first,"changes") if opts && opts.any? && opts.first.is_a?(Hash)
|
98
|
+
|
99
|
+
@conn.query({url_path: q, method: :get})
|
95
100
|
end
|
96
101
|
|
97
102
|
# Returns all database for the current instance of Cloudant
|
@@ -184,7 +189,7 @@ module Cloudant
|
|
184
189
|
end
|
185
190
|
|
186
191
|
# Paginate query results - best for large volume.
|
187
|
-
# TODO: add feature that allows users to view previous pages and
|
192
|
+
# TODO: add feature that allows users to view previous pages and generally move into own class.
|
188
193
|
def bookmark_query(q,&blk)
|
189
194
|
response = query(q)
|
190
195
|
bookmark = response["bookmark"]
|
@@ -21,8 +21,15 @@ module Cloudant
|
|
21
21
|
|
22
22
|
# TODO: This will be expanded to calls other than /_view.
|
23
23
|
def get_fields(type)
|
24
|
-
|
25
|
-
|
24
|
+
case type
|
25
|
+
when "view"
|
26
|
+
return [:reduce,:include_docs,:descending,:endkey,:endkey_docid,:group,:group_level,:inclusive_end,:key,:keys,:limit,:skip,:stale,:startkey,:startkey_docid]
|
27
|
+
when "all_docs"
|
28
|
+
return [:include_docs,:descending,:endkey,:conflicts,:inclusive_end,:key,:limit,:skip,:startkey,:keys]
|
29
|
+
when "changes"
|
30
|
+
return [:include_docs,:descending,:feed,:filter,:heartbeat,:conflicts,:limit,:since,:style,:timeout,:doc_ids]
|
31
|
+
when "doc"
|
32
|
+
return [:local_seq,:attachments,:att_encoding_info,:atts_since,:conflicts,:deleted_conflicts,:latest,:meta,:open_revs,:rev,:revs,:revs_info]
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|
data/lib/cloudant/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Yanai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|