libxml-ruby 4.1.1-x64-mingw-ucrt → 5.0.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +22 -0
  3. data/ext/libxml/extconf.rb +67 -61
  4. data/ext/libxml/ruby_libxml.h +43 -44
  5. data/ext/libxml/ruby_xml.c +0 -343
  6. data/ext/libxml/ruby_xml.h +9 -10
  7. data/ext/libxml/ruby_xml_attr_decl.c +154 -153
  8. data/ext/libxml/ruby_xml_attributes.c +276 -275
  9. data/ext/libxml/ruby_xml_attributes.h +2 -0
  10. data/ext/libxml/ruby_xml_document.c +6 -6
  11. data/ext/libxml/ruby_xml_document.h +11 -11
  12. data/ext/libxml/ruby_xml_dtd.c +3 -3
  13. data/ext/libxml/ruby_xml_encoding.h +20 -18
  14. data/ext/libxml/ruby_xml_error.c +9 -6
  15. data/ext/libxml/ruby_xml_error.h +2 -2
  16. data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
  17. data/ext/libxml/ruby_xml_namespace.c +0 -3
  18. data/ext/libxml/ruby_xml_node.c +1394 -1398
  19. data/ext/libxml/ruby_xml_parser.h +1 -1
  20. data/ext/libxml/ruby_xml_parser_context.c +47 -39
  21. data/ext/libxml/ruby_xml_parser_options.c +9 -1
  22. data/ext/libxml/ruby_xml_parser_options.h +1 -1
  23. data/ext/libxml/ruby_xml_reader.c +1244 -1242
  24. data/ext/libxml/ruby_xml_relaxng.c +113 -112
  25. data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
  26. data/ext/libxml/ruby_xml_sax_parser.c +1 -9
  27. data/ext/libxml/ruby_xml_schema.c +422 -420
  28. data/ext/libxml/ruby_xml_schema_attribute.c +108 -107
  29. data/ext/libxml/ruby_xml_schema_element.c +70 -69
  30. data/ext/libxml/ruby_xml_schema_type.c +252 -251
  31. data/ext/libxml/ruby_xml_version.h +5 -5
  32. data/ext/libxml/ruby_xml_writer.c +1138 -1137
  33. data/ext/libxml/ruby_xml_xpath.c +1 -1
  34. data/ext/libxml/ruby_xml_xpath_context.c +2 -2
  35. data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
  36. data/ext/libxml/ruby_xml_xpath_object.c +340 -339
  37. data/lib/3.2/libxml_ruby.so +0 -0
  38. data/lib/3.3/libxml_ruby.so +0 -0
  39. data/lib/libxml/document.rb +13 -13
  40. data/lib/libxml/html_parser.rb +23 -23
  41. data/lib/libxml/parser.rb +26 -24
  42. data/lib/libxml/schema/element.rb +27 -19
  43. data/test/test.rb +5 -0
  44. data/test/test_document_write.rb +1 -4
  45. data/test/test_dtd.rb +1 -4
  46. data/test/test_encoding.rb +1 -4
  47. data/test/test_helper.rb +9 -2
  48. data/test/test_html_parser.rb +162 -162
  49. data/test/test_namespace.rb +1 -3
  50. data/test/test_node.rb +1 -3
  51. data/test/test_node_write.rb +1 -4
  52. data/test/test_parser.rb +26 -17
  53. data/test/test_reader.rb +4 -4
  54. data/test/test_sax_parser.rb +1 -1
  55. data/test/test_schema.rb +237 -231
  56. data/test/test_xml.rb +0 -99
  57. metadata +5 -4
  58. data/lib/3.1/libxml_ruby.so +0 -0
@@ -17,21 +17,21 @@ module LibXML
17
17
 
18
18
  # call-seq:
19
19
  # XML::Document.file(path) -> XML::Document
20
- # XML::Document.file(path, :encoding => XML::Encoding::UTF_8,
21
- # :options => XML::Parser::Options::NOENT) -> XML::Document
20
+ # XML::Document.file(path, encoding: XML::Encoding::UTF_8,
21
+ # options: XML::Parser::Options::NOENT) -> XML::Document
22
22
  #
