libxml-ruby 4.1.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +14 -0
  3. data/ext/libxml/ruby_libxml.h +43 -44
  4. data/ext/libxml/ruby_xml.c +0 -343
  5. data/ext/libxml/ruby_xml.h +9 -10
  6. data/ext/libxml/ruby_xml_attributes.h +2 -0
  7. data/ext/libxml/ruby_xml_document.c +6 -6
  8. data/ext/libxml/ruby_xml_document.h +11 -11
  9. data/ext/libxml/ruby_xml_dtd.c +3 -3
  10. data/ext/libxml/ruby_xml_encoding.h +20 -18
  11. data/ext/libxml/ruby_xml_error.c +9 -6
  12. data/ext/libxml/ruby_xml_error.h +2 -2
  13. data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
  14. data/ext/libxml/ruby_xml_namespace.c +0 -3
  15. data/ext/libxml/ruby_xml_node.c +1394 -1398
  16. data/ext/libxml/ruby_xml_parser.h +1 -1
  17. data/ext/libxml/ruby_xml_parser_context.c +47 -39
  18. data/ext/libxml/ruby_xml_parser_options.c +9 -1
  19. data/ext/libxml/ruby_xml_parser_options.h +1 -1
  20. data/ext/libxml/ruby_xml_reader.c +15 -16
  21. data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
  22. data/ext/libxml/ruby_xml_sax_parser.c +1 -9
  23. data/ext/libxml/ruby_xml_schema.c +4 -4
  24. data/ext/libxml/ruby_xml_version.h +5 -5
  25. data/ext/libxml/ruby_xml_writer.c +8 -8
  26. data/ext/libxml/ruby_xml_xpath.c +1 -1
  27. data/ext/libxml/ruby_xml_xpath_context.c +2 -2
  28. data/ext/libxml/ruby_xml_xpath_expression.c +1 -1
  29. data/lib/libxml/document.rb +13 -13
  30. data/lib/libxml/html_parser.rb +23 -23
  31. data/lib/libxml/parser.rb +26 -24
  32. data/test/test.rb +5 -0
  33. data/test/test_document_write.rb +1 -4
  34. data/test/test_dtd.rb +1 -4
  35. data/test/test_encoding.rb +1 -4
  36. data/test/test_helper.rb +9 -2
  37. data/test/test_html_parser.rb +162 -162
  38. data/test/test_namespace.rb +1 -3
  39. data/test/test_node.rb +1 -3
  40. data/test/test_node_write.rb +1 -4
  41. data/test/test_parser.rb +26 -17
  42. data/test/test_reader.rb +4 -4
  43. data/test/test_sax_parser.rb +1 -1
  44. data/test/test_xml.rb +0 -99
  45. metadata +4 -3
data/test/test_parser.rb CHANGED
@@ -27,7 +27,7 @@ class TestParser < Minitest::Test
27
27
  LibXML::XML::Parser.document(nil)
28
28
  end
29
29
 
30
- assert_equal("Must pass an LibXML::XML::Document object", error.to_s)
30
+ assert_equal("Must pass an LibXML::XML::Document object", error.message)
31
31
  end
32
32
 
33
33
  def test_file
@@ -44,7 +44,7 @@ class TestParser < Minitest::Test
44
44
  LibXML::XML::Parser.file('i_dont_exist.xml')
45
45
  end
46
46
 
47
- assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.to_s)
47
+ assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.message)
48
48
  end
49
49
 
50
50
  def test_nil_file
@@ -52,7 +52,7 @@ class TestParser < Minitest::Test
52
52
  LibXML::XML::Parser.file(nil)
53
53
  end
54
54
 
55
- assert_match(/nil into String/, error.to_s)
55
+ assert_match(/nil into String/, error.message)
56
56
  end
57
57
 
58
58
  def test_file_encoding
@@ -63,7 +63,11 @@ class TestParser < Minitest::Test
63
63
  parser.parse
64
64
  end
65
65
 
