couchrest 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/Gemfile +2 -4
- data/README.md +3 -2
- data/Rakefile +9 -24
- data/VERSION +1 -1
- data/couchrest.gemspec +3 -1
- data/history.txt +8 -0
- data/lib/couchrest.rb +13 -1
- data/lib/couchrest/database.rb +5 -5
- data/lib/couchrest/helper/streamer.rb +1 -1
- data/lib/couchrest/rest_api.rb +4 -3
- data/lib/couchrest/server.rb +11 -11
- data/spec/couchrest/couchrest_spec.rb +2 -7
- data/spec/couchrest/database_spec.rb +92 -112
- data/spec/couchrest/helpers/streamer_spec.rb +3 -3
- data/spec/couchrest/rest_api_spec.rb +21 -0
- metadata +43 -7
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# CouchRest: CouchDB, close to the metal
|
1
|
+
# CouchRest: CouchDB, close to the metal [![Build Status](https://travis-ci.org/couchrest/couchrest.png)](https://travis-ci.org/couchrest/couchrest)
|
2
2
|
|
3
3
|
CouchRest is based on [CouchDB's couch.js test
|
4
4
|
library](http://svn.apache.org/repos/asf/couchdb/trunk/share/www/script/couch.js),
|
@@ -41,12 +41,13 @@ CouchRest install, from the project root directory use bundler to install
|
|
41
41
|
the dependencies and then run the tests:
|
42
42
|
|
43
43
|
$ bundle install
|
44
|
-
$ bundle exec
|
44
|
+
$ bundle exec rake
|
45
45
|
|
46
46
|
To date, the couchrest specs have been show to run on:
|
47
47
|
|
48
48
|
* Ruby 1.8.7
|
49
49
|
* Ruby 1.9.2
|
50
|
+
* Ruby 1.9.3
|
50
51
|
* JRuby 1.5.6
|
51
52
|
|
52
53
|
## Docs
|
data/Rakefile
CHANGED
@@ -1,33 +1,18 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
require 'bundler'
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
require "rake/rdoctask"
|
5
|
-
|
6
3
|
Bundler::GemHelper.install_tasks
|
7
4
|
|
8
|
-
|
9
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
10
|
-
spec.rspec_opts = ["--color"]
|
11
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
12
|
-
end
|
5
|
+
require 'rspec/core/rake_task'
|
13
6
|
|
14
|
-
desc
|
15
|
-
|
16
|
-
spec.rspec_opts = ["--format", "specdoc"]
|
17
|
-
spec.pattern = 'spec/*_spec.rb'
|
18
|
-
end
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :spec
|
19
9
|
|
20
|
-
desc "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
rdoc.main = "README.rdoc"
|
25
|
-
rdoc.title = "CouchRest: Ruby CouchDB, close to the metal"
|
10
|
+
desc "Run all specs"
|
11
|
+
RSpec::Core::RakeTask.new do |t|
|
12
|
+
t.pattern = 'spec/**/*_spec.rb'
|
13
|
+
t.rspec_opts = ["-c", "-f progress"]
|
26
14
|
end
|
27
15
|
|
28
|
-
desc "Run the rspec"
|
29
|
-
task :default => :spec
|
30
|
-
|
31
16
|
module Rake
|
32
17
|
def self.remove_task(task_name)
|
33
18
|
Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
|
@@ -35,4 +20,4 @@ module Rake
|
|
35
20
|
end
|
36
21
|
|
37
22
|
Rake.remove_task("github:release")
|
38
|
-
Rake.remove_task("release")
|
23
|
+
Rake.remove_task("release")
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/couchrest.gemspec
CHANGED
@@ -29,6 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
|
30
30
|
s.add_dependency(%q<mime-types>, ["~> 1.15"])
|
31
31
|
s.add_dependency(%q<multi_json>, ["~> 1.0"])
|
32
|
-
s.add_development_dependency(%q<json>, ["
|
32
|
+
s.add_development_dependency(%q<json>, [">= 1.7.0"])
|
33
33
|
s.add_development_dependency(%q<rspec>, "~> 2.6.0")
|
34
|
+
s.add_development_dependency(%q<rake>)
|
35
|
+
s.add_development_dependency(%q<multi_json>, "~> 1.7") # needed for json decode json objects
|
34
36
|
end
|
data/history.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 1.2.0 - 2013-05-25
|
2
|
+
|
3
|
+
* Changes
|
4
|
+
* Added clobal configuration option to decode JSON objects (@langalex)
|
5
|
+
* Changing specs to test parameters as apposed to CouchDB for replication and restart
|
6
|
+
* Spec updates (@tapajos)
|
7
|
+
* Spec typos (@frasertweedale, @m1foley)
|
8
|
+
|
1
9
|
== 1.1.3 - 2012-07-31
|
2
10
|
|
3
11
|
* Minor changes
|
data/lib/couchrest.rb
CHANGED
@@ -43,7 +43,7 @@ module CouchRest
|
|
43
43
|
# the get, post, put, delete and copy
|
44
44
|
CouchRest.extend(::CouchRest::RestAPI)
|
45
45
|
|
46
|
-
# The CouchRest module methods handle the basic JSON serialization
|
46
|
+
# The CouchRest module methods handle the basic JSON serialization
|
47
47
|
# and deserialization, as well as query parameters. The module also includes
|
48
48
|
# some helpers for tasks like instantiating a new Database or Server instance.
|
49
49
|
class << self
|
@@ -118,6 +118,18 @@ module CouchRest
|
|
118
118
|
end
|
119
119
|
url
|
120
120
|
end
|
121
|
+
|
122
|
+
@@decode_json_objects = false
|
123
|
+
|
124
|
+
def decode_json_objects=(value)
|
125
|
+
@@decode_json_objects = value
|
126
|
+
end
|
127
|
+
|
128
|
+
# When set to true, CouchRest.get tries to decode the JSON returned
|
129
|
+
# from CouchDB into a Ruby object. Default: false.
|
130
|
+
def decode_json_objects
|
131
|
+
@@decode_json_objects
|
132
|
+
end
|
121
133
|
end # class << self
|
122
134
|
end
|
123
135
|
# For the sake of backwards compatability, generate a dummy ExtendedDocument class
|
data/lib/couchrest/database.rb
CHANGED
@@ -129,7 +129,7 @@ module CouchRest
|
|
129
129
|
uri << "?batch=ok" if batch
|
130
130
|
CouchRest.put uri, doc
|
131
131
|
rescue RestClient::ResourceNotFound
|
132
|
-
|
132
|
+
puts "resource not found when saving even though an id was passed"
|
133
133
|
slug = doc['_id'] = @server.next_uuid
|
134
134
|
CouchRest.put "#{@root}/#{slug}", doc
|
135
135
|
end
|
@@ -349,12 +349,12 @@ module CouchRest
|
|
349
349
|
doc_ids = options.delete(:doc_ids)
|
350
350
|
payload = options
|
351
351
|
if options.has_key?(:target)
|
352
|
-
payload[
|
352
|
+
payload[:source] = other_db.root
|
353
353
|
else
|
354
|
-
payload[
|
354
|
+
payload[:target] = other_db.root
|
355
355
|
end
|
356
|
-
payload[
|
357
|
-
payload[
|
356
|
+
payload[:continuous] = continuous
|
357
|
+
payload[:doc_ids] = doc_ids if doc_ids
|
358
358
|
CouchRest.post "#{@host}/_replicate", payload
|
359
359
|
end
|
360
360
|
|
data/lib/couchrest/rest_api.rb
CHANGED
@@ -30,7 +30,7 @@ module CouchRest
|
|
30
30
|
#
|
31
31
|
# Any other remaining options will be sent to the MultiJSON backend except for the :raw option.
|
32
32
|
#
|
33
|
-
# When :raw is true in PUT and POST requests, no attempt will be made to convert the document payload to JSON. This is
|
33
|
+
# When :raw is true in PUT and POST requests, no attempt will be made to convert the document payload to JSON. This is
|
34
34
|
# not normally necessary as IO and Tempfile objects will not be parsed anyway. The result of the request will
|
35
35
|
# *always* be parsed.
|
36
36
|
#
|
@@ -84,7 +84,7 @@ module CouchRest
|
|
84
84
|
|
85
85
|
private
|
86
86
|
|
87
|
-
# Perform the RestClient request by removing the parse specific options, ensuring the
|
87
|
+
# Perform the RestClient request by removing the parse specific options, ensuring the
|
88
88
|
# payload is prepared, and sending the request ready to parse the response.
|
89
89
|
def execute(url, method, options = {}, payload = nil)
|
90
90
|
request, parser = prepare_and_split_options(url, method, options)
|
@@ -131,7 +131,7 @@ module CouchRest
|
|
131
131
|
[request, parser]
|
132
132
|
end
|
133
133
|
|
134
|
-
# Check if the provided doc is nil or special IO device or temp file. If not,
|
134
|
+
# Check if the provided doc is nil or special IO device or temp file. If not,
|
135
135
|
# encode it into a string.
|
136
136
|
#
|
137
137
|
# The options supported are:
|
@@ -147,6 +147,7 @@ module CouchRest
|
|
147
147
|
|
148
148
|
# Parse the response provided.
|
149
149
|
def parse_response(result, opts = {})
|
150
|
+
opts = opts.update(:create_additions => true) if decode_json_objects
|
150
151
|
(opts.delete(:raw) || opts.delete(:head)) ? result : MultiJson.decode(result, opts.update(:max_nesting => false))
|
151
152
|
end
|
152
153
|
|
data/lib/couchrest/server.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module CouchRest
|
2
2
|
class Server
|
3
|
+
|
3
4
|
attr_accessor :uri, :uuid_batch_count, :available_databases
|
5
|
+
|
4
6
|
def initialize(server = 'http://127.0.0.1:5984', uuid_batch_count = 1000)
|
5
7
|
@uri = server
|
6
8
|
@uuid_batch_count = uuid_batch_count
|
7
9
|
end
|
8
|
-
|
10
|
+
|
9
11
|
# Lists all "available" databases.
|
10
12
|
# An available database, is a database that was specified
|
11
13
|
# as avaiable by your code.
|
@@ -13,7 +15,7 @@ module CouchRest
|
|
13
15
|
def available_databases
|
14
16
|
@available_databases ||= {}
|
15
17
|
end
|
16
|
-
|
18
|
+
|
17
19
|
# Adds a new available database and create it unless it already exists
|
18
20
|
#
|
19
21
|
# Example:
|
@@ -24,7 +26,7 @@ module CouchRest
|
|
24
26
|
def define_available_database(reference, db_name, create_unless_exists = true)
|
25
27
|
available_databases[reference.to_sym] = create_unless_exists ? database!(db_name) : database(db_name)
|
26
28
|
end
|
27
|
-
|
29
|
+
|
28
30
|
# Checks that a database is set as available
|
29
31
|
#
|
30
32
|
# Example:
|
@@ -34,25 +36,25 @@ module CouchRest
|
|
34
36
|
def available_database?(ref_or_name)
|
35
37
|
ref_or_name.is_a?(Symbol) ? available_databases.keys.include?(ref_or_name) : available_databases.values.map{|db| db.name}.include?(ref_or_name)
|
36
38
|
end
|
37
|
-
|
39
|
+
|
38
40
|
def default_database=(name, create_unless_exists = true)
|
39
41
|
define_available_database(:default, name, create_unless_exists = true)
|
40
42
|
end
|
41
|
-
|
43
|
+
|
42
44
|
def default_database
|
43
45
|
available_databases[:default]
|
44
46
|
end
|
45
|
-
|
47
|
+
|
46
48
|
# Lists all databases on the server
|
47
49
|
def databases
|
48
50
|
CouchRest.get "#{@uri}/_all_dbs"
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
# Returns a CouchRest::Database for the given name
|
52
54
|
def database(name)
|
53
55
|
CouchRest::Database.new(self, name)
|
54
56
|
end
|
55
|
-
|
57
|
+
|
56
58
|
# Creates the database if it doesn't exist
|
57
59
|
def database!(name)
|
58
60
|
CouchRest.head "#{@uri}/#{name}" # Check if the URL is valid
|
@@ -60,7 +62,7 @@ module CouchRest
|
|
60
62
|
rescue RestClient::ResourceNotFound # Thrown if the HTTP HEAD fails
|
61
63
|
create_db(name)
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
# GET the welcome message
|
65
67
|
def info
|
66
68
|
CouchRest.get "#{@uri}/"
|
@@ -75,8 +77,6 @@ module CouchRest
|
|
75
77
|
# Restart the CouchDB instance
|
76
78
|
def restart!
|
77
79
|
CouchRest.post "#{@uri}/_restart"
|
78
|
-
rescue RestClient::ServerBrokeConnection
|
79
|
-
# Shouldn't really happen, but does in CouchDB 1.0.0
|
80
80
|
end
|
81
81
|
|
82
82
|
# Retrive an unused UUID from CouchDB. Server instances manage caching a list of unused UUIDs.
|
@@ -27,14 +27,9 @@ describe CouchRest do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should restart" do
|
30
|
+
# we really do not need to perform a proper restart!
|
31
|
+
CouchRest.should_receive(:post).with("#{@cr.uri}/_restart")
|
30
32
|
@cr.restart!
|
31
|
-
begin
|
32
|
-
@cr.info
|
33
|
-
rescue
|
34
|
-
# Give the couchdb time to restart
|
35
|
-
sleep 0.2
|
36
|
-
retry
|
37
|
-
end
|
38
33
|
end
|
39
34
|
|
40
35
|
it "should provide one-time access to uuids" do
|
@@ -4,8 +4,8 @@ describe CouchRest::Database do
|
|
4
4
|
before(:each) do
|
5
5
|
@cr = CouchRest.new(COUCHHOST)
|
6
6
|
@db = @cr.database(TESTDB)
|
7
|
-
@db.delete! rescue
|
8
|
-
@db = @cr.create_db(TESTDB) rescue nil
|
7
|
+
@db.delete! rescue RestClient::ResourceNotFound
|
8
|
+
@db = @cr.create_db(TESTDB) # rescue nil
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "database name including slash" do
|
@@ -735,10 +735,11 @@ describe CouchRest::Database do
|
|
735
735
|
|
736
736
|
|
737
737
|
describe "#compact" do
|
738
|
+
# Can cause failures in recent versions of CouchDB, just ensure
|
739
|
+
# we actually send the right command.
|
738
740
|
it "should compact the database" do
|
739
|
-
|
740
|
-
|
741
|
-
r['ok'].should == true
|
741
|
+
CouchRest.should_receive(:post).with("#{@cr.uri}/couchrest-test/_compact")
|
742
|
+
@cr.database('couchrest-test').compact!
|
742
743
|
end
|
743
744
|
end
|
744
745
|
|
@@ -754,128 +755,107 @@ describe CouchRest::Database do
|
|
754
755
|
end
|
755
756
|
end
|
756
757
|
|
758
|
+
#
|
759
|
+
# Replicating databases is often a time consuming process, so instead of
|
760
|
+
# trying to send commands to CouchDB, we just validate that the post
|
761
|
+
# command contains the correct parameters.
|
762
|
+
#
|
763
|
+
|
757
764
|
describe "simply replicating a database" do
|
758
765
|
before(:each) do
|
759
|
-
@db.save_doc({'_id' => 'test_doc', 'some-value' => 'foo'})
|
760
766
|
@other_db = @cr.database(REPLICATIONDB)
|
761
767
|
end
|
762
768
|
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
@db.
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
769
|
+
it "should replicate via pulling" do
|
770
|
+
CouchRest.should_receive(:post).with(
|
771
|
+
include("/_replicate"),
|
772
|
+
include(
|
773
|
+
:create_target => false,
|
774
|
+
:continuous => false,
|
775
|
+
:source => "#{@cr.uri}/#{@db.name}",
|
776
|
+
:target => @other_db.name
|
777
|
+
)
|
778
|
+
)
|
779
|
+
@other_db.replicate_from @db
|
780
|
+
end
|
781
|
+
|
782
|
+
it "should replicate via pushing" do
|
783
|
+
CouchRest.should_receive(:post).with(
|
784
|
+
include("/_replicate"),
|
785
|
+
include(
|
786
|
+
:create_target => false,
|
787
|
+
:continuous => false,
|
788
|
+
:source => @db.name,
|
789
|
+
:target => "#{@cr.uri}/#{@other_db.name}"
|
790
|
+
)
|
791
|
+
)
|
792
|
+
@db.replicate_to @other_db
|
793
|
+
end
|
794
|
+
|
795
|
+
it "should replacicate with a specific doc" do
|
796
|
+
CouchRest.should_receive(:post).with(
|
797
|
+
include("/_replicate"),
|
798
|
+
include(
|
799
|
+
:create_target => false,
|
800
|
+
:continuous => false,
|
801
|
+
:doc_ids => ['test_doc'],
|
802
|
+
:source => @db.name,
|
803
|
+
:target => "#{@cr.uri}/#{@other_db.name}"
|
804
|
+
)
|
805
|
+
)
|
806
|
+
@db.replicate_to @other_db, false, false, ['test_doc']
|
800
807
|
end
|
801
808
|
|
802
809
|
describe "implicitly creating target" do
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
@db.save_doc({'_id' => 'test_doc_after', 'some-value' => 'bar'})
|
836
|
-
sleep(1.5) # Allow some time to replicate
|
837
|
-
doc = @other_db.get('test_doc_after')
|
838
|
-
doc['some-value'].should == 'bar'
|
839
|
-
end
|
840
|
-
end
|
841
|
-
|
842
|
-
describe "via pulling" do
|
843
|
-
before(:each) do
|
844
|
-
@other_db.recreate!
|
810
|
+
it "should replicate via pulling" do
|
811
|
+
CouchRest.should_receive(:post).with(
|
812
|
+
include("/_replicate"),
|
813
|
+
include(
|
814
|
+
:create_target => true,
|
815
|
+
:continuous => false
|
816
|
+
)
|
817
|
+
)
|
818
|
+
@other_db.replicate_from(@db, false, true)
|
819
|
+
end
|
820
|
+
|
821
|
+
it "should replicate via pushing" do
|
822
|
+
CouchRest.should_receive(:post).with(
|
823
|
+
include("/_replicate"),
|
824
|
+
include(
|
825
|
+
:create_target => true,
|
826
|
+
:continuous => false
|
827
|
+
)
|
828
|
+
)
|
829
|
+
@db.replicate_to(@other_db, false, true)
|
830
|
+
end
|
831
|
+
end
|
832
|
+
|
833
|
+
describe "continuous replication" do
|
834
|
+
it "should replicate via pulling" do
|
835
|
+
CouchRest.should_receive(:post).with(
|
836
|
+
include("/_replicate"),
|
837
|
+
include(
|
838
|
+
:create_target => false,
|
839
|
+
:continuous => true
|
840
|
+
)
|
841
|
+
)
|
845
842
|
@other_db.replicate_from(@db, true)
|
846
843
|
end
|
847
844
|
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
845
|
+
it "should replicate via pushing" do
|
846
|
+
CouchRest.should_receive(:post).with(
|
847
|
+
include("/_replicate"),
|
848
|
+
include(
|
849
|
+
:create_target => false,
|
850
|
+
:continuous => true
|
851
|
+
)
|
852
|
+
)
|
854
853
|
@db.replicate_to(@other_db, true)
|
855
854
|
end
|
856
|
-
|
857
|
-
it_should_behave_like "continuously replicated"
|
858
|
-
end
|
859
|
-
|
860
|
-
describe "implicitly creating target" do
|
861
|
-
before(:each) do
|
862
|
-
@other_db.replicate_from(@db, true, true)
|
863
|
-
end
|
864
|
-
|
865
|
-
after(:each) do
|
866
|
-
@other_db.delete!
|
867
|
-
end
|
868
|
-
|
869
|
-
describe "via pulling" do
|
870
|
-
it_should_behave_like "continuously replicated"
|
871
|
-
end
|
872
|
-
|
873
|
-
describe "via pushing" do
|
874
|
-
it_should_behave_like "continuously replicated"
|
875
|
-
end
|
876
855
|
end
|
877
856
|
end
|
878
857
|
|
858
|
+
|
879
859
|
describe "#create!" do
|
880
860
|
before(:each) do
|
881
861
|
@db = @cr.database('couchrest-test-db_to_create')
|
@@ -903,7 +883,7 @@ describe CouchRest::Database do
|
|
903
883
|
@cr.databases.should include(@db.name)
|
904
884
|
end
|
905
885
|
|
906
|
-
it "should recreate a db even
|
886
|
+
it "should recreate a db even though it doesn't exist" do
|
907
887
|
@cr.databases.should_not include(@db2.name)
|
908
888
|
@db2.recreate!
|
909
889
|
@cr.databases.should include(@db2.name)
|
@@ -19,8 +19,8 @@ describe CouchRest::Streamer do
|
|
19
19
|
})
|
20
20
|
end
|
21
21
|
|
22
|
-
it "should raise error on #view as
|
23
|
-
lambda { @streamer.view }.should raise_error(/
|
22
|
+
it "should raise error on #view as deprecated" do
|
23
|
+
lambda { @streamer.view }.should raise_error(/deprecated/)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should GET each row in a view" do
|
@@ -50,7 +50,7 @@ describe CouchRest::Streamer do
|
|
50
50
|
header.should == {"total_rows" => 1001, "offset" => 0}
|
51
51
|
end
|
52
52
|
|
53
|
-
it "should raise an exception receives malformed data" do
|
53
|
+
it "should raise an exception if it receives malformed data" do
|
54
54
|
IO.stub(:popen) do |cmd, block|
|
55
55
|
class F
|
56
56
|
def initialize
|
@@ -98,6 +98,27 @@ describe CouchRest::RestAPI do
|
|
98
98
|
expect { CouchRest.get('foo') }.to raise_error(RestClient::Exception)
|
99
99
|
end
|
100
100
|
|
101
|
+
context 'when decode_json_objects is true' do
|
102
|
+
class TestObject
|
103
|
+
def self.json_create(args)
|
104
|
+
new
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
before(:each) do
|
109
|
+
CouchRest.decode_json_objects = true
|
110
|
+
end
|
111
|
+
|
112
|
+
after(:each) do
|
113
|
+
CouchRest.decode_json_objects = false
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should return the response as a Ruby object' do
|
117
|
+
CouchRest.put "#{COUCHHOST}/#{TESTDB}/test", JSON.create_id => TestObject.to_s
|
118
|
+
|
119
|
+
CouchRest.get("#{COUCHHOST}/#{TESTDB}/test").class.should eql(TestObject)
|
120
|
+
end
|
121
|
+
end
|
101
122
|
end
|
102
123
|
|
103
124
|
describe :post do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rest-client
|
@@ -68,17 +68,17 @@ dependencies:
|
|
68
68
|
requirement: !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
71
|
-
- -
|
71
|
+
- - ! '>='
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 1.
|
73
|
+
version: 1.7.0
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
none: false
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ! '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 1.
|
81
|
+
version: 1.7.0
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: rspec
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,6 +95,38 @@ dependencies:
|
|
95
95
|
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: 2.6.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rake
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: multi_json
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ~>
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.7'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ~>
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.7'
|
98
130
|
description: CouchRest provides a simple interface on top of CouchDB's RESTful HTTP
|
99
131
|
API, as well as including some utility scripts for managing views and attachments.
|
100
132
|
email: jchris@apache.org
|
@@ -106,6 +138,7 @@ extra_rdoc_files:
|
|
106
138
|
- THANKS.md
|
107
139
|
files:
|
108
140
|
- .gitignore
|
141
|
+
- .travis.yml
|
109
142
|
- Gemfile
|
110
143
|
- LICENSE
|
111
144
|
- README.md
|
@@ -175,6 +208,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
208
|
- - ! '>='
|
176
209
|
- !ruby/object:Gem::Version
|
177
210
|
version: '0'
|
211
|
+
segments:
|
212
|
+
- 0
|
213
|
+
hash: 1010445868410705054
|
178
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
215
|
none: false
|
180
216
|
requirements:
|
@@ -183,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
219
|
version: 1.3.1
|
184
220
|
requirements: []
|
185
221
|
rubyforge_project:
|
186
|
-
rubygems_version: 1.8.
|
222
|
+
rubygems_version: 1.8.25
|
187
223
|
signing_key:
|
188
224
|
specification_version: 3
|
189
225
|
summary: Lean and RESTful interface to CouchDB.
|