Module: DiffXML
- Defined in:
- lib/diffxml.rb,
lib/diffXML/utils.rb
Defined Under Namespace
Classes: Utils
Class Method Summary collapse
- .compareToPath(path, doc1, doc2) ⇒ Object
- .compareXML(doc1, doc2, ignores = [], css = false) ⇒ Object
- .getXPathArray ⇒ Object
Class Method Details
.compareToPath(path, doc1, doc2) ⇒ Object
29 30 31 |
# File 'lib/diffxml.rb', line 29 def self.compareToPath(path, doc1, doc2) doc2.search(path, @namespaces).to_s == doc1.search(path, @namespaces).to_s end |
.compareXML(doc1, doc2, ignores = [], css = false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/diffxml.rb', line 6 def self.compareXML(doc1, doc2, ignores = [], css = false) raise "Expected true or false for css parameter, got #{css}" unless css.is_a? TrueClass or css.is_a? FalseClass @namespaces = doc1.collect_namespaces cssClass = Nokogiri::CSS if doc1.class == Nokogiri::XML::Document DiffXML::Utils.collectXPaths(doc1.root, @xpathArray) else DiffXML::Utils.collectXPaths(doc1, @xpathArray) end if !ignores.empty? ignores.each do |ignore| if css @xpathArray.delete(cssClass.xpath_for(ignore)[0]) else @xpathArray.delete(ignore) end end end @xpathArray.delete_if do |element| compareToPath(element, doc1, doc2) end end |
.getXPathArray ⇒ Object
33 34 35 |
# File 'lib/diffxml.rb', line 33 def self.getXPathArray @xpathArray end |