66
- assert(error.to_s.match(/Fatal error: Extra content at the end of the document/))
66
+ if windows?
67
+ assert_match(/Fatal error: Opening and ending tag mismatch/, error.message)
68
+ else
69
+ assert_match(/Fatal error: Extra content at the end of the document/, error.message)
70
+ end
67
71
 
68
72
  parser = LibXML::XML::Parser.file(file, :encoding => LibXML::XML::Encoding::UTF_8)
69
73
  doc = parser.parse
@@ -108,7 +112,7 @@ class TestParser < Minitest::Test
108
112
  LibXML::XML::Parser.io(nil)
109
113
  end
110
114
 
111
- assert_equal("Must pass in an IO object", error.to_s)
115
+ assert_equal("Must pass in an IO object", error.message)
112
116
  end
113
117
 
114
118
  def test_string_io
@@ -153,7 +157,7 @@ class TestParser < Minitest::Test
153
157
  LibXML::XML::Parser.string(nil)
154
158
  end
155
159
 
156
- assert_equal("wrong argument type nil (expected String)", error.to_s)
160
+ assert_equal("wrong argument type nil (expected String)", error.message)
157
161
  end
158
162
 
159
163
  def test_string_options
@@ -165,9 +169,7 @@ class TestParser < Minitest::Test
165
169
  </test>
166
170
  EOS
167
171
 
168
- LibXML::XML::default_substitute_entities = false
169
-
170
- # Parse normally
172
+ # Parse normally - entities won't be substituted
171
173
  parser = LibXML::XML::Parser.string(xml)
172
174
  doc = parser.parse
173
175
  assert_nil(doc.child.base_uri)
@@ -176,13 +178,13 @@ class TestParser < Minitest::Test
176
178
  node = doc.find_first('/test/cdata').child
177
179
  assert_equal(LibXML::XML::Node::CDATA_SECTION_NODE, node.node_type)
178
180
 
179
- # Entities should not be subtituted
181
+ # Entities should not be substituted
180
182
  node = doc.find_first('/test/entity')
181
183
  assert_equal('&foo;', node.child.to_s)
182
184
 
183
185
  # Parse with options
184
- parser = LibXML::XML::Parser.string(xml, :base_uri => 'http://libxml.rubyforge.org',
185
- :options => LibXML::XML::Parser::Options::NOCDATA | LibXML::XML::Parser::Options::NOENT)
186
+ parser = LibXML::XML::Parser.string(xml, base_uri: 'http://libxml.rubyforge.org',
187
+ options: LibXML::XML::Parser::Options::NOCDATA | LibXML::XML::Parser::Options::NOENT)
186
188
  doc = parser.parse
187
189
  assert_equal(doc.child.base_uri, 'http://libxml.rubyforge.org')
188
190
 
@@ -214,7 +216,7 @@ class TestParser < Minitest::Test
214
216
  end
215
217
 
216
218
  assert_equal("Fatal error: Input is not proper UTF-8, indicate encoding !\nBytes: 0xF6 0x74 0x6C 0x65 at :2.",
217
- error.to_s)
219
+ error.message)
218
220
 
219
221
  # Parse as ISO_8859_1:
220
222
  parser = LibXML::XML::Parser.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
@@ -283,16 +285,23 @@ class TestParser < Minitest::Test
283
285
 
284
286
  refute_nil(error)
285
287
  assert_kind_of(LibXML::XML::Error, error)
286
- assert_equal("Fatal error: Extra content at the end of the document at :1.", error.message)
288
+ if windows?
289
+ assert_equal("Fatal error: Couldn't find end of Start Tag ruby_array line 1 at :1.", error.message)
290
+ assert_equal(LibXML::XML::Error::GT_REQUIRED, error.code)
291
+ assert_equal("ruby_array", error.str1)
292
+ assert_equal(1, error.int1)
293
+ else
294
+ assert_equal("Fatal error: Extra content at the end of the document at :1.", error.message)
295
+ assert_equal(LibXML::XML::Error::DOCUMENT_END, error.code)
296
+ assert_nil(error.str1)
297
+ assert_equal(0, error.int1)
298
+ end
287
299
  assert_equal(LibXML::XML::Error::PARSER, error.domain)
288
- assert_equal(LibXML::XML::Error::DOCUMENT_END, error.code)
289
300
  assert_equal(LibXML::XML::Error::FATAL, error.level)
290
301
  assert_nil(error.file)
291
302
  assert_equal(1, error.line)
292
- assert_nil(error.str1)
293
303
  assert_nil(error.str2)
294
304
  assert_nil(error.str3)
295
- assert_equal(0, error.int1)
296
305
  assert_equal(34, error.int2)
297
306
  assert_nil(error.node)
298
307
  end
data/test/test_reader.rb CHANGED
@@ -60,9 +60,10 @@ class TestReader < Minitest::Test
60
60
  end
61
61
 
62
62
  def test_invalid_file
63
- assert_raises(LibXML::XML::Error) do
63
+ error = assert_raises(Errno::ENOENT) do
64
64
  LibXML::XML::Reader.file('/does/not/exist')
65
65
  end
66
+ assert_equal("No such file or directory - /does/not/exist", error.message)
66
67
  end
67
68
 
68
69
  def test_string
@@ -256,7 +257,6 @@ class TestReader < Minitest::Test
256
257
  end
257
258
 
258
259
  def test_node
259
- LibXML::XML.default_line_numbers = true
260
260
  reader = LibXML::XML::Reader.file(XML_FILE)
261
261
 
262
262
  # first try to get a node
@@ -358,7 +358,7 @@ class TestReader < Minitest::Test
358
358
  reader = LibXML::XML::Reader.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
359
359
  reader.read
360
360
 
361
- # Encoding is always null for strings, very annoying!
362
- assert_equal(reader.encoding, LibXML::XML::Encoding::NONE)
361
+ encoding = windows? ? LibXML::XML::Encoding::ISO_8859_1 : LibXML::XML::Encoding::NONE
362
+ assert_equal(reader.encoding, encoding)
363
363
  end
364
364
  end
@@ -318,7 +318,7 @@ EOS
318
318
  error = assert_raises(LibXML::XML::Error) do
319
319
  parser.parse
320
320
  end
321
- assert_equal("Fatal error: xmlParseEntityRef: no name at :5.", error.to_s)
321
+ assert_match("Fatal error: xmlParseEntityRef: no name at", error.to_s)
322
322
 
323
323
  # Check callbacks
324
324
  parser.callbacks.result
data/test/test_xml.rb CHANGED
@@ -9,21 +9,6 @@ class TestXml < Minitest::Test
9
9
  assert(LibXML::XML.check_lib_versions)
10
10
  end
11
11
 
12
- def test_debug_entities
13
- original = LibXML::XML.debug_entities
14
-
15
- LibXML::XML.debug_entities = false
16
- refute(LibXML::XML.debug_entities)
17
-
18
- LibXML::XML.debug_entities = true
19
- assert(LibXML::XML.debug_entities)
20
-
21
- LibXML::XML.debug_entities = false
22
- refute(LibXML::XML.debug_entities)
23
-
24
- LibXML::XML.debug_entities = original
25
- end
26
-
27
12
  def test_default_compression
28
13
  return unless LibXML::XML.default_compression
29
14
 
@@ -52,52 +37,6 @@ class TestXml < Minitest::Test
52
37
  LibXML::XML.default_compression = original
53
38
  end
54
39
 
55
- def test_default_keep_blanks
56
- original = LibXML::XML.default_keep_blanks
57
-
58
- LibXML::XML.default_keep_blanks = false
59
- refute(LibXML::XML.default_keep_blanks)
60
- assert_equal(LibXML::XML::Parser::Options::NOBLANKS, LibXML::XML.default_options)
61
-
62
- LibXML::XML.default_keep_blanks = true
63
- assert(LibXML::XML.default_keep_blanks)
64
- assert_equal(0, LibXML::XML.default_options)
65
-
66
- LibXML::XML.default_keep_blanks = original
67
- end
68
-
69
- def test_default_line_numbers
70
- original = LibXML::XML.default_line_numbers
71
-
72
- LibXML::XML.default_line_numbers = false
73
- refute(LibXML::XML.default_line_numbers)
74
-
75
- LibXML::XML.default_line_numbers = true
76
- assert(LibXML::XML.default_line_numbers)
77
-
78
- LibXML::XML.default_line_numbers = false
79
- refute(LibXML::XML.default_line_numbers)
80
-
81
- LibXML::XML.default_line_numbers = original
82
- end
83
-
84
- def test_default_substitute_entities
85
- original = LibXML::XML.default_substitute_entities
86
-
87
- LibXML::XML.default_substitute_entities = false
88
- refute(LibXML::XML.default_substitute_entities)
89
- assert_equal(0, LibXML::XML.default_options)
90
-
91
- LibXML::XML.default_substitute_entities = true
92
- assert(LibXML::XML.default_substitute_entities)
93
- assert_equal(LibXML::XML::Parser::Options::NOENT, LibXML::XML.default_options)
94
-
95
- LibXML::XML.default_substitute_entities = false
96
- refute(LibXML::XML.default_substitute_entities)
97
-
98
- LibXML::XML.default_substitute_entities = original
99
- end
100
-
101
40
  def test_default_tree_indent_string
102
41
  original = LibXML::XML.default_tree_indent_string
103
42
 
@@ -116,40 +55,6 @@ class TestXml < Minitest::Test
116
55
  LibXML::XML.default_tree_indent_string = original
117
56
  end
118
57
 
119
- def test_default_validity_checking
120
- original = LibXML::XML.default_validity_checking
121
-
122
- LibXML::XML.default_validity_checking = false
123
- refute(LibXML::XML.default_validity_checking)
124
- assert_equal(0, LibXML::XML.default_options)
125
-
126
- LibXML::XML.default_validity_checking = true
127
- assert(LibXML::XML.default_validity_checking)
128
- assert_equal(LibXML::XML::Parser::Options::DTDVALID, LibXML::XML.default_options)
129
-
130
- LibXML::XML.default_validity_checking = false
131
- refute(LibXML::XML.default_validity_checking)
132
-
133
- LibXML::XML.default_validity_checking = original
134
- end
135
-
136
- def test_default_warnings
137
- original = LibXML::XML.default_warnings
138
-
139
- LibXML::XML.default_warnings = false
140
- refute(LibXML::XML.default_warnings)
141
- assert_equal(LibXML::XML::Parser::Options::NOWARNING, LibXML::XML.default_options)
142
-
143
- LibXML::XML.default_warnings = true
144
- assert(LibXML::XML.default_warnings)
145
- assert_equal(0, LibXML::XML.default_options)
146
-
147
- LibXML::XML.default_warnings = false
148
- refute(LibXML::XML.default_warnings)
149
-
150
- LibXML::XML.default_warnings = original
151
- end
152
-
153
58
  def test_enabled_automata
154
59
  assert(LibXML::XML.enabled_automata?)
155
60
  end
@@ -249,10 +154,6 @@ class TestXml < Minitest::Test
249
154
  assert_instance_of(Integer, LibXML::XML::VERNUM)
250
155
  end
251
156
 
252
- def test_default_options
253
- assert_equal(0, LibXML::XML.default_options)
254
- end
255
-
256
157
  def test_default_save_no_empty_tags
257
158
  original = LibXML::XML.default_save_no_empty_tags
258
159
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxml-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamform
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2023-11-04 00:00:00.000000000 Z
17
+ date: 2024-01-07 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: rake-compiler
@@ -216,6 +216,7 @@ files:
216
216
  - test/model/shiporder_import.xsd
217
217
  - test/model/soap.xml
218
218
  - test/model/xinclude.xml
219
+ - test/test.rb
219
220
  - test/test_attr.rb
220
221
  - test/test_attr_decl.rb
221
222
  - test/test_attributes.rb
@@ -274,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
275
  - !ruby/object:Gem::Version
275
276
  version: '0'
276
277
  requirements: []
277
- rubygems_version: 3.4.21
278
+ rubygems_version: 3.5.3
278
279
  signing_key:
279
280
  specification_version: 4
280
281
  summary: Ruby Bindings for LibXML2