23
23
  # Creates a new document from the specified file or uri.
24
24
  #
25
- # You may provide an optional hash table to control how the
26
- # parsing is performed. Valid options are:
25
+ # Parameters:
27
26
  #
27
+ # path - Path to file
28
28
  # encoding - The document encoding, defaults to nil. Valid values
29
29
  # are the encoding constants defined on XML::Encoding.
30
30
  # options - Parser options. Valid values are the constants defined on
31
31
  # XML::Parser::Options. Mutliple options can be combined
32
32
  # by using Bitwise OR (|).
33
- def self.file(value, options = {})
34
- Parser.file(value, options).parse
33
+ def self.file(path, encoding: nil, options: nil)
34
+ Parser.file(path, encoding: encoding, options: options).parse
35
35
  end
36
36
 
37
37
  # call-seq:
@@ -57,23 +57,23 @@ module LibXML
57
57
 
58
58
  # call-seq:
59
59
  # XML::Document.string(string) -> XML::Document
60
- # XML::Document.string(string, :encoding => XML::Encoding::UTF_8,
61
- # :options => XML::Parser::Options::NOENT
62
- # :base_uri="http://libxml.org") -> XML::Document
60
+ # XML::Document.string(string, encoding: XML::Encoding::UTF_8,
61
+ # options: XML::Parser::Options::NOENT
62
+ # base_uri: "http://libxml.org") -> XML::Document
63
63
  #
64
64
  # Creates a new document from the specified string.
65
65
  #
66
- # You may provide an optional hash table to control how the
67
- # parsing is performed. Valid options are:
66
+ # Parameters:
68
67
  #
68
+ # string - String to parse
69
69
  # base_uri - The base url for the parsed document.
70
70
  # encoding - The document encoding, defaults to nil. Valid values
71
71
  # are the encoding constants defined on XML::Encoding.
72
72
  # options - Parser options. Valid values are the constants defined on
73
73
  # XML::Parser::Options. Mutliple options can be combined
74
74
  # by using Bitwise OR (|).
75
- def self.string(value, options = {})
76
- Parser.string(value, options).parse
75
+ def self.string(value, base_uri: nil, encoding: nil, options: nil)
76
+ Parser.string(value, base_uri: base_uri, encoding: encoding, options: options).parse
77
77
  end
78
78
 
79
79
  # Returns a new XML::XPathContext for the document.
@@ -5,31 +5,31 @@ module LibXML
5
5
  class HTMLParser
6
6
  # call-seq:
7
7
  # XML::HTMLParser.file(path) -> XML::HTMLParser
8
- # XML::HTMLParser.file(path, :encoding => XML::Encoding::UTF_8,
9
- # :options => XML::HTMLParser::Options::NOENT) -> XML::HTMLParser
8
+ # XML::HTMLParser.file(path, encoding: XML::Encoding::UTF_8,
9
+ # options: XML::HTMLParser::Options::NOENT) -> XML::HTMLParser
10
10
  #
11
11
  # Creates a new parser by parsing the specified file or uri.
12
12
  #
13
- # You may provide an optional hash table to control how the
14
- # parsing is performed. Valid options are:
13
+ # Parameters:
15
14
  #
15
+ # path - Path to file to parse
16
16
  # encoding - The document encoding, defaults to nil. Valid values
17
17
  # are the encoding constants defined on XML::Encoding.
18
18
  # options - Parser options. Valid values are the constants defined on
19
19
  # XML::HTMLParser::Options. Mutliple options can be combined
20
20
  # by using Bitwise OR (|).
21
- def self.file(path, options = {})
21
+ def self.file(path, encoding: nil, options: nil)
22
22
  context = XML::HTMLParser::Context.file(path)
23
- context.encoding = options[:encoding] if options[:encoding]
24
- context.options = options[:options] if options[:options]
23
+ context.encoding = encoding if encoding
24
+ context.options = options if options
25
25
  self.new(context)
26
26
  end
27
27
 
28
28
  # call-seq:
