jchris-couchrest 0.7.99 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/couchrest.rb +1 -0
- data/lib/database.rb +6 -1
- data/script/couchdir +5 -1
- data/script/couchview +5 -1
- data/spec/couchrest_spec.rb +13 -12
- data/spec/database_spec.rb +3 -3
- metadata +2 -2
data/lib/couchrest.rb
CHANGED
data/lib/database.rb
CHANGED
@@ -31,7 +31,12 @@ class CouchRest
|
|
31
31
|
url = CouchRest.paramify_url "#{@root}/_search", params
|
32
32
|
CouchRest.get url
|
33
33
|
end
|
34
|
-
|
34
|
+
# experimental
|
35
|
+
def action action, params = nil
|
36
|
+
url = CouchRest.paramify_url "#{@root}/_action/#{action}", params
|
37
|
+
CouchRest.get url
|
38
|
+
end
|
39
|
+
|
35
40
|
def get id
|
36
41
|
slug = CGI.escape(id)
|
37
42
|
CouchRest.get "#{@root}/#{slug}"
|
data/script/couchdir
CHANGED
data/script/couchview
CHANGED
@@ -112,7 +112,11 @@ when "push" # files to views
|
|
112
112
|
dviews.delete("#{view}-reduce") unless dviews["#{view}-reduce"]["reduce"]
|
113
113
|
end
|
114
114
|
# save them to the db
|
115
|
-
|
115
|
+
begin
|
116
|
+
view = db.get("_design/#{design}")
|
117
|
+
rescue RestClient::Request::RequestFailed
|
118
|
+
view = nil
|
119
|
+
end
|
116
120
|
if (view && view['views'] == dviews)
|
117
121
|
puts "no change to _design/#{design}. skipping..."
|
118
122
|
else
|
data/spec/couchrest_spec.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe CouchRest do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@cr = CouchRest.new(
|
7
|
-
@db = @cr.database('couchrest-test')
|
6
|
+
@cr = CouchRest.new(COUCHHOST)
|
8
7
|
begin
|
9
|
-
@db.
|
8
|
+
@db = @cr.database(TESTDB)
|
9
|
+
@db.delete!
|
10
|
+
|
10
11
|
rescue RestClient::Request::RequestFailed
|
11
12
|
end
|
12
13
|
end
|
@@ -49,7 +50,7 @@ describe CouchRest do
|
|
49
50
|
|
50
51
|
describe "initializing a database" do
|
51
52
|
it "should return a db" do
|
52
|
-
db = @cr.database(
|
53
|
+
db = @cr.database(TESTDB)
|
53
54
|
db.should be_an_instance_of(CouchRest::Database)
|
54
55
|
db.host.should == @cr.uri
|
55
56
|
end
|
@@ -57,28 +58,28 @@ describe CouchRest do
|
|
57
58
|
|
58
59
|
describe "successfully creating a database" do
|
59
60
|
it "should start without a database" do
|
60
|
-
@cr.databases.should_not include(
|
61
|
+
@cr.databases.should_not include(TESTDB)
|
61
62
|
end
|
62
63
|
it "should return the created database" do
|
63
|
-
db = @cr.create_db(
|
64
|
+
db = @cr.create_db(TESTDB)
|
64
65
|
db.should be_an_instance_of(CouchRest::Database)
|
65
66
|
end
|
66
67
|
it "should create the database" do
|
67
|
-
db = @cr.create_db(
|
68
|
-
@cr.databases.should include(
|
68
|
+
db = @cr.create_db(TESTDB)
|
69
|
+
@cr.databases.should include(TESTDB)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
73
|
describe "failing to create a database because the name is taken" do
|
73
74
|
before(:each) do
|
74
|
-
db = @cr.create_db(
|
75
|
+
db = @cr.create_db(TESTDB)
|
75
76
|
end
|
76
77
|
it "should start with the test database" do
|
77
|
-
@cr.databases.should include(
|
78
|
+
@cr.databases.should include(TESTDB)
|
78
79
|
end
|
79
80
|
it "should PUT the database and raise an error" do
|
80
81
|
lambda{
|
81
|
-
@cr.create_db(
|
82
|
+
@cr.create_db(TESTDB)
|
82
83
|
}.should raise_error(RestClient::Request::RequestFailed)
|
83
84
|
end
|
84
85
|
end
|
data/spec/database_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe CouchRest::Database do
|
4
4
|
before(:each) do
|
5
|
-
@cr = CouchRest.new(
|
5
|
+
@cr = CouchRest.new(COUCHHOST)
|
6
6
|
begin
|
7
|
-
@db = @cr.create_db(
|
7
|
+
@db = @cr.create_db(TESTDB)
|
8
8
|
rescue RestClient::Request::RequestFailed
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jchris-couchrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J. Chris Anderson
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
requirements: []
|
70
70
|
|
71
71
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.0
|
72
|
+
rubygems_version: 1.2.0
|
73
73
|
signing_key:
|
74
74
|
specification_version: 2
|
75
75
|
summary: Lean and RESTful interface to CouchDB.
|