armchair 0.0.1 → 0.0.2
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.
- data/Rakefile +1 -1
- data/armchair.gemspec +1 -1
- data/lib/armchair.rb +4 -4
- data/spec/armchair_spec.rb +1 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "armchair"
|
8
|
-
gem.version = '0.0.
|
8
|
+
gem.version = '0.0.2'
|
9
9
|
gem.summary = %Q{Minimal CouchDB interface}
|
10
10
|
gem.description = %Q{A minimal CouchDB interface that can do nothing but add documents and iterate over documents.}
|
11
11
|
gem.email = "danishkirel@gmail.com"
|
data/armchair.gemspec
CHANGED
data/lib/armchair.rb
CHANGED
@@ -10,7 +10,7 @@ class Armchair
|
|
10
10
|
# couch = Armchair.new 'http://127.0.0.1:5984/mycouch'
|
11
11
|
#
|
12
12
|
def initialize dburl, batch_size = 100
|
13
|
-
@dburl = dburl
|
13
|
+
@dburl = dburl.gsub(/\/$/,'')
|
14
14
|
@batch_size = batch_size
|
15
15
|
end
|
16
16
|
|
@@ -37,7 +37,7 @@ class Armchair
|
|
37
37
|
|
38
38
|
# Returns the size of the Armchair (the number of documents stored).
|
39
39
|
def size
|
40
|
-
RestClient.get(@dburl + '_all_docs?limit=0', :accept => :json) do |r|
|
40
|
+
RestClient.get(@dburl + '/_all_docs?limit=0', :accept => :json) do |r|
|
41
41
|
case r.code
|
42
42
|
when 200
|
43
43
|
JSON(r.body)['total_rows']
|
@@ -51,7 +51,7 @@ class Armchair
|
|
51
51
|
def each
|
52
52
|
# iterate in batches of @batch_size
|
53
53
|
# initial query
|
54
|
-
res = RestClient.get(@dburl + "_all_docs?limit=#{@batch_size+1}&include_docs=true", :accept => :json) do |r|
|
54
|
+
res = RestClient.get(@dburl + "/_all_docs?limit=#{@batch_size+1}&include_docs=true", :accept => :json) do |r|
|
55
55
|
case r.code
|
56
56
|
when 200
|
57
57
|
JSON(r.body)
|
@@ -65,7 +65,7 @@ class Armchair
|
|
65
65
|
# subsequent queries
|
66
66
|
while last
|
67
67
|
startkey = last['key']
|
68
|
-
res = RestClient.get(@dburl+"_all_docs?startkey=%22#{startkey}%22&limit=#{@batch_size+1}&include_docs=true", :accept => :json) do |r|
|
68
|
+
res = RestClient.get(@dburl + "/_all_docs?startkey=%22#{startkey}%22&limit=#{@batch_size+1}&include_docs=true", :accept => :json) do |r|
|
69
69
|
case r.code
|
70
70
|
when 200
|
71
71
|
JSON(r.body)
|
data/spec/armchair_spec.rb
CHANGED