lolsoap 0.9.0 → 0.10.0

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
- SHA1:
3
- metadata.gz: f3f35de62b3329ac274dbf69b5fd25052d22d41c
4
- data.tar.gz: 306b20946e12d19ead01e087aebc890f28578f11
2
+ SHA256:
3
+ metadata.gz: a09434296d2a8e8a79df7eaa09fb83e73b1204b0e5ef0bd806619c2fe3e4ef54
4
+ data.tar.gz: 1d20400665a1a131da2254eac6561b8dc8d25c24caab7638e6a45a545f772c94
5
5
  SHA512:
6
- metadata.gz: 65b2031d1b4ae9caa69bc9dadbe75a13b4d5b4adc48e0543db7959b0bcdf68c462e6e7e25d98242ba7edf27a946f833700a121888184e8bd9b74a3d55008d8b7
7
- data.tar.gz: a1406021f4af3844a990c1b5085693bef493a02da5c326859cc8c612dfebe889f820f01478da73786e0383a6b5f703dfbe08ea55c9385b20242790477fe5bb6d
6
+ metadata.gz: c45884341a7061d94cc33e6af9751f39ba843fbed09286aad8e8c8d97ef2c4822f68b805de3aacde826339f445b36d58a9b5aad6132a6f94e71d4cf750a9c6b4
7
+ data.tar.gz: d1b757bbc9d0426eb95bf4df758c6507420e42dc50ddd1dd5d8a84e0bc91db85f3a3b1fa29f789723ce25c4d27f68d33b669354b3fb65176f1ca9bf0c4a9bd95
data/README.md CHANGED
@@ -120,6 +120,10 @@ Development sponsored by [Loco2](http://loco2.com/).
120
120
 
121
121
  ## Changelog ##
122
122
 
123
+ ### 0.10 ###
124
+
125
+ * Added support for using WSDL with abstract types in operation definitions
126
+
123
127
  ### 0.9 ###
124
128
 
125
129
  * Support unqualified form for elements in a schema
@@ -1,3 +1,3 @@
1
1
  module LolSoap
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -13,8 +13,8 @@ module LolSoap
13
13
  require 'lolsoap/wsdl/operation_io_part'
14
14
 
15
15
  # Create a new instance by parsing a raw string of XML
16
- def self.parse(raw)
17
- new(WSDLParser.parse(raw))
16
+ def self.parse(raw, options={})
17
+ new(WSDLParser.parse(raw), options)
18
18
  end
19
19
 
20
20
  # The SOAP endpoint URL
@@ -29,13 +29,15 @@ module LolSoap
29
29
  # The version of SOAP detected.
30
30
  attr_reader :soap_version
31
31
 
32
- def initialize(parser)
33
- @prefixes = generate_prefixes(parser)
34
- @namespaces = prefixes.invert
35
- @types = load_types(parser)
36
- @operations = load_operations(parser)
37
- @endpoint = parser.endpoint
32
+ def initialize(parser, options={})
33
+ @prefixes = generate_prefixes(parser)
34
+ @namespaces = prefixes.invert
35
+ @abstract_types = load_types(parser.abstract_types)
36
+ @types = load_types(parser.types)
37
+ @operations = load_operations(parser)
38
+ @endpoint = parser.endpoint
38
39
  @soap_version = parser.soap_version
40
+ @allow_abstract_types = options[:allow_abstract_types]
39
41
  end
40
42
 
41
43
  # Hash of types declared by the service
@@ -43,9 +45,23 @@ module LolSoap
43
45
  Hash[@types.values.map { |t| [t.name, t] }]
44
46
  end
45
47
 
48
+ # Hash of abstract types declared by the service
49
+ def abstract_types
50
+ Hash[@abstract_types.values.map { |t| [t.name, t] }]
51
+ end
52
+
46
53
  # Get a single type, or a NullType if the type doesn't exist
47
54
  def type(namespace, name)
48
- @types.fetch([namespace, name]) { NullType.new }
55
+ if @allow_abstract_types
56
+ @types.fetch([namespace, name]) { abstract_type(namespace, name) }
57
+ else
58
+ @types.fetch([namespace, name]) { NullType.new }
59
+ end
60
+ end
61
+
62
+ # Get a single abstract type, or a NullType if the type doesn't exist
63
+ def abstract_type(namespace, name)
64
+ @abstract_types.fetch([namespace, name]) { NullType.new }
49
65
  end
50
66
 
51
67
  # Hash of operations that are supported by the SOAP service
@@ -73,9 +89,9 @@ module LolSoap
73
89
  private
74
90
 
75
91
  # @private
76
- def load_types(parser)
92
+ def load_types(types)
77
93
  Hash[
78
- parser.types.map do |id, type|
94
+ types.map do |id, type|
79
95
  [id, build_type(type)]
80
96
  end
81
97
  ]
@@ -307,12 +307,18 @@ module LolSoap
307
307
  types = {}
308
308
  each_node('xs:complexType[not(@abstract="true")]') do |node, schema|
309
309
  type = Type.new(self, schema, node)
310
- types[type.id] = {
311
- :name => type.name,
312
- :namespace => type.namespace,
313
- :elements => type.elements,
314
- :attributes => type.attributes
315
- }
310
+ types[type.id] = type_record(type)
311
+ end
312
+ types
313
+ end
314
+ end
315
+
316
+ def abstract_types
317
+ @abstract_types ||= begin
318
+ types = {}
319
+ each_node('xs:complexType[@abstract="true"]') do |node, schema|
320
+ type = Type.new(self, schema, node)
321
+ types[type.id] = type_record(type)
316
322
  end
317
323
  types
318
324
  end
@@ -446,5 +452,15 @@ module LolSoap
446
452
  node_class.new(self, schema, node)
447
453
  end
448
454
  end
455
+
456
+ private
457
+ def type_record(type)
458
+ {
459
+ :name => type.name,
460
+ :namespace => type.namespace,
461
+ :elements => type.elements,
462
+ :attributes => type.attributes
463
+ }
464
+ end
449
465
  end
450
466
  end
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_dependency 'nokogiri', '~> 1.5'
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler", "~> 2.0"
23
+ spec.add_development_dependency "rake", "~> 12.3"
24
24
  spec.add_development_dependency "minitest", "~> 2.10.0"
25
25
  spec.add_development_dependency "yard"
26
26
  end
@@ -28,6 +28,11 @@ module LolSoap
28
28
  o.input.body.content.name.must_equal 'historicalPriceRequest'
29
29
  end
30
30
 
31
+ subject.abstract_types.length.must_equal 1
32
+ subject.abstract_types.fetch('BaseRequest').tap do |t|
33
+ t.prefix.must_equal 'ns0'
34
+ end
35
+
31
36
  subject.types.length.must_equal 4
32
37
  subject.types.fetch('TradePriceRequest').tap do |t|
33
38
  t.prefix.must_equal 'ns0'
@@ -59,8 +59,16 @@ module LolSoap
59
59
  :attributes => ['id'],
60
60
  :namespace => namespace
61
61
  }
62
- },
63
- :elements => {
62
+ },
63
+ :abstract_types => {
64
+ [namespace, 'BaseBrush'] => {
65
+ :name => 'BaseBrush',
66
+ :elements => {},
67
+ :attributes => ['id'],
68
+ :namespace => namespace
69
+ },
70
+ },
71
+ :elements => {
64
72
  [namespace, 'brush'] => {
65
73
  :name => 'brush',
66
74
  :namespace => namespace,
@@ -172,6 +180,16 @@ module LolSoap
172
180
  end
173
181
  end
174
182
 
183
+ describe '#abstract_types' do
184
+ it 'returns a hash of abstract types' do
185
+ subject.abstract_types.length.must_equal 1
186
+
187
+ subject.abstract_types['BaseBrush'].tap do |t|
188
+ t.attributes.must_equal ['id']
189
+ end
190
+ end
191
+ end
192
+
175
193
  describe '#type' do
176
194
  it 'returns a single type' do
177
195
  subject.type(namespace, 'Brush').must_equal subject.types.fetch('Brush')
@@ -180,6 +198,28 @@ module LolSoap
180
198
  it 'returns a null object if a type is missing' do
181
199
  subject.type(namespace, 'FooBar').must_equal WSDL::NullType.new
182
200
  end
201
+
202
+ it 'returns a null object for abstract types' do
203
+ subject.type(namespace, 'BaseBrush').must_equal WSDL::NullType.new
204
+ end
205
+
206
+ describe 'when abstract types are allowed' do
207
+ subject { WSDL.new(parser, :allow_abstract_types => true) }
208
+
209
+ it 'returns an abstract type' do
210
+ subject.type(namespace, 'BaseBrush').must_equal subject.abstract_types.fetch('BaseBrush')
211
+ end
212
+ end
213
+ end
214
+
215
+ describe '#abstract_type' do
216
+ it 'returns a single type' do
217
+ subject.abstract_type(namespace, 'BaseBrush').must_equal subject.abstract_types.fetch('BaseBrush')
218
+ end
219
+
220
+ it 'returns a null object if a type is missing' do
221
+ subject.abstract_type(namespace, 'FooBar').must_equal WSDL::NullType.new
222
+ end
183
223
  end
184
224
  end
185
225
  end
@@ -107,6 +107,26 @@ module LolSoap
107
107
  end
108
108
  end
109
109
 
110
+ describe "#abstract_types" do
111
+ it 'returns the abstract types, with attributes and namespace' do
112
+ subject.abstract_types.must_equal({
113
+ [namespace, "BaseRequest"] => {
114
+ :name => "BaseRequest",
115
+ :namespace => "http://example.com/stockquote.xsd",
116
+ :elements => {
117
+ "accountId" => {
118
+ :name => "accountId",
119
+ :namespace => "http://example.com/stockquote.xsd",
120
+ :type => [xs, "string"],
121
+ :singular=>true
122
+ }
123
+ },
124
+ :attributes=>["signature"]
125
+ },
126
+ })
127
+ end
128
+ end
129
+
110
130
  describe '#elements' do
111
131
  it 'returns the elements with inline types' do
112
132
  subject.elements.must_equal({
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolsoap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Leighton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2019-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '12.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.6.13
160
+ rubygems_version: 2.7.6
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: A library for dealing with SOAP requests and responses.
@@ -183,4 +183,3 @@ test_files:
183
183
  - test/unit/test_wsdl_parser.rb
184
184
  - test/unit/wsdl/test_element.rb
185
185
  - test/unit/wsdl/test_type.rb
186
- has_rdoc: