soap4r-ng 2.1.0 → 2.1.1

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: 1ec08ba5accd7ec65e6304c09557a8da24d1c084f1d8da5a670cc43f170215d4
4
- data.tar.gz: 511a26a5a90fedd8d1bca578b39bd3273f11bba64a41647e569107bdcad33461
3
+ metadata.gz: c35bbc2b8a935aa7ac62209afc47abd84db691861878863f58163f8cdfc86ef9
4
+ data.tar.gz: ee6fcded626fc828440e1a38a02070facd66f120baf55164fa2eb20b2b2c08cb
5
5
  SHA512:
6
- metadata.gz: ad85078c39eed227b20ca73050e2c36cc272fa037b7afea634da3ecee9214f1941ce7c7a26a377f365a1303cfd7e986124ae317ecd85e2b5cb942ec4c7d8b215
7
- data.tar.gz: 5f13e6fadeb0b16cad896050c67e6f9455b9c1684fb7f78a3009c1ea1508e8c0fe572884040ff83f02b4bece9644e5caf2bd15ae02908d5af63632eb7d52c088
6
+ metadata.gz: 9052b0804246c8fdc3f62288c00e03ab572a7bf0960d7a0ea658ff66ca68d5cf6ea280b7b466efac597fcbf166984119b118bd986009aa798eec96379bce15a8
7
+ data.tar.gz: fccb428ad847f1bb16ae74ad5249ae4a99783ac5beaddfa7f1393598cfede2cc5e5315f774d776352f3c9fcdd867899c07ce555e923b7d595c676694e7fcbca1
@@ -169,8 +169,10 @@ private
169
169
  unless no_proxy?(url)
170
170
  proxy_host = @proxy.host
171
171
  proxy_port = @proxy.port
172
+ proxy_user = @proxy.user
173
+ proxy_password = @proxy.password
172
174
  end
173
- http = Net::HTTP::Proxy(proxy_host, proxy_port).new(url.host, url.port)
175
+ http = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_password).new(url.host, url.port)
174
176
  if http.respond_to?(:set_debug_output)
175
177
  http.set_debug_output(@debug_dev)
176
178
  end
data/lib/soap/version.rb CHANGED
@@ -3,7 +3,7 @@ module SOAP
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 2
5
5
  MINOR = 1
6
- TINY = 0
6
+ TINY = 1
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
9
9
  FORK = "SOAP4R-NG"
@@ -274,8 +274,20 @@ private
274
274
  c.comment = "#{qname}"
275
275
  c.comment << "\nabstract" if typedef.abstract
276
276
  parentmodule = mapped_class_name(qname, mpath)
277
+ # Shared across both parse_elements calls below (and all of their
278
+ # recursive descendants) so that a name reachable through two
279
+ # independent paths -- e.g. two group refs each declaring an element
280
+ # called "shared" -- is detected as a collision no matter which branch
281
+ # of the content model it comes from.
282
+ varnames = {}
277
283
  init_lines, init_params =
278
- parse_elements(c, typedef.elements, qname.namespace, parentmodule)
284
+ parse_elements(c, typedef.elements, qname.namespace, parentmodule, false, varnames)
285
+ if typedef.content && (WSDL::XMLSchema::Group === typedef.content)
286
+ g_init_lines, g_init_params =
287
+ parse_elements(c, typedef.content.refelement.elements, qname.namespace, parentmodule, false, varnames)
288
+ init_lines = (g_init_lines + init_lines)
289
+ init_params = (g_init_params + init_params)
290
+ end
279
291
  unless typedef.attributes.empty?
280
292
  define_attribute(c, typedef.attributes)
281
293
  init_lines << "@__xmlattr = {}"
@@ -286,7 +298,20 @@ private
286
298
  c
287
299
  end
288
300
 
289
- def parse_elements(c, elements, base_namespace, mpath, as_array = false)
301
+ # varnames tracks every attribute/param name assigned so far across the
302
+ # whole recursive walk for one class (threaded through by the caller, and
303
+ # passed on unchanged to every recursive call below), so that a name
304
+ # reachable through two independent paths -- e.g. two group refs each
305
+ # declaring an element called "shared" -- collides no matter which branch
306
+ # of the content model it comes from. Without this, the second "shared"
307
+ # would emit an `attr_accessor :shared` and `def initialize(shared = nil)`
308
+ # entry identical to the first, silently wiring both onto the very same
309
+ # @shared ivar (a plain Array#uniq on init_params alone would only paper
310
+ # over the resulting SyntaxError, not this data loss: the two occurrences
311
+ # would remain last-write-wins instead of independently addressable). We
312
+ # instead suffix the repeat, the same way define_attribute already
313
+ # disambiguates colliding attribute constants below.
314
+ def parse_elements(c, elements, base_namespace, mpath, as_array = false, varnames = {})
290
315
  init_lines = []
291
316
  init_params = []
292
317
  any = false
@@ -317,6 +342,12 @@ private
317
342
  unless as_array
318
343
  attrname = safemethodname(name)
319
344
  varname = safevarname(name)
345
+ varnames[varname] ||= 0
346
+ if (varnames[varname] += 1) > 1
347
+ suffix = "_#{varnames[varname]}"
348
+ attrname += suffix
349
+ varname += suffix
350
+ end
320
351
  c.def_attr(attrname, true, varname)
321
352
  init_lines << "@#{varname} = #{varname}"
322
353
  if element.map_as_array?
@@ -328,21 +359,24 @@ private
328
359
  end
329
360
  when WSDL::XMLSchema::Sequence
330
361
  child_init_lines, child_init_params =
331
- parse_elements(c, element.elements, base_namespace, mpath, as_array)
362
+ parse_elements(c, element.elements, base_namespace, mpath, as_array, varnames)
332
363
  init_lines.concat(child_init_lines)
333
364
  init_params.concat(child_init_params)
334
365
  when WSDL::XMLSchema::Choice
335
366
  child_init_lines, child_init_params =
336
- parse_elements(c, element.elements, base_namespace, mpath, as_array)
367
+ parse_elements(c, element.elements, base_namespace, mpath, as_array, varnames)
337
368
  init_lines.concat(child_init_lines)
338
369
  init_params.concat(child_init_params)
339
370
  when WSDL::XMLSchema::Group
371
+ if element.ref && element.content.nil?
372
+ element.content = element.refelement
373
+ end
340
374
  if element.content.nil?
341
375
  warn("no group definition found: #{element}")
342
376
  next
343
377
  end
344
378
  child_init_lines, child_init_params =
345
- parse_elements(c, element.content.elements, base_namespace, mpath, as_array)
379
+ parse_elements(c, element.content.elements, base_namespace, mpath, as_array, varnames)
346
380
  init_lines.concat(child_init_lines)
347
381
  init_params.concat(child_init_params)
348
382
  else
@@ -354,7 +388,10 @@ private
354
388
 
355
389
  def define_attribute(c, attributes)
356
390
  const = {}
357
- unless attributes.empty?
391
+ # No __xmlattr-backed storage is needed when every attribute is fixed:
392
+ # their getters return the fixed literal directly and none of them get
393
+ # a setter (see below), so there's nothing left to read the hash for.
394
+ unless attributes.empty? || attributes.all? { |attribute| attribute.fixed }
358
395
  c.def_method("__xmlattr") do <<-__EOD__
359
396
  @__xmlattr ||= {}
360
397
  __EOD__
@@ -369,18 +406,37 @@ private
369
406
  constname += "_#{const[constname]}"
370
407
  end
371
408
  c.def_const(constname, dqname(name))
372
- c.def_method(methodname) do <<-__EOD__
373
- __xmlattr[#{constname}]
374
- __EOD__
409
+ c.def_method(methodname) do
410
+ define_attribute_reader_body(attribute, constname)
375
411
  end
376
- c.def_method(methodname + '=', 'value') do <<-__EOD__
377
- __xmlattr[#{constname}] = value
378
- __EOD__
412
+ # XSD's `fixed` value constraint means any value other than the fixed
413
+ # one is invalid, so there's no legitimate value a setter could ever
414
+ # assign; omit it entirely rather than generate a footgun.
415
+ unless attribute.fixed
416
+ c.def_method(methodname + '=', 'value') do <<-__EOD__
417
+ __xmlattr[#{constname}] = value
418
+ __EOD__
419
+ end
379
420
  end
380
421
  c.comment << "\n #{methodname} - #{attribute_basetype(attribute) || '(any)'}"
381
422
  end
382
423
  end
383
424
 
425
+ # Per XML Schema Part 1 S3.2.1, a `fixed` or `default` value constraint
426
+ # means an omitted attribute is treated as if it were present with that
427
+ # value -- this was previously discarded at codegen time, silently
428
+ # dropping that XSD semantic. `fixed` wins if both are somehow set, since
429
+ # WSDL::XMLSchema::Attribute itself only ever populates one or the other.
430
+ def define_attribute_reader_body(attribute, constname)
431
+ if f = attribute.fixed
432
+ %Q{"#{f}"}
433
+ elsif d = attribute.default
434
+ %Q{__xmlattr[#{constname}] || "#{d}"}
435
+ else
436
+ "__xmlattr[#{constname}]"
437
+ end
438
+ end
439
+
384
440
  def create_arraydef(mpath, qname, typedef)
385
441
  classname = mapped_class_basename(qname, mpath)
386
442
  c = ClassDef.new(classname, '::Array')
@@ -62,6 +62,11 @@ module MappingRegistryCreatorSupport
62
62
  parentmodule = var[:class]
63
63
  parsed_element =
64
64
  parse_elements(typedef.elements, qname.namespace, parentmodule, opt)
65
+ if typedef.content && (WSDL::XMLSchema::Group === typedef.content) && typedef.elements.empty?
66
+ g_parsed_element =
67
+ parse_elements(typedef.content.refelement.elements, qname.namespace, parentmodule, opt)
68
+ parsed_element = (g_parsed_element + parsed_element)
69
+ end
65
70
  if typedef.choice?
66
71
  parsed_element.unshift(:choice)
67
72
  end
@@ -9,13 +9,14 @@
9
9
 
10
10
  require 'wsdl/info'
11
11
  require 'wsdl/xmlSchema/ref'
12
+ require 'wsdl/xmlSchema/complexType'
12
13
 
13
14
 
14
15
  module WSDL
15
16
  module XMLSchema
16
17
 
17
18
 
18
- class Group < Info
19
+ class Group < ComplexType
19
20
  include Ref
20
21
 
21
22
  attr_writer :name # required
@@ -89,8 +90,9 @@ class Group < Info
89
90
  end
90
91
  end
91
92
 
92
- private
93
-
93
+ # No longer private: classDefCreator.rb and mappingRegistryCreatorSupport.rb
94
+ # both need to resolve a group ref's actual definition when generating code
95
+ # for a complexType whose sole content is a <xsd:group ref="..."/>.
94
96
  def refelement
95
97
  @refelement ||= (@ref ? root.collect_modelgroups[@ref] : nil)
96
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soap4r-ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurence A. Lee, Hiroshi NAKAMURA