compare-xml 0.65 → 0.66
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 +5 -5
- data/.rubocop.yml +3 -0
- data/README.md +42 -0
- data/compare-xml.gemspec +1 -1
- data/lib/compare-xml.rb +5 -0
- data/lib/compare-xml/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eb6c3fb3e704a49642e05b7c2ff26442ad63a77aa22c4a2dc461ffce22c5dc59
|
4
|
+
data.tar.gz: 8fa4604c0f7216f077fa48807a68c4b222fefca2dd6beedfc0d745cb3f5074ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be5a2a949660aff92a2d4fea1fa6820a960ceb7b177479ee6a7b3464cc0f9b12ce7a81f08fe4567243a658987ab48c34362cf09b9a2f11767724d669cc0f142
|
7
|
+
data.tar.gz: 7d17c1fd43511146021eadc83037cf27d7c259fad86658ecba24f6c021ec4095b984d1e5cb9becaa1cd2e78b4338db95f0b437e00ab60aed0f54f6733087dde9
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -78,6 +78,9 @@ CompareXML.equivalent?(doc1, doc2, {collapse_whitespace: false, verbose: true, .
|
|
78
78
|
- `ignore_attrs: [css_selector1, css_selector1, ...]` default: **`[]`** [show examples ⇨](#ignore_attrs)
|
79
79
|
- when provided, ignores specific *attributes* using [CSS selectors](http://www.w3schools.com/cssref/css_selectors.asp)
|
80
80
|
|
81
|
+
- `ignore_attrs_by_name: [string1, string2, ...]` default: **`[]`** [show examples ⇨](#ignore_attrs_by_name)
|
82
|
+
- when provided, ignores specific *attributes* using [String]
|
83
|
+
|
81
84
|
- `ignore_comments: {true|false}` default: **`true`** [show examples ⇨](#ignore_comments)
|
82
85
|
- when `true`, ignores comments, such as `<!-- comment -->`
|
83
86
|
|
@@ -90,6 +93,12 @@ CompareXML.equivalent?(doc1, doc2, {collapse_whitespace: false, verbose: true, .
|
|
90
93
|
- `verbose: {true|false}` default: **`false`** [show examples ⇨](#verbose)
|
91
94
|
- when `true`, instead of a boolean, `CompareXML.equivalent?` returns an array of discrepancies.
|
92
95
|
|
96
|
+
- `ignore_children {true|false}` default **`false`** [show examples ⇨](#ignore_children)
|
97
|
+
- when `true`, the subnodes of a node in the xml are ignored
|
98
|
+
|
99
|
+
- `force_children {true|false}` default **`false`** [show examples ⇨](#force_children)
|
100
|
+
- when `true`, the subnodes of a node are checked independently of the status of the parent node
|
101
|
+
|
93
102
|
|
94
103
|
## Options in Depth
|
95
104
|
|
@@ -185,6 +194,18 @@ CompareXML.equivalent?(doc1, doc2, {collapse_whitespace: false, verbose: true, .
|
|
185
194
|
<a href="http://google.ca" class="primary button">Link</a>
|
186
195
|
<a href="https://google.com" class="primary button rounded">Link</a>
|
187
196
|
|
197
|
+
----------
|
198
|
+
|
199
|
+
- <a id="ignore_attrs_by_name"></a>`ignore_attrs_by_name: [string1, string2, ...]` default: **`false`**
|
200
|
+
|
201
|
+
When provided, ignores all **attributes** which name is specified in the string array.
|
202
|
+
|
203
|
+
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_attrs_by_name: ['target'])`
|
204
|
+
|
205
|
+
**Example:** With `ignore_attrs_by_name: ['target', 'rel']` the following HTML strings are considered equal:
|
206
|
+
|
207
|
+
<a href="/admin" class="button" target="_blank">Link</a>
|
208
|
+
<a href="/admin" class="button" target="_self" rel="nofollow">Link</a>
|
188
209
|
|
189
210
|
----------
|
190
211
|
|
@@ -305,7 +326,28 @@ CompareXML.equivalent?(doc1, doc2, {collapse_whitespace: false, verbose: true, .
|
|
305
326
|
diff1: [Nokogiri::XML::Node|String] left difference
|
306
327
|
diff2: [Nokogiri::XML::Node|String] right difference
|
307
328
|
|
329
|
+
----------
|
308
330
|
|
331
|
+
- <a id="ignore_children"></a>`ignore_children: {true|false}` default: **`false`**
|
332
|
+
|
333
|
+
When provided, ignores all **subnodes** of any node.
|
334
|
+
|
335
|
+
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_children: true})`
|
336
|
+
|
337
|
+
**Example:** With `ignore_children: true` the following HTML strings are considered equal:
|
338
|
+
|
339
|
+
<body><a href="/admin" class="icon" target="_blank">Link 1</a></body>
|
340
|
+
<body><a href="/index" class="button" target="_self" rel="nofollow">Link 2</a></body>
|
341
|
+
|
342
|
+
----------
|
343
|
+
|
344
|
+
- <a id="force_children"></a>`force_children: {true|false}` default: **`false`**
|
345
|
+
|
346
|
+
When provided, compares all **subnodes** of any node.
|
347
|
+
|
348
|
+
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_children: true})`
|
349
|
+
|
350
|
+
----------
|
309
351
|
|
310
352
|
## Contributing
|
311
353
|
|
data/compare-xml.gemspec
CHANGED
data/lib/compare-xml.rb
CHANGED
@@ -16,6 +16,10 @@ module CompareXML
|
|
16
16
|
# when false, children of elements are not compared if the root is different
|
17
17
|
force_children: false,
|
18
18
|
|
19
|
+
# when true, children of elements are never compared
|
20
|
+
# when false, children of elements are compared if root is different or see force_children
|
21
|
+
ignore_children: false,
|
22
|
+
|
19
23
|
# contains an array of user specified strings that is used to ignore any attributes
|
20
24
|
# whose content contains a string from this array (e.g. "good automobile" contains "mobile")
|
21
25
|
ignore_attr_content: [],
|
@@ -191,6 +195,7 @@ module CompareXML
|
|
191
195
|
#
|
192
196
|
def compareChildren(n1_set, n2_set, opts, differences, diffchildren = false, status = EQUIVALENT)
|
193
197
|
i = 0; j = 0
|
198
|
+
return if opts[:ignore_children]
|
194
199
|
while i < n1_set.length || j < n2_set.length
|
195
200
|
if !n1_set[i].nil? && nodeExcluded?(n1_set[i], opts)
|
196
201
|
i += 1 # increment counter if left node is excluded
|
data/lib/compare-xml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compare-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.66'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vadim Kononov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.7.3
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: A customizable tool that compares two instances of Nokogiri::XML::Node for
|