soaspec 0.2.22 → 0.2.23

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
  SHA256:
3
- metadata.gz: 2f3a41968e523901e869b24522b1fe2c630518239fed2e3600f2e8f5b67a9fb5
4
- data.tar.gz: f9af632f2e025cccf4da721120ca44e5aed446d0b5b2353e860d347fbfd28594
3
+ metadata.gz: 984b49dfa801f4f86aeca02b864d1a0077ad9b998bce7497f8566de102dd874b
4
+ data.tar.gz: d0dff6ccbaecb663de4af1fd10a70481ca02ed75934662760476c9567366d41e
5
5
  SHA512:
6
- metadata.gz: a1eb7bf52e74e6c355bf5f078707a97998c90c6084caaae85e4647ad3750e1c5daa9f593f1dbb4aa4bc688a410fa1c3c04a13e06037949a53547d1c3b04305f4
7
- data.tar.gz: 77f6623886cb834aac76e5bdc275bee97260ddec1d0277c7f57bdb042355d45b03e94902900526520d2ffd2b0e05a23c41980d6c5eae11eee8aadf3c0f4375b2
6
+ metadata.gz: f4274b58b4aa962229592148d4b45018bf7f3365f65012c7b4409e0f84fa912acd194bd2376e0563a30ad6c6b7dfa6567abfdf392cbb2999b7db4399893ac3ad
7
+ data.tar.gz: e0532bf5aef88377ae778649823068d4eb77ae8968f1c4a1204d59fedefb66b9c5361481396a5ef7fafd12caf396d42d411b2f02a9a5a9f9b96048e836a037a0
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.2.23
2
+ * Enhancement
3
+ * Interpreter handles XML Doc
4
+ * Get document_type_for complex element working. Hopefully should be able to handle WSDL with large response now
5
+
1
6
  Version 0.2.22
2
7
  * Bug Fix
3
8
  * Allow negated version of 'be_successful' to work
@@ -15,7 +15,7 @@ class Interpreter
15
15
  end
16
16
  elsif response.is_a? Hash
17
17
  :hash
18
- elsif response.is_a? Nokogiri::XML::NodeSet
18
+ elsif response.is_a?(Nokogiri::XML::NodeSet) || response.is_a?(Nokogiri::XML::Document)
19
19
  :xml
20
20
  else
21
21
  :unknown
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.2.22'.freeze
2
+ VERSION = '0.2.23'.freeze
3
3
  end
@@ -71,6 +71,12 @@ module Soaspec
71
71
  !type.xpath("*/#{type.first.namespace.prefix}:enumeration").empty?
72
72
  end
73
73
 
74
+ # @param [Nokogiri::XML::Element] element
75
+ # @return [String] Name of element excluding namespace
76
+ def name_after_namespace(element)
77
+ value_after_namespace(element.name)
78
+ end
79
+
74
80
  # Return value of string after a namespace
75
81
  # @param [String] string String to parse for part after namespace
76
82
  # @return [String] Part after the namespace, demonstrated by ':'
@@ -95,7 +101,7 @@ module Soaspec
95
101
  # @param [Nokogiri::XML::Element] element Element to check
96
102
  # @return [Boolean] True if Nokogiri element is a complex type, that is, has a complexType element underneath itself
97
103
  def complex_type?(element)
98
- element.children.any? { |child| child.name == 'complexType' }
104
+ element.children.any? { |child| name_after_namespace(child) == 'complexType' }
99
105
  end
100
106
 
101
107
  # @param [String, Symbol] underscore_separated Snakecase value to be converted to camel case
@@ -104,18 +110,26 @@ module Soaspec
104
110
  underscore_separated.to_s.split('_').collect(&:capitalize).join
105
111
  end
106
112
 
113
+ # Element at the root of an operation
114
+ # @param [Hash] op_details Hash with details from WSDL for an operation
115
+ def root_element_for(op_details)
116
+ root_element = @wsdl_schemas.at_xpath("//*[@name='#{op_details[:input]}']")
117
+ raise 'Operation has no input defined' if root_element.nil?
118
+
119
+ root_element
120
+ end
121
+
122
+ # Returns list of elements present at the root of an operation
107
123
  # @param [Hash] op_details Hash with details from WSDL for an operation
108
124
  # @return [Nokogiri::XML::NodeSet] List of the root elements in the SOAP body
109
125
  def root_elements_for(op_details)
110
126
  raise "'@wsdl_schemas' must be defined" if @wsdl_schemas.nil?
111
127
 
112
- root_element = @wsdl_schemas.at_xpath("//*[@name='#{op_details[:input]}']")
113
- raise 'Operation has no input defined' if root_element.nil?
114
-
128
+ root_element = root_element_for(op_details)
115
129
  schema_namespace = root_element.namespace.prefix
116
130
  root_type = root_element['type']
117
131
  if root_type
118
- @wsdl_schemas.xpath("//*[@name='#{root_type.split(':').last}']//#{schema_namespace}:element")
132
+ @wsdl_schemas.xpath("//*[@name='#{value_after_namespace(root_type)}']//#{schema_namespace}:element")
119
133
  else
120
134
  return [] unless complex_type? root_element # Empty Array if there are no root elements
121
135
 
@@ -126,6 +140,7 @@ module Soaspec
126
140
  end
127
141
 
128
142
  # Adds documentation content for all children of XML element
143
+ # This will be an example yaml for setting SOAP requests
129
144
  # @param [Nokogiri::XML::Element] element Type to document for
130
145
  # @param [Integer] depth How many times to iterate depth for
131
146
  def document_type_for(element, depth = 1)
@@ -133,10 +148,10 @@ module Soaspec
133
148
  return unless depth < 6
134
149
 
135
150
  if complex_type? element
136
- complex_type = element.children.find { |c| c.name == 'complexType' }
137
- sequence = complex_type.children.find { |c| c.name == 'sequence' }
151
+ complex_type = element.children.find { |c| name_after_namespace(c) == 'complexType' }
152
+ sequence = complex_type.children.find { |c| name_after_namespace(c) == 'sequence' }
138
153
  sequence.children.select { |node| node.class == Nokogiri::XML::Element }.each do |sub_element|
139
- document_type_for sub_element, depth += 1
154
+ document_type_for sub_element, depth + 1
140
155
  end
141
156
  else
142
157
  return "No type seen for #{element}, #{element.class}" unless element['type']
@@ -149,6 +164,7 @@ module Soaspec
149
164
  end
150
165
  end
151
166
 
167
+ # @todo This should return YAML rather than just set an instance variable
152
168
  # Makes a yaml string in a '@content' instance variable
153
169
  # @param [Nokogiri::XML::NodeSet] list List to convert to YAML
154
170
  def wsdl_to_yaml_for(list)
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.2.22
4
+ version: 0.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler