dolly 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dolly/request.rb +20 -19
- data/lib/dolly/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: 4aebf024e5e48154c3725af48715816d015b6444
|
4
|
+
data.tar.gz: e1a4d17548ecdd9e9d4cceb9c482ba77de1ba983
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2262642fce24061d8141d160be3aec870a8cf101931bb0bf6371b3e08d5e590ddb80121d0cac6246f1530ac5a175557d9c343e36066ad1bb7eca6cc086b425ea
|
7
|
+
data.tar.gz: 98160dca126b53ca2c3840719463747d29067985777445149744fb003720842428a1026f66e1ccab3dd80cc5c03b4687e1ba1c53524d70009f1caaf7a00af6aa
|
data/lib/dolly/request.rb
CHANGED
@@ -25,19 +25,19 @@ module Dolly
|
|
25
25
|
|
26
26
|
def get resource, data = nil
|
27
27
|
q = {query: values_to_json(data)} if data
|
28
|
-
request :get, resource, q
|
28
|
+
request :get, full_path(resource), q
|
29
29
|
end
|
30
30
|
|
31
31
|
def put resource, data
|
32
|
-
request :put, resource, {body: data}
|
32
|
+
request :put, full_path(resource), {body: data}
|
33
33
|
end
|
34
34
|
|
35
35
|
def post resource, data
|
36
|
-
request :post, resource, {body: data}
|
36
|
+
request :post, full_path(resource), {body: data}
|
37
37
|
end
|
38
38
|
|
39
39
|
def delete resource
|
40
|
-
request :delete, resource, {}
|
40
|
+
request :delete, full_path(resource), {}
|
41
41
|
end
|
42
42
|
|
43
43
|
def protocol
|
@@ -50,7 +50,22 @@ module Dolly
|
|
50
50
|
|
51
51
|
def all_docs data = {}
|
52
52
|
data = values_to_json data.merge( include_docs: true )
|
53
|
-
request :get, '_all_docs', {query: data}
|
53
|
+
request :get, full_path('_all_docs'), {query: data}
|
54
|
+
end
|
55
|
+
|
56
|
+
def request method, resource, data = nil
|
57
|
+
data ||= {}
|
58
|
+
data.merge!(basic_auth: auth_info) if auth_info.present?
|
59
|
+
headers = { 'Content-Type' => 'application/json' }
|
60
|
+
headers.merge! data[:headers] if data[:headers]
|
61
|
+
response = self.class.send method, resource, data.merge(headers: headers)
|
62
|
+
if response.code == 404
|
63
|
+
raise Dolly::ResourceNotFound
|
64
|
+
elsif (500..600).include? response.code
|
65
|
+
raise Dolly::ServerError
|
66
|
+
else
|
67
|
+
response
|
68
|
+
end
|
54
69
|
end
|
55
70
|
|
56
71
|
private
|
@@ -73,20 +88,6 @@ module Dolly
|
|
73
88
|
def full_path resource
|
74
89
|
"/#{database_name}/#{resource}"
|
75
90
|
end
|
76
|
-
|
77
|
-
def request method, resource, data = nil
|
78
|
-
data ||= {}
|
79
|
-
data.merge!(basic_auth: auth_info) if auth_info.present?
|
80
|
-
headers = { 'Content-Type' => 'application/json' }
|
81
|
-
response = self.class.send method, full_path(resource), data.merge(headers: headers)
|
82
|
-
if response.code == 404
|
83
|
-
raise Dolly::ResourceNotFound
|
84
|
-
elsif (500..600).include? response.code
|
85
|
-
raise Dolly::ServerError
|
86
|
-
else
|
87
|
-
response
|
88
|
-
end
|
89
|
-
end
|
90
91
|
end
|
91
92
|
|
92
93
|
end
|
data/lib/dolly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- javierg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|