azure-core 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f9d9bdb999e8d716b42a909bb0546b463c22f86
4
- data.tar.gz: 4bb66e37b486d3a865e430936d84aac53a71767e
3
+ metadata.gz: 9633ae4d67b96a41ca289286b59a6acfb3eada61
4
+ data.tar.gz: 6b13301832d6cd68b9c16f78b9eea614a78d93ab
5
5
  SHA512:
6
- metadata.gz: 4a09278b7af2ee896435cff2e532e52797b51aa244063470ccc8a26a06e4f38151170378c5685aee2ffb7a11f1cbbfde339cfb177f6ca58e0527242725f1cdce
7
- data.tar.gz: 59cd8e564774ab06af71f84477d12ac72a9708758e85c63882c48c0c74b4ca26c3d4739e1f3f480d69dff17a2a509230ee2f52543a8ca56366fe68af5e2751fe
6
+ metadata.gz: 4bec89582a3c07f810cb4874bf92c5313f9c0ba3ac78569031ceeee05524120822c46d2de3328b7a21ea9fb2cadecd7abb0c658bd29efdb1ac1d3a037b27f13d
7
+ data.tar.gz: 3e93068317140579daef9a4d931d4de91ad0f732221f1af0a7bb6c4c445f3242eff3453b6d4f7db5b6d164a67576e59c1703c63aad4479266c1dcaf16a13f6b0
@@ -1,3 +1,7 @@
1
+ # 2017.08.31 - azure-core gem @version 0.1.12
2
+ * Changed default value of header `MaxDataServiceVersion` to `3.0;NetFx` now that the service is available.
3
+ * `Azure::Core::Http::HTTPError` now can also parse JSON format response body for error type and description.
4
+
1
5
  # 2017.08.18 - azure-core gem @version 0.1.11
2
6
  * Changed 'nokogiri' to runtime dependency with version >= 1.6, and added documentation to resolve dependency issue to Readme for users with Ruby version lower than 2.2.0.
3
7
 
@@ -14,6 +14,7 @@
14
14
  #--------------------------------------------------------------------------
15
15
  require 'azure/core/error'
16
16
  require 'nokogiri'
17
+ require 'json'
17
18
 
18
19
  module Azure
19
20
  module Core
@@ -80,29 +81,44 @@ module Azure
80
81
  #
81
82
  # Returns nothing
82
83
  def parse_response
83
- if @http_response.body && @http_response.body.include?('<')
84
-
85
- document = Nokogiri.Slop(@http_response.body)
86
-
87
- @type = document.css('code').first.text if document.css('code').any?
88
- @type = document.css('Code').first.text if document.css('Code').any?
89
- @description = document.css('message').first.text if document.css('message').any?
90
- @description = document.css('Message').first.text if document.css('Message').any?
84
+ if @http_response.body && @http_response.respond_to?(:headers) && @http_response.headers['Content-Type']
85
+ if @http_response.headers['Content-Type'].include?('xml')
86
+ parse_xml_response
87
+ elsif @http_response.headers['Content-Type'].include?('json')
88
+ parse_json_response
89
+ end
90
+ else
91
+ parse_unknown_response
92
+ end
93
+ end
91
94
 
92
- @header = document.css('headername').first.text if document.css('headername').any?
93
- @header = document.css('HeaderName').first.text if document.css('HeaderName').any?
95
+ def parse_xml_response
96
+ document = Nokogiri.Slop(@http_response.body)
97
+
98
+ @type = document.css('code').first.text if document.css('code').any?
99
+ @type = document.css('Code').first.text if document.css('Code').any?
100
+ @description = document.css('message').first.text if document.css('message').any?
101
+ @description = document.css('Message').first.text if document.css('Message').any?
102
+ @header = document.css('headername').first.text if document.css('headername').any?
103
+ @header = document.css('HeaderName').first.text if document.css('HeaderName').any?
104
+ @header_value = document.css('headervalue').first.text if document.css('headervalue').any?
105
+ @header_value = document.css('HeaderValue').first.text if document.css('HeaderValue').any?
106
+
107
+ # service bus uses detail instead of message
108
+ @detail = document.css('detail').first.text if document.css('detail').any?
109
+ @detail = document.css('Detail').first.text if document.css('Detail').any?
110
+ end
94
111
 
95
- @header_value = document.css('headervalue').first.text if document.css('headervalue').any?
96
- @header_value = document.css('HeaderValue').first.text if document.css('HeaderValue').any?
112
+ def parse_json_response
113
+ odata_error = JSON.parse(@http_response.body)['odata.error']
114
+ @type = odata_error['code']
115
+ @description = odata_error['message']['value']
116
+ end
97
117
 
98
- # service bus uses detail instead of message
99
- @detail = document.css('detail').first.text if document.css('detail').any?
100
- @detail = document.css('Detail').first.text if document.css('Detail').any?
101
- else
102
- @type = 'Unknown'
103
- if @http_response.body
104
- @description = "#{@http_response.body.strip}"
105
- end
118
+ def parse_unknown_response
119
+ @type = 'Unknown'
120
+ if @http_response.body
121
+ @description = "#{@http_response.body.strip}"
106
122
  end
107
123
  end
108
124
 
@@ -121,7 +121,7 @@ module Azure
121
121
  def_headers['x-ms-date'] = current_time
122
122
  def_headers['x-ms-version'] = '2014-02-14'
123
123
  def_headers['DataServiceVersion'] = '1.0;NetFx'
124
- def_headers['MaxDataServiceVersion'] = '2.0;NetFx'
124
+ def_headers['MaxDataServiceVersion'] = '3.0;NetFx'
125
125
  def_headers['Content-Type'] = 'application/atom+xml; charset=utf-8'
126
126
  end
127
127
  end
@@ -18,7 +18,7 @@ module Azure
18
18
  class Version
19
19
  MAJOR = 0 unless defined? MAJOR
20
20
  MINOR = 1 unless defined? MINOR
21
- UPDATE = 11 unless defined? UPDATE
21
+ UPDATE = 12 unless defined? UPDATE
22
22
  PRE = nil unless defined? PRE
23
23
 
24
24
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-22 00:00:00.000000000 Z
12
+ date: 2017-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  requirements: []
211
211
  rubyforge_project:
212
- rubygems_version: 2.4.5
212
+ rubygems_version: 2.6.13
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: Core library to be consumed by Ruby SDK gems