maremma 3.0.2 → 3.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/maremma/version.rb +1 -1
- data/lib/maremma.rb +9 -7
- data/spec/maremma_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa8efffa613ac1806ff563a3fae7a430976baa9
|
4
|
+
data.tar.gz: 71f604839289779969077528a757a0cc1aa8f175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a391693917452149062b1f5053cde47fa387bf552667a8dd352f43b3fe2d6f283f544d1fc734ec9f6c2bb127ed1a3ff162aa441e966ad7f5bf5416e13b973246
|
7
|
+
data.tar.gz: 9bf52ef7911ef0994806ab8d483f6d7a670cc767d3d17e0af940929004305ef0831820a66b9969a3dc5e6982a0f81b523c5fd1b612cf951e0e7909d5b656da0e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v.3.1 (December 10, 2016)
|
2
|
+
|
3
|
+
[maremma 3.1](https://github.com/datacite/maremma/releases/tag/v.3.1) was released on December 10, 2016:
|
4
|
+
|
5
|
+
* added `:raw` option to disable automatic parsing of JSON and XML responses.
|
6
|
+
|
1
7
|
## v.3.0.2 (December 10, 2016)
|
2
8
|
|
3
9
|
[maremma 3.0.2](https://github.com/datacite/maremma/releases/tag/v.3.0.2) was released on December 10, 2016:
|
data/Gemfile.lock
CHANGED
data/lib/maremma/version.rb
CHANGED
data/lib/maremma.rb
CHANGED
@@ -30,7 +30,7 @@ module Maremma
|
|
30
30
|
response = conn.post url, {}, options[:headers] do |request|
|
31
31
|
request.body = options[:data]
|
32
32
|
end
|
33
|
-
OpenStruct.new(body: parse_success_response(response.body),
|
33
|
+
OpenStruct.new(body: parse_success_response(response.body, options),
|
34
34
|
headers: response.headers,
|
35
35
|
status: response.status)
|
36
36
|
rescue *NETWORKABLE_EXCEPTIONS => error
|
@@ -48,7 +48,7 @@ module Maremma
|
|
48
48
|
response = conn.put url, {}, options[:headers] do |request|
|
49
49
|
request.body = options[:data]
|
50
50
|
end
|
51
|
-
OpenStruct.new(body: parse_success_response(response.body),
|
51
|
+
OpenStruct.new(body: parse_success_response(response.body, options),
|
52
52
|
headers: response.headers,
|
53
53
|
status: response.status)
|
54
54
|
rescue *NETWORKABLE_EXCEPTIONS => error
|
@@ -65,7 +65,7 @@ module Maremma
|
|
65
65
|
|
66
66
|
response = conn.delete url, {}, options[:headers]
|
67
67
|
|
68
|
-
OpenStruct.new(body: parse_success_response(response.body),
|
68
|
+
OpenStruct.new(body: parse_success_response(response.body, options),
|
69
69
|
headers: response.headers,
|
70
70
|
status: response.status)
|
71
71
|
rescue *NETWORKABLE_EXCEPTIONS => error
|
@@ -87,7 +87,7 @@ module Maremma
|
|
87
87
|
headers: response.headers,
|
88
88
|
status: response.status)
|
89
89
|
end
|
90
|
-
OpenStruct.new(body: parse_success_response(response.body),
|
90
|
+
OpenStruct.new(body: parse_success_response(response.body, options),
|
91
91
|
headers: response.headers,
|
92
92
|
status: response.status)
|
93
93
|
rescue *NETWORKABLE_EXCEPTIONS => error
|
@@ -188,8 +188,8 @@ module Maremma
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
def self.parse_success_response(string)
|
192
|
-
string = parse_response(string)
|
191
|
+
def self.parse_success_response(string, options={})
|
192
|
+
string = parse_response(string, options)
|
193
193
|
|
194
194
|
if string.blank?
|
195
195
|
{ "data" => nil }
|
@@ -212,7 +212,9 @@ module Maremma
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
def self.parse_response(string)
|
215
|
+
def self.parse_response(string, options={})
|
216
|
+
return string if options[:raw]
|
217
|
+
|
216
218
|
from_json(string) || from_xml(string) || from_string(string)
|
217
219
|
end
|
218
220
|
|
data/spec/maremma_spec.rb
CHANGED
@@ -70,6 +70,14 @@ describe Maremma do
|
|
70
70
|
expect(response.headers).to eq("Content-Type"=>"application/json")
|
71
71
|
expect(stub).to have_been_requested
|
72
72
|
end
|
73
|
+
|
74
|
+
it "get xml raw" do
|
75
|
+
stub = stub_request(:get, url).to_return(:body => data.to_xml, :status => 200, :headers => { "Content-Type" => "application/xml" })
|
76
|
+
response = subject.get(url, accept: 'xml', raw: true)
|
77
|
+
expect(response.body).to eq("data"=>data.to_xml)
|
78
|
+
expect(response.headers).to eq("Content-Type"=>"application/xml")
|
79
|
+
expect(stub).to have_been_requested
|
80
|
+
end
|
73
81
|
end
|
74
82
|
|
75
83
|
context "empty response" do
|