ms_rest 0.6.2 → 0.6.3

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: 2d2db8ae8d8497768be9eb4c395a4e522b859dbf
4
- data.tar.gz: 15a44eba7e903c3f31d2746d96cd71b4a62cfaa3
3
+ metadata.gz: 10cbb1f919666f9c19887792759a060b79f59878
4
+ data.tar.gz: b33aca96c204967edb4b84c2f5404ace1a9e7c5a
5
5
  SHA512:
6
- metadata.gz: 886e52660f25ea8a4fdeece7f6042464553f674b47b5fd8f5b362875f59654538c14705459aa651885401eb6b9279646f4ccfe52cc507d15374fb8a94a2ebdf8
7
- data.tar.gz: 8836aae6f682ec3f123cf0dcb2b4e05935e931db01d8a346037d010f978d6bea0d00bf94f9e68e8409c5dd756f494ecee64f0ab78cee530ab8ac4e74c2de6ff2
6
+ metadata.gz: d3127b3854b0406b22e08c31fb6d284c6e580a97a08970261a53d10cd6f234773e29e2592b6768a860000a1cde3425fbbd062c9d2f6e915b8553dbc51cce5e3f
7
+ data.tar.gz: 6a4d804c66504db422d0697c315cfa22eeade02380fe39539d868d48251d1b15c7a505fe36dc35b189d58fac7aa28f43f89972154d0510b18febd94845228829
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ##2017.02.06 ms_rest version 0.6.3
2
+ * Adding JSONable mixin module to provide simple serialization / deserialization [PR #599](https://github.com/Azure/azure-sdk-for-ruby/pull/599)
3
+ * Making credentials optional parameter for MsRest::ServiceClient [PR #626](https://github.com/Azure/azure-sdk-for-ruby/pull/626)
4
+ * Bug fix while building path to handle double // [Issue #693](https://github.com/Azure/azure-sdk-for-ruby/issues/639) [PR #640](https://github.com/Azure/azure-sdk-for-ruby/pull/640)
5
+
1
6
  ##2016.11.14 ms_rest version 0.6.2
2
7
  * Missing default ca-cert for providing ssl options [#580](https://github.com/Azure/azure-sdk-for-ruby/issues/580)
3
8
 
@@ -21,4 +26,3 @@
21
26
 
22
27
  ##2016.07.14 ms_rest version 0.3.0
23
28
  * Moving serialization/deserializaiton code from sdk models to client runtime. [#1106](https://github.com/Azure/autorest/pull/1106)
24
-
data/README.md CHANGED
@@ -48,7 +48,7 @@ To start working on the gem the only additional dev dependency is required - rsp
48
48
  Reference it in the gemfile and also add this line to your client's gemspec file:
49
49
 
50
50
  ```ruby
51
- spec.add_runtime_dependency 'ms_rest', '~> 0.6.2'
51
+ spec.add_runtime_dependency 'ms_rest', '~> 0.6.3'
52
52
  ```
53
53
  Don't forget to correct the version.
54
54
 
data/lib/ms_rest.rb CHANGED
@@ -23,6 +23,7 @@ require 'ms_rest/http_operation_request'
23
23
  require 'ms_rest/http_operation_error'
24
24
  require 'ms_rest/retry_policy_middleware'
25
25
  require 'ms_rest/service_client'
26
+ require 'ms_rest/jsonable'
26
27
 
27
28
  module MsRest end
28
29
  module MsRest::Serialization end
@@ -91,7 +91,7 @@ module MsRest
91
91
  template = path_template.dup
92
92
  path_params.each{ |key, value| template["{#{key}}"] = ERB::Util.url_encode(value) if template.include?("{#{key}}") } unless path_params.nil?
93
93
  skip_encoding_path_params.each{ |key, value| template["{#{key}}"] = value } unless skip_encoding_path_params.nil?
94
- path = URI.parse(template.gsub(/([^:])\/\//, '\1/'))
94
+ path = URI.parse(template.gsub(/([^:]|\A)\/\//, '\1/'))
95
95
  unless skip_encoding_query_params.nil?
96
96
  path.query = [(path.query || ""), skip_encoding_query_params.reject{|_, v| v.nil?}.map{|k,v| "#{k}=#{v}"}].join('&')
97
97
  end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ module MsRest
6
+ # Mixin to provide simple serialization / deserialization in AutoRest generated model classes
7
+ module JSONable
8
+ include MsRest::Serialization
9
+
10
+ #
11
+ # Serialize the object to JSON
12
+ # @return [String] JSON serialized version of the object
13
+ #
14
+ def to_json
15
+ serialize(self.class.mapper, self)
16
+ end
17
+
18
+ #
19
+ # Deserialize the object from JSON
20
+ # @param json [String] JSON string representation of the object
21
+ # @return [JSONable] object built from json input
22
+ #
23
+ def from_json(json)
24
+ deserialize(self.class.mapper, json)
25
+ end
26
+
27
+ #
28
+ # String representation of the object
29
+ # @return [String]
30
+ #
31
+ def to_s
32
+ "#{super} #{to_json.to_s}"
33
+ end
34
+ end
35
+ end
@@ -15,7 +15,7 @@ module MsRest
15
15
  # @param response_body [Hash] Ruby Hash object to deserialize.
16
16
  # @param object_name [String] Name of the deserialized object.
17
17
  #
18
- def deserialize(mapper, response_body, object_name)
18
+ def deserialize(mapper, response_body, object_name = nil)
19
19
  build_serializer.deserialize(mapper, response_body, object_name)
20
20
  end
21
21
 
@@ -26,7 +26,7 @@ module MsRest
26
26
  # @param object [Object] Ruby object to serialize.
27
27
  # @param object_name [String] Name of the serialized object.
28
28
  #
29
- def serialize(mapper, object, object_name)
29
+ def serialize(mapper, object, object_name = nil)
30
30
  build_serializer.serialize(mapper, object, object_name)
31
31
  end
32
32
 
@@ -391,7 +391,14 @@ module MsRest
391
391
  # @param model_name [String] Name of the model to retrieve.
392
392
  #
393
393
  def get_model(model_name)
394
- Object.const_get(@context.class.to_s.split('::')[0...-1].join('::') + "::Models::#{model_name}")
394
+ consts = @context.class.to_s.split('::')
395
+ if consts.any?{ |const| const == 'Models' }
396
+ # context is a model class
397
+ @context.class
398
+ else
399
+ # context is a service, so find the model class
400
+ Object.const_get(consts[0...-1].join('::') + "::Models::#{model_name}")
401
+ end
395
402
  end
396
403
 
397
404
  #
@@ -27,7 +27,7 @@ module MsRest
27
27
  # HTTP requests made by the service client.
28
28
  # @param options additional parameters for the HTTP request (not implemented yet).
29
29
  #
30
- def initialize(credentials, options = nil)
30
+ def initialize(credentials = nil, options = nil)
31
31
  @credentials = credentials
32
32
  @request_headers = {}
33
33
  @middlewares = {middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]]}
@@ -3,5 +3,5 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for license information.
4
4
 
5
5
  module MsRest
6
- VERSION = '0.6.2'
6
+ VERSION = '0.6.3'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ms_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-14 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,6 +114,7 @@ files:
114
114
  - lib/ms_rest/http_operation_error.rb
115
115
  - lib/ms_rest/http_operation_request.rb
116
116
  - lib/ms_rest/http_operation_response.rb
117
+ - lib/ms_rest/jsonable.rb
117
118
  - lib/ms_rest/rest_error.rb
118
119
  - lib/ms_rest/retry_policy_middleware.rb
119
120
  - lib/ms_rest/serialization.rb