29
29
  # XML::HTMLParser.io(io) -> XML::HTMLParser
30
- # XML::HTMLParser.io(io, :encoding => XML::Encoding::UTF_8,
31
- # :options => XML::HTMLParser::Options::NOENT
32
- # :base_uri="http://libxml.org") -> XML::HTMLParser
30
+ # XML::HTMLParser.io(io, encoding: XML::Encoding::UTF_8,
31
+ # options: XML::HTMLParser::Options::NOENT
32
+ # base_uri: "http://libxml.org") -> XML::HTMLParser
33
33
  #
34
34
  # Creates a new reader by parsing the specified io object.
35
35
  #
@@ -42,36 +42,36 @@ module LibXML
42
42
  # options - Parser options. Valid values are the constants defined on
43
43
  # XML::HTMLParser::Options. Mutliple options can be combined
44
44
  # by using Bitwise OR (|).
45
- def self.io(io, options = {})
45
+ def self.io(io, base_uri: nil, encoding: nil, options: nil)
46
46
  context = XML::HTMLParser::Context.io(io)
47
- context.base_uri = options[:base_uri] if options[:base_uri]
48
- context.encoding = options[:encoding] if options[:encoding]
49
- context.options = options[:options] if options[:options]
47
+ context.base_uri = base_uri if base_uri
48
+ context.encoding = encoding if encoding
49
+ context.options = options if options
50
50
  self.new(context)
51
51
  end
52
52
 
53
53
  # call-seq:
54
54
  # XML::HTMLParser.string(string)
55
- # XML::HTMLParser.string(string, :encoding => XML::Encoding::UTF_8,
56
- # :options => XML::HTMLParser::Options::NOENT
57
- # :base_uri="http://libxml.org") -> XML::HTMLParser
55
+ # XML::HTMLParser.string(string, encoding: XML::Encoding::UTF_8,
56
+ # options: XML::HTMLParser::Options::NOENT
57
+ # base_uri: "http://libxml.org") -> XML::HTMLParser
58
58
  #
59
59
  # Creates a new parser by parsing the specified string.
60
60
  #
61
- # You may provide an optional hash table to control how the
62
- # parsing is performed. Valid options are:
61
+ # Parameters:
63
62
  #
63
+ # string - String to parse
64
64
  # base_uri - The base url for the parsed document.
65
65
  # encoding - The document encoding, defaults to nil. Valid values
66
66
  # are the encoding constants defined on XML::Encoding.
67
67
  # options - Parser options. Valid values are the constants defined on
68
68
  # XML::HTMLParser::Options. Mutliple options can be combined
69
69
  # by using Bitwise OR (|).
70
- def self.string(string, options = {})
70
+ def self.string(string, base_uri: nil, encoding: nil, options: nil)
71
71
  context = XML::HTMLParser::Context.string(string)
72
- context.base_uri = options[:base_uri] if options[:base_uri]
73
- context.encoding = options[:encoding] if options[:encoding]
74
- context.options = options[:options] if options[:options]
72
+ context.base_uri = base_uri if base_uri
73
+ context.encoding = encoding if encoding
74
+ context.options = options if options
75
75
  self.new(context)
76
76
  end
77
77
 
data/lib/libxml/parser.rb CHANGED
@@ -18,31 +18,33 @@ module LibXML
18
18
 
19
19
  # call-seq:
20
20
  # XML::Parser.file(path) -> XML::Parser
21
- # XML::Parser.file(path, :encoding => XML::Encoding::UTF_8,
22
- # :options => XML::Parser::Options::NOENT) -> XML::Parser
21
+ # XML::Parser.file(path, encoding: XML::Encoding::UTF_8,
22
+ # options: XML::Parser::Options::NOENT) -> XML::Parser
23
23
  #
24
24
  # Creates a new parser for the specified file or uri.
25
25
  #
26
- # You may provide an optional hash table to control how the
27
- # parsing is performed. Valid options are:
26
+ # Parameters:
28
27
  #
28
+ # path - Path to file
29
+ # base_uri - The base url for the parsed document.
29
30
  # encoding - The document encoding, defaults to nil. Valid values
30
31
  # are the encoding constants defined on XML::Encoding.
31
32
  # options - Parser options. Valid values are the constants defined on
32
33
  # XML::Parser::Options. Mutliple options can be combined
33
34
  # by using Bitwise OR (|).
34
- def self.file(path, options = {})
35
+ def self.file(path, base_uri: nil, encoding: nil, options: nil)
35
36
  context = XML::Parser::Context.file(path)
36
- context.encoding = options[:encoding] if options[:encoding]
37
- context.options = options[:options] if options[:options]
37
+ context.base_uri = base_uri if base_uri
38
+ context.encoding = encoding if encoding
39
+ context.options = options if options
38
40
  self.new(context)
39
41
  end
40
42
 
41
43
  # call-seq:
42
44
  # XML::Parser.io(io) -> XML::Parser
43
- # XML::Parser.io(io, :encoding => XML::Encoding::UTF_8,
44
- # :options => XML::Parser::Options::NOENT
45
- # :base_uri="http://libxml.org") -> XML::Parser
45
+ # XML::Parser.io(io, encoding: XML::Encoding::UTF_8,
46
+ # options: XML::Parser::Options::NOENT
47
+ # base_uri: "http://libxml.org") -> XML::Parser
46
48
  #
47
49
  # Creates a new parser for the specified io object.
48
50
  #
@@ -55,36 +57,36 @@ module LibXML
55
57
  # options - Parser options. Valid values are the constants defined on
56
58
  # XML::Parser::Options. Mutliple options can be combined
57
59
  # by using Bitwise OR (|).
58
- def self.io(io, options = {})
60
+ def self.io(io, base_uri: nil, encoding: nil, options: nil)
59
61
  context = XML::Parser::Context.io(io)
60
- context.base_uri = options[:base_uri] if options[:base_uri]
61
- context.encoding = options[:encoding] if options[:encoding]
62
- context.options = options[:options] if options[:options]
62
+ context.base_uri = base_uri if base_uri
63
+ context.encoding = encoding if encoding
64
+ context.options = options if options
63
65
  self.new(context)
64
66
  end
65
67
 
66
68
  # call-seq:
67
69
  # XML::Parser.string(string)
68
- # XML::Parser.string(string, :encoding => XML::Encoding::UTF_8,
69
- # :options => XML::Parser::Options::NOENT
70
- # :base_uri="http://libxml.org") -> XML::Parser
70
+ # XML::Parser.string(string, encoding: XML::Encoding::UTF_8,
71
+ # options: XML::Parser::Options::NOENT
72
+ # base_uri: "http://libxml.org") -> XML::Parser
71
73
  #
72
74
  # Creates a new parser by parsing the specified string.
73
75
  #
74
- # You may provide an optional hash table to control how the
75
- # parsing is performed. Valid options are:
76
+ # Parameters:
76
77
  #
78
+ # string - The string to parse
77
79
  # base_uri - The base url for the parsed document.
78
80
  # encoding - The document encoding, defaults to nil. Valid values
79
81
  # are the encoding constants defined on XML::Encoding.
80
82
  # options - Parser options. Valid values are the constants defined on
81
- # XML::Parser::Options. Mutliple options can be combined
83
+ # XML::Parser::Options. Multiple options can be combined
82
84
  # by using Bitwise OR (|).
83
- def self.string(string, options = {})
85
+ def self.string(string, base_uri: nil, encoding: nil, options: nil)
84
86
  context = XML::Parser::Context.string(string)
85
- context.base_uri = options[:base_uri] if options[:base_uri]
86
- context.encoding = options[:encoding] if options[:encoding]
87
- context.options = options[:options] if options[:options]
87
+ context.base_uri = base_uri if base_uri
88
+ context.encoding = encoding if encoding
89
+ context.options = options if options
88
90
  self.new(context)
89
91
  end
90
92
 
@@ -1,19 +1,27 @@
1
- # encoding: UTF-8
2
-
3
- module LibXML
4
- module XML
5
- class Schema::Element
6
- def required?
7
- !min_occurs.zero?
8
- end
9
-
10
- def array?
11
- max_occurs > 1
12
- end
13
-
14
- def elements
15
- type.elements
16
- end
17
- end
18
- end
19
- end
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class Schema::Element
6
+ def min_occurs
7
+ @min
8
+ end
9
+
10
+ def max_occurs
11
+ @max
12
+ end
13
+
14
+ def required?
15
+ !min_occurs.zero?
16
+ end
17
+
18
+ def array?
19
+ max_occurs > 1
20
+ end
21
+
22
+ def elements
23
+ type.elements
24
+ end
25
+ end
26
+ end
27
+ end
data/test/test.rb ADDED
@@ -0,0 +1,5 @@
1
+ begin
2
+ File.open("/does/not/exist")
3
+ rescue => e
4
+ puts e
5
+ end
@@ -7,14 +7,11 @@ class TestDocumentWrite < Minitest::Test
7
7
  def setup
8
8
  @file_name = "model/bands.utf-8.xml"
9
9
 
10
- # Strip spaces to make testing easier
11
- LibXML::XML.default_keep_blanks = false
12
10
  file = File.join(File.dirname(__FILE__), @file_name)
13
- @doc = LibXML::XML::Document.file(file)
11
+ @doc = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NOBLANKS)
14
12
  end
15
13
 
16
14
  def teardown
17
- LibXML::XML.default_keep_blanks = true
18
15
  @doc = nil
19
16
  end
20
17
 
data/test/test_dtd.rb CHANGED
@@ -106,13 +106,11 @@ class TestDtd < Minitest::Test
106
106
  errors << error
107
107
  end
108
108
 
109
- LibXML::XML.default_load_external_dtd = false
110
109
  LibXML::XML::Parser.string(xml).parse
111
110
  assert_equal(0, errors.length)
112
111
 
113
112
  errors.clear
114
- LibXML::XML.default_load_external_dtd = true
115
- LibXML::XML::Parser.string(xml).parse
113
+ LibXML::XML::Parser.string(xml, options: LibXML::XML::Parser::Options::DTDLOAD).parse
116
114
  assert_equal(1, errors.length)
117
115
  assert_equal("Warning: failed to load external entity \"test.dtd\" at :1.",
118
116
  errors[0].to_s)
@@ -123,7 +121,6 @@ class TestDtd < Minitest::Test
123
121
  assert_equal("Warning: failed to load external entity \"test.dtd\" at :1.",
124
122
  errors[0].to_s)
125
123
  ensure
126
- LibXML::XML.default_load_external_dtd = false
127
124
  LibXML::XML::Error.reset_handler
128
125
  end
129
126
  end
@@ -38,10 +38,7 @@ class TestEncoding < Minitest::Test
38
38
  @encoding = encoding
39
39
  file = file_for_encoding(encoding)
40
40
 
41
- # Strip spaces to make testing easier
42
- LibXML::XML.default_keep_blanks = false
43
- @doc = LibXML::XML::Document.file(file)
44
- LibXML::XML.default_keep_blanks = true
41
+ @doc = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NOBLANKS)
45
42
  end
46
43
 
47
44
  def test_encoding
data/test/test_helper.rb CHANGED
@@ -1,9 +1,13 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  # To make testing/debugging easier, test within this source tree versus an installed gem
4
-
5
4
  require 'bundler/setup'
6
- require 'minitest/autorun'
5
+
6
+ # Add ext directory to load path to make it easier to test locally built extensions
7
+ ext_path = File.expand_path(File.join(__dir__, '..', 'ext', 'libxml'))
8
+ $LOAD_PATH.unshift(File.expand_path(ext_path))
9
+
10
+ # Now load code
7
11
  require 'libxml-ruby'
8
12
 
9
13
  def windows?
@@ -11,3 +15,6 @@ def windows?
11
15
  end
12
16
 
13
17
  STDOUT.write "\nlibxml2: #{LibXML::XML::LIBXML_VERSION}\n#{RUBY_DESCRIPTION}\n\n"
18
+
19
+ require 'minitest/autorun'
20
+