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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db640552c55496aa0dc1ea7abe56a66cd95f44ee
4
- data.tar.gz: be819fe1b4ca496f34a70e7ce993b41b02a27bb6
3
+ metadata.gz: 0fa8efffa613ac1806ff563a3fae7a430976baa9
4
+ data.tar.gz: 71f604839289779969077528a757a0cc1aa8f175
5
5
  SHA512:
6
- metadata.gz: 70afab2fd2d2f2e2f39451e1d7fee815f4b3b0cc78be4c8dfc0168ef2091d0232c08e5f097f704f923f6beda0d851916ddeb29d53db969e57deeed36d399a4a9
7
- data.tar.gz: 21ede85ceb69692685c9eaec5e31f69e869a022d4d95b2e47bd197c17b8e668a5c88f2fe2b514ec7eec3706cac0597813052e91a3906f628f0523b9a8a5168a2
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (3.0.2)
4
+ maremma (3.1)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  excon (~> 0.45.0)
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "3.0.2"
2
+ VERSION = "3.1"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maremma
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: '3.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner