xqsr3-xml 0.1.1 → 0.1.3

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.
@@ -1,18 +1,18 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/xml/_utilities/navigation.rb
3
+ # File: lib/xqsr3/xml/_utilities/navigation.rb
4
4
  #
5
- # Purpose: Definition of the ::Xqsr3::XML::Utilities::Navigation
6
- # module
5
+ # Purpose: Definition of the ::Xqsr3::XML::Utilities::Navigation module
7
6
  #
8
- # Created: 7th August 2018
9
- # Updated: 7th August 2018
7
+ # Created: 7th August 2018
8
+ # Updated: 19th August 2026
10
9
  #
11
- # Home: http://github.com/synesissoftware/xqsr3
10
+ # Home: http://github.com/synesissoftware/xqsr3
12
11
  #
13
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
14
13
  #
15
- # Copyright (c) 2018, Matthew Wilson and Synesis Software
14
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
15
+ # Copyright (c) 2018-2019, Matthew Wilson and Synesis Software
16
16
  # All rights reserved.
17
17
  #
18
18
  # Redistribution and use in source and binary forms, with or without
@@ -61,42 +61,42 @@ module Utilities
61
61
 
62
62
  module Navigation
63
63
 
64
- module Internal_Compare_
64
+ module Internal_Compare_
65
65
 
66
- extend ::Xqsr3::Quality::ParameterChecking
66
+ extend ::Xqsr3::Quality::ParameterChecking
67
67
 
68
- def self.get_descendants node
68
+ def self.get_descendants node
69
69
 
70
- descendants = []
70
+ descendants = []
71
71
 
72
- node.children.each do |child|
72
+ node.children.each do |child|
73
73
 
74
- descendants << child
74
+ descendants << child
75
75
 
76
- descendants += self.get_descendants child
77
- end
76
+ descendants += self.get_descendants child
77
+ end
78
78
 
79
- descendants
80
- end
81
- end # module Internal_Compare_
79
+ descendants
80
+ end
81
+ end # module Internal_Compare_
82
82
 
83
- def self.included receiver
83
+ def self.included receiver
84
84
 
85
- def receiver.get_descendants node
85
+ def receiver.get_descendants node
86
86
 
87
- Internal_Compare_.get_descendants node
88
- end
89
- end
87
+ Internal_Compare_.get_descendants node
88
+ end
89
+ end
90
90
 
91
- def self.get_descendants node
91
+ def self.get_descendants node
92
92
 
93
- Internal_Compare_.get_descendants node
94
- end
93
+ Internal_Compare_.get_descendants node
94
+ end
95
95
 
96
- def get_descendants
96
+ def get_descendants
97
97
 
98
- Internal_Compare_.get_descendants self
99
- end
98
+ Internal_Compare_.get_descendants self
99
+ end
100
100
  end # module Navigation
101
101
 
102
102
  end # module Utilities
@@ -1,16 +1,17 @@
1
-
1
+ # frozen_string_literal: true
2
2
  # ######################################################################## #
3
- # File: lib/xqsr3/xml/version.rb
3
+ # File: lib/xqsr3/xml/version.rb
4
4
  #
5
- # Purpose: Version for xqsr3-xml library
5
+ # Purpose: Version for xqsr3-xml library
6
6
  #
7
- # Created: 1st March 2019
8
- # Updated: 11th April 2019
7
+ # Created: 1st March 2019
8
+ # Updated: 19th August 2026
9
9
  #
10
- # Home: http://github.com/synesissoftware/xqsr3
10
+ # Home: https://github.com/synesissoftware/xqsr3-xml
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -50,22 +51,20 @@
50
51
  module Xqsr3
51
52
  module XML
52
53
 
53
- # Current version of the Xqsr3 library
54
- VERSION = '0.1.1'
54
+ # Current version of the xqsr3-xml library
55
+ VERSION = '0.1.3'
55
56
 
56
- private
57
- VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
58
- public
59
- # Major version of the Xqsr3 library
60
- VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
61
- # Minor version of the Xqsr3 library
62
- VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
63
- # Revision version of the Xqsr3 library
64
- VERSION_REVISION = VERSION_PARTS_[2] # :nodoc:
57
+ private
58
+ VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
59
+ public
60
+ # Major version of the xqsr3-xml library
61
+ VERSION_MAJOR = VERSION_PARTS_[0] # :nodoc:
62
+ # Minor version of the xqsr3-xml library
63
+ VERSION_MINOR = VERSION_PARTS_[1] # :nodoc:
64
+ # Revision version of the xqsr3-xml library
65
+ VERSION_REVISION = VERSION_PARTS_[2] # :nodoc:
65
66
 
66
67
  end # module XML
67
68
  end # module Xqsr3
68
69
 
69
70
  # ############################## end of file ############################# #
70
-
71
-
@@ -8,29 +8,29 @@ require 'test/unit'
8
8
 
9
9
  class Test_version < Test::Unit::TestCase
10
10
 
11
- def test_has_VERSION
11
+ def test_has_VERSION
12
12
 
13
- assert defined? Xqsr3::XML::VERSION
14
- end
13
+ assert defined? Xqsr3::XML::VERSION
14
+ end
15
15
 
16
- def test_has_VERSION_MAJOR
16
+ def test_has_VERSION_MAJOR
17
17
 
18
- assert defined? Xqsr3::XML::VERSION_MAJOR
19
- end
18
+ assert defined? Xqsr3::XML::VERSION_MAJOR
19
+ end
20
20
 
21
- def test_has_VERSION_MINOR
21
+ def test_has_VERSION_MINOR
22
22
 
23
- assert defined? Xqsr3::XML::VERSION_MINOR
24
- end
23
+ assert defined? Xqsr3::XML::VERSION_MINOR
24
+ end
25
25
 
26
- def test_has_VERSION_REVISION
26
+ def test_has_VERSION_REVISION
27
27
 
28
- assert defined? Xqsr3::XML::VERSION_REVISION
29
- end
28
+ assert defined? Xqsr3::XML::VERSION_REVISION
29
+ end
30
30
 
31
- def test_VERSION_has_consistent_format
31
+ def test_VERSION_has_consistent_format
32
32
 
33
- assert_equal Xqsr3::XML::VERSION, "#{Xqsr3::XML::VERSION_MAJOR}.#{Xqsr3::XML::VERSION_MINOR}.#{Xqsr3::XML::VERSION_REVISION}"
34
- end
33
+ assert_equal Xqsr3::XML::VERSION, "#{Xqsr3::XML::VERSION_MAJOR}.#{Xqsr3::XML::VERSION_MINOR}.#{Xqsr3::XML::VERSION_REVISION}"
34
+ end
35
35
  end
36
36
 
@@ -9,104 +9,104 @@ require 'test/unit'
9
9
 
10
10
  class Test_Xqsr3_XML_Utilities_Compare < Test::Unit::TestCase
11
11
 
12
- include ::Xqsr3::XML::Utilities::Compare
12
+ include ::Xqsr3::XML::Utilities::Compare
13
13
 
14
- def test_compare_nil
14
+ def test_compare_nil
15
15
 
16
- assert xml_compare(nil, nil).same?
16
+ assert xml_compare(nil, nil).same?
17
17
 
18
- assert_false xml_compare('', nil).same?
19
- assert_false xml_compare(nil, '').same?
18
+ assert_false xml_compare('', nil).same?
19
+ assert_false xml_compare(nil, '').same?
20
20
 
21
- assert xml_compare('', nil, equate_nil_and_empty: true).same?
22
- assert xml_compare(nil, '', equate_nil_and_empty: true).same?
23
- end
21
+ assert xml_compare('', nil, equate_nil_and_empty: true).same?
22
+ assert xml_compare(nil, '', equate_nil_and_empty: true).same?
23
+ end
24
24
 
25
- def test_compare_empty
25
+ def test_compare_empty
26
26
 
27
- assert xml_compare('', '').same?
27
+ assert xml_compare('', '').same?
28
28
 
29
- assert_false xml_compare('<abc/>', '').same?
30
- assert_false xml_compare('', '<abc/>').same?
31
- end
29
+ assert_false xml_compare('<abc/>', '').same?
30
+ assert_false xml_compare('', '<abc/>').same?
31
+ end
32
32
 
33
- def test_compare_one_level_1
33
+ def test_compare_one_level_1
34
34
 
35
- assert xml_compare('<abc/>', '<abc/>').same?
36
- assert xml_compare('<abc/>', '<abc></abc>').same?
37
- assert_false xml_compare('<abc/>', '<def/>').same?
38
- end
35
+ assert xml_compare('<abc/>', '<abc/>').same?
36
+ assert xml_compare('<abc/>', '<abc></abc>').same?
37
+ assert_false xml_compare('<abc/>', '<def/>').same?
38
+ end
39
39
 
40
- def test_compare_two_level_1
40
+ def test_compare_two_level_1
41
41
 
42
- assert xml_compare('<parent><child1></child1></parent>', '<parent><child1></child1></parent>').same?
43
- assert xml_compare('<parent><child1/></parent>', '<parent><child1></child1></parent>').same?
42
+ assert xml_compare('<parent><child1></child1></parent>', '<parent><child1></child1></parent>').same?
43
+ assert xml_compare('<parent><child1/></parent>', '<parent><child1></child1></parent>').same?
44
44
 
45
- r = xml_compare('<parent><child1/></parent>', '<parent><child2/></parent>')
45
+ r = xml_compare('<parent><child1/></parent>', '<parent><child2/></parent>')
46
46
 
47
- assert_false r.same?
48
- end
47
+ assert_false r.same?
48
+ end
49
49
 
50
- def test_compare_attributes_1
50
+ def test_compare_attributes_1
51
51
 
52
- lhs = <<END_OF_lhs
52
+ lhs = <<END_OF_lhs
53
53
  <node name="John Smith" age="21" />
54
54
  END_OF_lhs
55
55
 
56
- rhs_same = <<END_OF_lhs
56
+ rhs_same = <<END_OF_lhs
57
57
  <node age="21" name="John Smith" />
58
58
  END_OF_lhs
59
59
 
60
- rhs_diff = <<END_OF_lhs
60
+ rhs_diff = <<END_OF_lhs
61
61
  <node name="John Smith" age="22" />
62
62
  END_OF_lhs
63
63
 
64
- r = xml_compare lhs, rhs_same, ignore_attribute_order: false
64
+ r = xml_compare lhs, rhs_same, ignore_attribute_order: false
65
65
 
66
- assert r.different?, r.details
67
- assert_equal :different_attribute_order, r.reason
66
+ assert r.different?, r.details
67
+ assert_equal :different_attribute_order, r.reason
68
68
 
69
- r = xml_compare lhs, rhs_same, ignore_attribute_order: true
69
+ r = xml_compare lhs, rhs_same, ignore_attribute_order: true
70
70
 
71
- assert r.same?
71
+ assert r.same?
72
72
 
73
- r = xml_compare lhs, rhs_same, element_order: false
73
+ r = xml_compare lhs, rhs_same, element_order: false
74
74
 
75
- assert r.same?
75
+ assert r.same?
76
76
 
77
- r = xml_compare lhs, rhs_diff
77
+ r = xml_compare lhs, rhs_diff
78
78
 
79
- assert r.different?
80
- assert_equal :different_attributes, r.reason
81
- end
79
+ assert r.different?
80
+ assert_equal :different_attributes, r.reason
81
+ end
82
82
 
83
- def test_compare_two_level_2
83
+ def test_compare_two_level_2
84
84
 
85
- lhs = <<END_OF_lhs
85
+ lhs = <<END_OF_lhs
86
86
  <parent>
87
87
  <child1/>
88
88
  </parent>
89
89
  END_OF_lhs
90
- rhs = <<END_OF_rhs
90
+ rhs = <<END_OF_rhs
91
91
  <parent>
92
92
  <child1>
93
93
  </child1>
94
94
  </parent>
95
95
  END_OF_rhs
96
96
 
97
- r = xml_compare lhs, rhs, normalize_whitespace: false
97
+ r = xml_compare lhs, rhs, normalize_whitespace: false
98
98
 
99
- assert r.different?, "#{r.details}"
100
- assert_equal :different_node_contents, r.reason
99
+ assert r.different?, "#{r.details}"
100
+ assert_equal :different_node_contents, r.reason
101
101
 
102
- r = xml_compare(lhs, rhs, normalize_whitespace: true)
102
+ r = xml_compare(lhs, rhs, normalize_whitespace: true)
103
103
 
104
- assert r.same?, "#{r.details}"
105
- end
104
+ assert r.same?, "#{r.details}"
105
+ end
106
106
 
107
- def test_compare_two_level_3
107
+ def test_compare_two_level_3
108
108
 
109
- lhs = <<END_OF_lhs
109
+ lhs = <<END_OF_lhs
110
110
  <parent>
111
111
  <child1/>
112
112
  <child2>
@@ -114,7 +114,7 @@ END_OF_rhs
114
114
  </child2>
115
115
  </parent>
116
116
  END_OF_lhs
117
- rhs = <<END_OF_rhs
117
+ rhs = <<END_OF_rhs
118
118
  <parent>
119
119
  <child2><grandchild2a/></child2>
120
120
  <child1>
@@ -122,14 +122,14 @@ END_OF_lhs
122
122
  </parent>
123
123
  END_OF_rhs
124
124
 
125
- r = xml_compare lhs, rhs, normalize_whitespace: true
125
+ r = xml_compare lhs, rhs, normalize_whitespace: true
126
126
 
127
- assert r.same?, "#{r.details}"
128
- end
127
+ assert r.same?, "#{r.details}"
128
+ end
129
129
 
130
- def test_different_declarations_and_dont_ignore
130
+ def test_different_declarations_and_dont_ignore
131
131
 
132
- lhs_str = <<END_OF_lhs_doc
132
+ lhs_str = <<END_OF_lhs_doc
133
133
  <?xml version="1.0"?>
134
134
  <outer>
135
135
  <mid>
@@ -138,27 +138,27 @@ END_OF_rhs
138
138
  </outer>
139
139
  END_OF_lhs_doc
140
140
 
141
- rhs_str = <<END_OF_rhs_doc
141
+ rhs_str = <<END_OF_rhs_doc
142
142
  <?xml version="1.0"?>
143
143
  <mid>
144
144
  <inner>some text</inner>
145
145
  </mid>
146
146
  END_OF_rhs_doc
147
147
 
148
- lhs_doc = Nokogiri::XML lhs_str
149
- rhs_doc = Nokogiri::XML rhs_str
148
+ lhs_doc = Nokogiri::XML lhs_str
149
+ rhs_doc = Nokogiri::XML rhs_str
150
150
 
151
- expected = rhs_doc
152
- actual = lhs_doc.at_xpath('/outer/mid')
151
+ expected = rhs_doc
152
+ actual = lhs_doc.at_xpath('/outer/mid')
153
153
 
154
- r = xml_compare expected, actual, normalise_whitespace: true, ignore_xml_declarations: false
154
+ r = xml_compare expected, actual, normalise_whitespace: true, ignore_xml_declarations: false
155
155
 
156
- assert !r.same?
157
- end
156
+ assert !r.same?
157
+ end
158
158
 
159
- def test_different_declarations_and_do_ignore
159
+ def test_different_declarations_and_do_ignore
160
160
 
161
- lhs_str = <<END_OF_lhs_doc
161
+ lhs_str = <<END_OF_lhs_doc
162
162
  <?xml version="1.0"?>
163
163
  <outer>
164
164
  <mid>
@@ -167,27 +167,27 @@ END_OF_rhs_doc
167
167
  </outer>
168
168
  END_OF_lhs_doc
169
169
 
170
- rhs_str = <<END_OF_rhs_doc
170
+ rhs_str = <<END_OF_rhs_doc
171
171
  <?xml version="1.0"?>
172
172
  <mid>
173
173
  <inner>some text</inner>
174
174
  </mid>
175
175
  END_OF_rhs_doc
176
176
 
177
- lhs_doc = Nokogiri::XML lhs_str
178
- rhs_doc = Nokogiri::XML rhs_str
177
+ lhs_doc = Nokogiri::XML lhs_str
178
+ rhs_doc = Nokogiri::XML rhs_str
179
179
 
180
- expected = rhs_doc
181
- actual = lhs_doc.at_xpath('/outer/mid')
180
+ expected = rhs_doc
181
+ actual = lhs_doc.at_xpath('/outer/mid')
182
182
 
183
- r = xml_compare expected, actual, normalise_whitespace: true, ignore_xml_declarations: true
183
+ r = xml_compare expected, actual, normalise_whitespace: true, ignore_xml_declarations: true
184
184
 
185
- assert r.same?, "#{r.details}"
186
- end
185
+ assert r.same?, "#{r.details}"
186
+ end
187
187
 
188
- def test_different_node_contents_by_child_node_order
188
+ def test_different_node_contents_by_child_node_order
189
189
 
190
- lhs_str = <<END_OF_lhs_doc
190
+ lhs_str = <<END_OF_lhs_doc
191
191
  <?xml version="1.0"?>
192
192
  <outer>
193
193
  <mid_1>
@@ -199,7 +199,7 @@ END_OF_rhs_doc
199
199
  </outer>
200
200
  END_OF_lhs_doc
201
201
 
202
- rhs_str = <<END_OF_rhs_doc
202
+ rhs_str = <<END_OF_rhs_doc
203
203
  <?xml version="1.0"?>
204
204
  <outer>
205
205
  <mid_2>
@@ -211,25 +211,25 @@ END_OF_lhs_doc
211
211
  </outer>
212
212
  END_OF_rhs_doc
213
213
 
214
- lhs_doc = Nokogiri::XML lhs_str
215
- rhs_doc = Nokogiri::XML rhs_str
214
+ lhs_doc = Nokogiri::XML lhs_str
215
+ rhs_doc = Nokogiri::XML rhs_str
216
216
 
217
- expected = rhs_doc
218
- actual = lhs_doc
217
+ expected = rhs_doc
218
+ actual = lhs_doc
219
219
 
220
- r = xml_compare expected, actual, ignore_child_node_order: true, normalise_whitespace: true, ignore_xml_declarations: true
220
+ r = xml_compare expected, actual, ignore_child_node_order: true, normalise_whitespace: true, ignore_xml_declarations: true
221
221
 
222
- assert r.same?, "#{r.details}"
223
- end
222
+ assert r.same?, "#{r.details}"
223
+ end
224
224
 
225
- def test_different_node_contents_by_child_node_order_and_whitespace
225
+ def test_different_node_contents_by_child_node_order_and_whitespace
226
226
 
227
- lhs_str = <<END_OF_lhs_doc
227
+ lhs_str = <<END_OF_lhs_doc
228
228
  <?xml version="1.0"?>
229
229
  <outer><mid_1><inner>some text</inner></mid_1><mid_2><inner>some more text</inner></mid_2></outer>
230
230
  END_OF_lhs_doc
231
231
 
232
- rhs_str = <<END_OF_rhs_doc
232
+ rhs_str = <<END_OF_rhs_doc
233
233
  <?xml version="1.0"?>
234
234
  <outer>
235
235
  <mid_2>
@@ -241,16 +241,16 @@ END_OF_lhs_doc
241
241
  </outer>
242
242
  END_OF_rhs_doc
243
243
 
244
- lhs_doc = Nokogiri::XML lhs_str
245
- rhs_doc = Nokogiri::XML rhs_str
244
+ lhs_doc = Nokogiri::XML lhs_str
245
+ rhs_doc = Nokogiri::XML rhs_str
246
246
 
247
- expected = rhs_doc
248
- actual = lhs_doc
247
+ expected = rhs_doc
248
+ actual = lhs_doc
249
249
 
250
- r = xml_compare expected, actual, ignore_child_node_order: true, normalise_whitespace: true, ignore_xml_declarations: true
250
+ r = xml_compare expected, actual, ignore_child_node_order: true, normalise_whitespace: true, ignore_xml_declarations: true
251
251
 
252
- assert r.same?, "#{r.details}"
253
- end
252
+ assert r.same?, "#{r.details}"
253
+ end
254
254
  end
255
255
 
256
256
 
@@ -11,11 +11,11 @@ require 'nokogiri'
11
11
 
12
12
  class Test_Xqsr3_XML_Utilities_Navigation < Test::Unit::TestCase
13
13
 
14
- include ::Xqsr3::XML::Utilities::Navigation
14
+ include ::Xqsr3::XML::Utilities::Navigation
15
15
 
16
- def test_get_descendants_1
16
+ def test_get_descendants_1
17
17
 
18
- xml_s = <<END_OF_rhs_doc
18
+ xml_s = <<END_OF_rhs_doc
19
19
  <?xml version="1.0"?>
20
20
  <document>
21
21
  <outer>
@@ -29,27 +29,27 @@ class Test_Xqsr3_XML_Utilities_Navigation < Test::Unit::TestCase
29
29
  </document>
30
30
  END_OF_rhs_doc
31
31
 
32
- xml = ::Nokogiri.XML(xml_s)
33
- doc = xml.children.first
32
+ xml = ::Nokogiri.XML(xml_s)
33
+ doc = xml.children.first
34
34
 
35
- descs = self.class.get_descendants xml.children.first
35
+ descs = self.class.get_descendants xml.children.first
36
36
 
37
- assert_not_nil descs
38
- assert_kind_of ::Array, descs
37
+ assert_not_nil descs
38
+ assert_kind_of ::Array, descs
39
39
 
40
- assert_operator 7, :<=, descs.size
41
- %w{ outer mid_1 mid_2 }.each do |name|
40
+ assert_operator 7, :<=, descs.size
41
+ %w{ outer mid_1 mid_2 }.each do |name|
42
42
 
43
- assert(descs.find { |el| name == el.name }, "did not find an element named '#{name}' in the collection #{descs}")
44
- end
43
+ assert(descs.find { |el| name == el.name }, "did not find an element named '#{name}' in the collection #{descs}")
44
+ end
45
45
 
46
- texts = descs.select { |el| el.text? }
46
+ texts = descs.select { |el| el.text? }
47
47
 
48
- [ 'some text', 'some more text' ].each do |text|
48
+ [ 'some text', 'some more text' ].each do |text|
49
49
 
50
- assert(texts.find { |el| text == el.text }, "did not find an element with the text '#{text}' in the collection #{texts}")
51
- end
52
- end
50
+ assert(texts.find { |el| text == el.text }, "did not find an element with the text '#{text}' in the collection #{texts}")
51
+ end
52
+ end
53
53
  end
54
54
 
55
55