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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a87df45b55aa852bb16fbfaf68bb0846a3171f7
4
- data.tar.gz: ea5973b00b7892677d321898c28cf5b8bde56ad8
3
+ metadata.gz: 617903591a37ae1748f18b5eae04fa09b888e1c9
4
+ data.tar.gz: f63d86f9d26940307786fcd17cb4bdf55c0c3ac5
5
5
  SHA512:
6
- metadata.gz: e31e0d97dec43099293c76f4e24f83026be30aed88c12250ccbae1e41c2a09f9ce6b40d5a72f48e384210bb821cf778eee32c0cb2e070816c4509decc2783bde
7
- data.tar.gz: 3f5c0abb9ccd099505256e0a03c20fd9fc6beff6902f7fe2ba5162f3ee5b60c7b65d94129aa40646fa634e02114dedadf26b9a56ee96d4e259247516d1b79b8a
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](##Contributing) and is a work in progress.
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; deleting multiple documents at once is best performed by adding `['_deleted']` to each document and performing an update. [Bulk operations](https://docs.cloudant.com/document.html#bulk-operations)
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)
@@ -14,17 +14,19 @@ module Cloudant
14
14
  end
15
15
 
16
16
  # Retrieve all docs from the database
17
- # Returns an array of hashes including ids, keys, and revs, unless :include_docs is passed
18
- def all_docs(*include_docs)
17
+ def all_docs(*opts)
19
18
  q = "#{database}/_all_docs"
20
- q << "?include_docs=true" if include_docs && include_docs.any? && include_docs.first == :include_docs
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
- @conn.query({url_path: "#{database}/#{id}", method: :get})
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
- @conn.query({url_path: "#{database}/_changes", method: :get})
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 generall move into own class.
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
- if type == "view"
25
- return [:reduce,:include_docs,:descending,:endkey,:endkey_docid,:group,:group_level,:inclusive_end,:key,:keys,:limit,:skip,:stale,:startkey,:startkey_docid]
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
@@ -1,3 +1,3 @@
1
1
  module Cloudant
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-14 00:00:00.000000000 Z
11
+ date: 2016-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler