soaspec 0.0.50 → 0.0.51

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: 19dafaaba6b39b922969a31020ea43fa9c93b530
4
- data.tar.gz: 04ed01a14243a2f6763590c6bf2ef00b9f394715
3
+ metadata.gz: e5b5fa8cf8849c0d7ad63f02428f7a7c7050e7b0
4
+ data.tar.gz: 55a05b486e03cb4d7ccb32f3cbfd14be87cd0f09
5
5
  SHA512:
6
- metadata.gz: e4c0e7c85069f3cb5263b41468523f07f675665f2616a1b4254dc3e588fab1f2f7e8992c6c9ba7a8ea0d774e312cb05ba2d7371de0cf8bcd1010bcabbaf81424
7
- data.tar.gz: ad6c88d92f1563669fd2454f2eb034877040699314e8db3fe3bb65f4276a24d03baafc0ff5ba73ad5523de88940ba247374a613c0b881343a8e47f4187de8e30
6
+ metadata.gz: 497e23505b69ba428131d7f327a69d60d25c0db3127a12c09711cca6d26e48212c10129768c63efca13f29a8222a09e0ed1f9ed7a6980963ab8cf7dc81e55754
7
+ data.tar.gz: 9873e4e70251804d46114bc60e84877bb778528cd854cb1062044006681f926903c5de323e15a3ab1bf45ebcd63bda1ae6fd37b4b0f5769cc385104c82c17c3e
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.0.51
2
+ * Enhancements
3
+ * Allow for 'default_hash=' method to be used in RestHandler. See 'many_calls_one_method_spec' for example
4
+ * Got element accessor working correctly (See soap/hash_spec.rb + 'blz_service' for example)
5
+
1
6
  Version 0.0.50
2
7
  * Enhancements
3
8
  * Able to use ERB in oauth parameters and extract oauth hash with 'oauth_response' method defined by 'oauth_file'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- soaspec (0.0.50)
4
+ soaspec (0.0.51)
5
5
  jsonpath
6
6
  rest-client (>= 2.0)
7
7
  rspec (~> 3.0)
@@ -14,7 +14,7 @@ pet:
14
14
  name: 'string'
15
15
  status: sold
16
16
 
17
- pet1:
17
+ default_pet:
18
18
  id: '123987'
19
19
  category:
20
20
  id: '1'
@@ -27,28 +27,11 @@ pet1:
27
27
  name: 'string'
28
28
  status: available
29
29
 
30
+ pet1:
31
+ id: '123987'
32
+
30
33
  pet2:
31
34
  id: '9998772'
32
- category:
33
- id: '1'
34
- name: 'string'
35
- name: 'new_puppy'
36
- photoUrls:
37
- - 'string'
38
- tags:
39
- - id: '1'
40
- name: 'string'
41
- status: available
42
35
 
43
36
  pet3:
44
37
  id: '554678'
45
- category:
46
- id: '1'
47
- name: 'string'
48
- name: 'new_puppy'
49
- photoUrls:
50
- - 'string'
51
- tags:
52
- - id: '1'
53
- name: 'string'
54
- status: available
@@ -28,10 +28,9 @@ class Exchange
28
28
  @override_parameters = override_parameters
29
29
  @retry_for_success = false
30
30
  self.retry_count = 3
31
- # puts 'ELE ' + @api_class.elements.to_s
32
31
  @api_class.elements.each do |element|
33
- define_singleton_method(element) do
34
- @api_class.__send__(element, response)
32
+ define_singleton_method(element.to_s.split('__custom_path_').last) do
33
+ @api_class.__send__(element, response) # Forward the call onto handler to retrieve the element for the response
35
34
  end
36
35
  end
37
36
  end
@@ -13,7 +13,14 @@ module Soaspec
13
13
 
14
14
  # Explicitly defined elements for which a path has been predefined
15
15
  def elements
16
- @elements || []
16
+ public_methods.select { |i| i[/__custom_path_.+/] }
17
+ end
18
+
19
+ # Set the default hash representing data to be used in making a request
20
+ # This will set the @request_option instance variable too
21
+ def default_hash=(hash)
22
+ @request_option = :hash
23
+ @default_hash = Soaspec.always_use_keys? ? hash.transform_keys_to_symbols : hash
17
24
  end
18
25
 
19
26
  # Set instance variable name
@@ -65,11 +65,7 @@ module Soaspec
65
65
  # @param [String, Symbol] name Method name used to access element
66
66
  # @param [String, Symbol] path Path to find object (e.g, XPath, JSONPath)
67
67
  def element(name, path)
68
- # puts 'Making with ' + name.to_s + path
69
- @elements ||= []
70
- @elements << name.to_s # Add record to list of elements used by exchange
71
- # puts 'NOW ELE' + @elements.to_s
72
- define_method(name.to_s) do |response|
68
+ define_method("__custom_path_#{name}") do |response|
73
69
  value_from_path(response, path.to_s)
74
70
  end
75
71
  end
@@ -7,6 +7,7 @@ require_relative '../interpreter'
7
7
  require 'json'
8
8
  require 'jsonpath'
9
9
  require 'nori'
10
+ require 'erb'
10
11
 
11
12
  module Soaspec
12
13
 
@@ -110,17 +111,19 @@ module Soaspec
110
111
  end
111
112
 
112
113
  # Setup object to handle communicating with a particular SOAP WSDL
113
- # @param [Hash] specific_options Options defining SOAP request. WSDL, authentication
114
+ # @param [Hash] options Options defining SOAP request. WSDL, authentication
114
115
  def initialize(name = self.class.to_s, options = {})
115
116
  raise "Base URL not set! Please set in class with 'base_url' method" unless base_url_value
117
+ @default_hash = {}
116
118
  if name.is_a?(Hash) && options == {} # If name is not set
117
119
  options = name
118
120
  name = self.class.to_s
119
121
  end
122
+ super
123
+ set_remove_key(options, :default_hash)
120
124
  merged_options = rest_resource_options
121
125
  merged_options.merge!(options)
122
126
  @resource = RestClient::Resource.new(base_url_value, merged_options) # @resource[url_extension].get
123
- super
124
127
  end
125
128
 
126
129
  # Used in together with Exchange request that passes such override parameters
@@ -137,14 +140,14 @@ module Soaspec
137
140
 
138
141
  begin
139
142
  response = case test_values[:method]
140
- when :post, :patch, :put
141
- unless test_values[:payload]
142
- test_values[:payload] = JSON.generate(test_values[:body]).to_s if test_values[:body]
143
- end
144
- @resource_used.send(test_values[:method].to_s, test_values[:payload], test_values[:params])
145
- else
146
- @resource_used.send(test_values[:method].to_s, test_values[:params])
147
- end
143
+ when :post, :patch, :put
144
+ unless test_values[:payload]
145
+ test_values[:payload] = JSON.generate(@default_hash.merge(test_values[:body])).to_s if test_values[:body]
146
+ end
147
+ @resource_used.send(test_values[:method].to_s, test_values[:payload], test_values[:params])
148
+ else
149
+ @resource_used.send(test_values[:method].to_s, test_values[:params])
150
+ end
148
151
  rescue RestClient::ExceptionWithResponse => e
149
152
  response = e.response
150
153
  end
@@ -103,13 +103,6 @@ module Soaspec
103
103
  end
104
104
  end
105
105
 
106
- # Set the default hash representing data to be used in making a request
107
- # This will set the @request_option instance variable too
108
- def default_hash=(hash)
109
- @request_option = :hash
110
- @default_hash = Soaspec.always_use_keys? ? hash.transform_keys_to_symbols : hash
111
- end
112
-
113
106
  # @param [Hash] format Format of expected result
114
107
  # @return [Object] Generic body to be displayed in error messages
115
108
  def response_body(response, format: :hash)
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.50'
2
+ VERSION = '0.0.51'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler