wsdl_validator 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 4fce125f29936513df4aef2ecc504d0386bedb78
4
- data.tar.gz: 8b482814d8c1f22c2ba4169619ac3c41aa4556db
3
+ metadata.gz: 48fff12b40c9b38144839f5b2f76467f8c199731
4
+ data.tar.gz: 4fdba0e3f8bdde25a218e47e8ea07b7a91ad66ea
5
5
  SHA512:
6
- metadata.gz: 3b5324da1ab553af1853eaa330632f0a906010688010082c17985a33e2e627d13c97abe26970a8ec0fecaf5f1776098acf3d171fe16f2bbf06e8b386d2c0e302
7
- data.tar.gz: ccafaf8061ee57ed137094e9e625e6e45a2985534c761b7196aebdc11db17fd91f69d318dc36a3176eb6537680311431784c3ec50865ce3502d7f511d09cfbba
6
+ metadata.gz: '083fc37f4fd97a7cb23ac4bb0f01390f5dd4e3e4696fded664789f6c1718aa0200d57cf1a207e098a184fcbc3091997ae01eafb592a05020eaf788e20d51034c'
7
+ data.tar.gz: 8ba071a17644cbf6f63db23bf37b9c832d4898108783d89278849a538ce27925e1367c9b0403de6e2cc4862541242f0d40d877b77c9d5f3ae90f5769b19070c5
@@ -1,3 +1,3 @@
1
1
  class WsdlValidator
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -1,13 +1,18 @@
1
+ # Helps to validate xml against schemas contained in a WSDL
1
2
  class WsdlValidator
3
+ # @param [String] wsdl_url URL to where WSDL is stored
2
4
  def initialize(wsdl_url)
3
5
  @doc = Wasabi.document wsdl_url
6
+ @schemas = @doc.parser.schemas.collect(&:to_s).join
4
7
  end
5
8
 
6
- def valid?(xml_string)
7
- schemas = @doc.parser.schemas.collect(&:to_s).join
8
- xml = Nokogiri::XML(xml_string)
9
- xsd = Nokogiri::XML::Schema(schemas)
10
- validator = xsd.validate(xml)
9
+ # @param [String, Nokogiri::XML::NodeSet] xml
10
+ # @return [Boolean] Whether xml is valid according to WSDL of class
11
+ def valid?(xml)
12
+ raise "Incorrect type #{xml.class}" unless [String, Nokogiri::XML::Document, Nokogiri::XML::NodeSet].include? xml.class
13
+ xml_under_test = Nokogiri::XML(xml.to_s)
14
+ xsd = Nokogiri::XML::Schema(@schemas)
15
+ validator = xsd.validate(xml_under_test)
11
16
  validator.each { |error| puts error.message }
12
17
  return false unless validator.empty?
13
18
  true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wsdl_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt