nokogiri 1.11.0.rc4-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-DEPENDENCIES.md +1682 -0
  3. data/LICENSE.md +9 -0
  4. data/README.md +200 -0
  5. data/bin/nokogiri +118 -0
  6. data/dependencies.yml +74 -0
  7. data/ext/nokogiri/depend +477 -0
  8. data/ext/nokogiri/extconf.rb +819 -0
  9. data/ext/nokogiri/html_document.c +171 -0
  10. data/ext/nokogiri/html_document.h +10 -0
  11. data/ext/nokogiri/html_element_description.c +279 -0
  12. data/ext/nokogiri/html_element_description.h +10 -0
  13. data/ext/nokogiri/html_entity_lookup.c +32 -0
  14. data/ext/nokogiri/html_entity_lookup.h +8 -0
  15. data/ext/nokogiri/html_sax_parser_context.c +116 -0
  16. data/ext/nokogiri/html_sax_parser_context.h +11 -0
  17. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  18. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  19. data/ext/nokogiri/include/libexslt/exslt.h +102 -0
  20. data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
  21. data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
  22. data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -0
  23. data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
  24. data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
  25. data/ext/nokogiri/include/libxml2/libxml/SAX.h +173 -0
  26. data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
  27. data/ext/nokogiri/include/libxml2/libxml/c14n.h +126 -0
  28. data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
  29. data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
  30. data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
  31. data/ext/nokogiri/include/libxml2/libxml/dict.h +79 -0
  32. data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
  33. data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
  34. data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -0
  35. data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
  36. data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
  37. data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +163 -0
  38. data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
  39. data/ext/nokogiri/include/libxml2/libxml/parser.h +1241 -0
  40. data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
  41. data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
  42. data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -0
  43. data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
  44. data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
  45. data/ext/nokogiri/include/libxml2/libxml/threads.h +89 -0
  46. data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
  47. data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
  48. data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -0
  49. data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
  50. data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
  51. data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +366 -0
  52. data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
  53. data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +945 -0
  54. data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +153 -0
  55. data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -0
  56. data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
  57. data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
  58. data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
  59. data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
  60. data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
  61. data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +151 -0
  62. data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
  63. data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
  64. data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +485 -0
  65. data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
  66. data/ext/nokogiri/include/libxml2/libxml/xpath.h +566 -0
  67. data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
  68. data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -0
  69. data/ext/nokogiri/include/libxslt/attributes.h +38 -0
  70. data/ext/nokogiri/include/libxslt/documents.h +93 -0
  71. data/ext/nokogiri/include/libxslt/extensions.h +262 -0
  72. data/ext/nokogiri/include/libxslt/extra.h +72 -0
  73. data/ext/nokogiri/include/libxslt/functions.h +78 -0
  74. data/ext/nokogiri/include/libxslt/imports.h +75 -0
  75. data/ext/nokogiri/include/libxslt/keys.h +53 -0
  76. data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
  77. data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
  78. data/ext/nokogiri/include/libxslt/pattern.h +84 -0
  79. data/ext/nokogiri/include/libxslt/preproc.h +43 -0
  80. data/ext/nokogiri/include/libxslt/security.h +104 -0
  81. data/ext/nokogiri/include/libxslt/templates.h +77 -0
  82. data/ext/nokogiri/include/libxslt/transform.h +207 -0
  83. data/ext/nokogiri/include/libxslt/variables.h +118 -0
  84. data/ext/nokogiri/include/libxslt/xslt.h +110 -0
  85. data/ext/nokogiri/include/libxslt/xsltInternals.h +1978 -0
  86. data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
  87. data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
  88. data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
  89. data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
  90. data/ext/nokogiri/nokogiri.c +135 -0
  91. data/ext/nokogiri/nokogiri.h +130 -0
  92. data/ext/nokogiri/xml_attr.c +103 -0
  93. data/ext/nokogiri/xml_attr.h +9 -0
  94. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  95. data/ext/nokogiri/xml_attribute_decl.h +9 -0
  96. data/ext/nokogiri/xml_cdata.c +62 -0
  97. data/ext/nokogiri/xml_cdata.h +9 -0
  98. data/ext/nokogiri/xml_comment.c +69 -0
  99. data/ext/nokogiri/xml_comment.h +9 -0
  100. data/ext/nokogiri/xml_document.c +622 -0
  101. data/ext/nokogiri/xml_document.h +23 -0
  102. data/ext/nokogiri/xml_document_fragment.c +48 -0
  103. data/ext/nokogiri/xml_document_fragment.h +10 -0
  104. data/ext/nokogiri/xml_dtd.c +202 -0
  105. data/ext/nokogiri/xml_dtd.h +10 -0
  106. data/ext/nokogiri/xml_element_content.c +123 -0
  107. data/ext/nokogiri/xml_element_content.h +10 -0
  108. data/ext/nokogiri/xml_element_decl.c +69 -0
  109. data/ext/nokogiri/xml_element_decl.h +9 -0
  110. data/ext/nokogiri/xml_encoding_handler.c +79 -0
  111. data/ext/nokogiri/xml_encoding_handler.h +8 -0
  112. data/ext/nokogiri/xml_entity_decl.c +110 -0
  113. data/ext/nokogiri/xml_entity_decl.h +10 -0
  114. data/ext/nokogiri/xml_entity_reference.c +52 -0
  115. data/ext/nokogiri/xml_entity_reference.h +9 -0
  116. data/ext/nokogiri/xml_io.c +63 -0
  117. data/ext/nokogiri/xml_io.h +11 -0
  118. data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
  119. data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
  120. data/ext/nokogiri/xml_namespace.c +111 -0
  121. data/ext/nokogiri/xml_namespace.h +14 -0
  122. data/ext/nokogiri/xml_node.c +1773 -0
  123. data/ext/nokogiri/xml_node.h +13 -0
  124. data/ext/nokogiri/xml_node_set.c +486 -0
  125. data/ext/nokogiri/xml_node_set.h +12 -0
  126. data/ext/nokogiri/xml_processing_instruction.c +56 -0
  127. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  128. data/ext/nokogiri/xml_reader.c +657 -0
  129. data/ext/nokogiri/xml_reader.h +10 -0
  130. data/ext/nokogiri/xml_relax_ng.c +179 -0
  131. data/ext/nokogiri/xml_relax_ng.h +9 -0
  132. data/ext/nokogiri/xml_sax_parser.c +305 -0
  133. data/ext/nokogiri/xml_sax_parser.h +39 -0
  134. data/ext/nokogiri/xml_sax_parser_context.c +262 -0
  135. data/ext/nokogiri/xml_sax_parser_context.h +10 -0
  136. data/ext/nokogiri/xml_sax_push_parser.c +159 -0
  137. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  138. data/ext/nokogiri/xml_schema.c +276 -0
  139. data/ext/nokogiri/xml_schema.h +9 -0
  140. data/ext/nokogiri/xml_syntax_error.c +64 -0
  141. data/ext/nokogiri/xml_syntax_error.h +13 -0
  142. data/ext/nokogiri/xml_text.c +52 -0
  143. data/ext/nokogiri/xml_text.h +9 -0
  144. data/ext/nokogiri/xml_xpath_context.c +374 -0
  145. data/ext/nokogiri/xml_xpath_context.h +10 -0
  146. data/ext/nokogiri/xslt_stylesheet.c +263 -0
  147. data/ext/nokogiri/xslt_stylesheet.h +14 -0
  148. data/lib/nokogiri.rb +127 -0
  149. data/lib/nokogiri/2.5/nokogiri.bundle +0 -0
  150. data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
  151. data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
  152. data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
  153. data/lib/nokogiri/css.rb +28 -0
  154. data/lib/nokogiri/css/node.rb +53 -0
  155. data/lib/nokogiri/css/parser.rb +751 -0
  156. data/lib/nokogiri/css/parser.y +272 -0
  157. data/lib/nokogiri/css/parser_extras.rb +94 -0
  158. data/lib/nokogiri/css/syntax_error.rb +8 -0
  159. data/lib/nokogiri/css/tokenizer.rb +154 -0
  160. data/lib/nokogiri/css/tokenizer.rex +55 -0
  161. data/lib/nokogiri/css/xpath_visitor.rb +260 -0
  162. data/lib/nokogiri/decorators/slop.rb +43 -0
  163. data/lib/nokogiri/html.rb +38 -0
  164. data/lib/nokogiri/html/builder.rb +36 -0
  165. data/lib/nokogiri/html/document.rb +322 -0
  166. data/lib/nokogiri/html/document_fragment.rb +50 -0
  167. data/lib/nokogiri/html/element_description.rb +24 -0
  168. data/lib/nokogiri/html/element_description_defaults.rb +672 -0
  169. data/lib/nokogiri/html/entity_lookup.rb +14 -0
  170. data/lib/nokogiri/html/sax/parser.rb +63 -0
  171. data/lib/nokogiri/html/sax/parser_context.rb +17 -0
  172. data/lib/nokogiri/html/sax/push_parser.rb +37 -0
  173. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  174. data/lib/nokogiri/syntax_error.rb +5 -0
  175. data/lib/nokogiri/version.rb +3 -0
  176. data/lib/nokogiri/version/constant.rb +5 -0
  177. data/lib/nokogiri/version/info.rb +182 -0
  178. data/lib/nokogiri/xml.rb +76 -0
  179. data/lib/nokogiri/xml/attr.rb +15 -0
  180. data/lib/nokogiri/xml/attribute_decl.rb +19 -0
  181. data/lib/nokogiri/xml/builder.rb +447 -0
  182. data/lib/nokogiri/xml/cdata.rb +12 -0
  183. data/lib/nokogiri/xml/character_data.rb +8 -0
  184. data/lib/nokogiri/xml/document.rb +290 -0
  185. data/lib/nokogiri/xml/document_fragment.rb +159 -0
  186. data/lib/nokogiri/xml/dtd.rb +33 -0
  187. data/lib/nokogiri/xml/element_content.rb +37 -0
  188. data/lib/nokogiri/xml/element_decl.rb +14 -0
  189. data/lib/nokogiri/xml/entity_decl.rb +20 -0
  190. data/lib/nokogiri/xml/entity_reference.rb +19 -0
  191. data/lib/nokogiri/xml/namespace.rb +14 -0
  192. data/lib/nokogiri/xml/node.rb +1240 -0
  193. data/lib/nokogiri/xml/node/save_options.rb +62 -0
  194. data/lib/nokogiri/xml/node_set.rb +372 -0
  195. data/lib/nokogiri/xml/notation.rb +7 -0
  196. data/lib/nokogiri/xml/parse_options.rb +127 -0
  197. data/lib/nokogiri/xml/pp.rb +3 -0
  198. data/lib/nokogiri/xml/pp/character_data.rb +19 -0
  199. data/lib/nokogiri/xml/pp/node.rb +57 -0
  200. data/lib/nokogiri/xml/processing_instruction.rb +9 -0
  201. data/lib/nokogiri/xml/reader.rb +116 -0
  202. data/lib/nokogiri/xml/relax_ng.rb +37 -0
  203. data/lib/nokogiri/xml/sax.rb +5 -0
  204. data/lib/nokogiri/xml/sax/document.rb +172 -0
  205. data/lib/nokogiri/xml/sax/parser.rb +123 -0
  206. data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
  207. data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
  208. data/lib/nokogiri/xml/schema.rb +72 -0
  209. data/lib/nokogiri/xml/searchable.rb +239 -0
  210. data/lib/nokogiri/xml/syntax_error.rb +71 -0
  211. data/lib/nokogiri/xml/text.rb +10 -0
  212. data/lib/nokogiri/xml/xpath.rb +11 -0
  213. data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
  214. data/lib/nokogiri/xml/xpath_context.rb +17 -0
  215. data/lib/nokogiri/xslt.rb +57 -0
  216. data/lib/nokogiri/xslt/stylesheet.rb +26 -0
  217. data/lib/xsd/xmlparser/nokogiri.rb +103 -0
  218. metadata +565 -0
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ module HTML
4
+ class EntityDescription < Struct.new(:value, :name, :description); end
5
+
6
+ class EntityLookup
7
+ ###
8
+ # Look up entity with +name+
9
+ def [] name
10
+ (val = get(name)) && val.value
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ module HTML
4
+ ###
5
+ # Nokogiri lets you write a SAX parser to process HTML but get HTML
6
+ # correction features.
7
+ #
8
+ # See Nokogiri::HTML::SAX::Parser for a basic example of using a
9
+ # SAX parser with HTML.
10
+ #
11
+ # For more information on SAX parsers, see Nokogiri::XML::SAX
12
+ module SAX
13
+ ###
14
+ # This class lets you perform SAX style parsing on HTML with HTML
15
+ # error correction.
16
+ #
17
+ # Here is a basic usage example:
18
+ #
19
+ # class MyDoc < Nokogiri::XML::SAX::Document
20
+ # def start_element name, attributes = []
21
+ # puts "found a #{name}"
22
+ # end
23
+ # end
24
+ #
25
+ # parser = Nokogiri::HTML::SAX::Parser.new(MyDoc.new)
26
+ # parser.parse(File.read(ARGV[0], mode: 'rb'))
27
+ #
28
+ # For more information on SAX parsers, see Nokogiri::XML::SAX
29
+ class Parser < Nokogiri::XML::SAX::Parser
30
+ ###
31
+ # Parse html stored in +data+ using +encoding+
32
+ def parse_memory data, encoding = 'UTF-8'
33
+ raise ArgumentError unless data
34
+ return unless data.length > 0
35
+ ctx = ParserContext.memory(data, encoding)
36
+ yield ctx if block_given?
37
+ ctx.parse_with self
38
+ end
39
+
40
+ ###
41
+ # Parse given +io+
42
+ def parse_io io, encoding = 'UTF-8'
43
+ check_encoding(encoding)
44
+ @encoding = encoding
45
+ ctx = ParserContext.io(io, ENCODINGS[encoding])
46
+ yield ctx if block_given?
47
+ ctx.parse_with self
48
+ end
49
+
50
+ ###
51
+ # Parse a file with +filename+
52
+ def parse_file filename, encoding = 'UTF-8'
53
+ raise ArgumentError unless filename
54
+ raise Errno::ENOENT unless File.exist?(filename)
55
+ raise Errno::EISDIR if File.directory?(filename)
56
+ ctx = ParserContext.file(filename, encoding)
57
+ yield ctx if block_given?
58
+ ctx.parse_with self
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ module HTML
4
+ module SAX
5
+ ###
6
+ # Context for HTML SAX parsers. This class is usually not instantiated
7
+ # by the user. Instead, you should be looking at
8
+ # Nokogiri::HTML::SAX::Parser
9
+ class ParserContext < Nokogiri::XML::SAX::ParserContext
10
+ def self.new thing, encoding = 'UTF-8'
11
+ [:read, :close].all? { |x| thing.respond_to?(x) } ? super :
12
+ memory(thing, encoding)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ module HTML
4
+ module SAX
5
+ class PushParser
6
+
7
+ # The Nokogiri::HTML::SAX::Document on which the PushParser will be
8
+ # operating
9
+ attr_accessor :document
10
+
11
+ def initialize(doc = HTML::SAX::Document.new, file_name = nil, encoding = 'UTF-8')
12
+ @document = doc
13
+ @encoding = encoding
14
+ @sax_parser = HTML::SAX::Parser.new(doc, @encoding)
15
+
16
+ ## Create our push parser context
17
+ initialize_native(@sax_parser, file_name, encoding)
18
+ end
19
+
20
+ ###
21
+ # Write a +chunk+ of HTML to the PushParser. Any callback methods
22
+ # that can be called will be called immediately.
23
+ def write chunk, last_chunk = false
24
+ native_write(chunk, last_chunk)
25
+ end
26
+ alias :<< :write
27
+
28
+ ###
29
+ # Finish the parsing. This method is only necessary for
30
+ # Nokogiri::HTML::SAX::Document#end_document to be called.
31
+ def finish
32
+ write '', true
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ # The line below caused a problem on non-GAE rack environment.
3
+ # unless defined?(JRuby::Rack::VERSION) || defined?(AppEngine::ApiProxy)
4
+ #
5
+ # However, simply cutting defined?(JRuby::Rack::VERSION) off resulted in
6
+ # an unable-to-load-nokogiri problem. Thus, now, Nokogiri checks the presense
7
+ # of appengine-rack.jar in $LOAD_PATH. If Nokogiri is on GAE, Nokogiri
8
+ # should skip loading xml jars. This is because those are in WEB-INF/lib and
9
+ # already set in the classpath.
10
+ unless $LOAD_PATH.to_s.include?("appengine-rack")
11
+ require 'stringio'
12
+ require 'isorelax.jar'
13
+ require 'jing.jar'
14
+ require 'nekohtml.jar'
15
+ require 'nekodtd.jar'
16
+ require 'xercesImpl.jar'
17
+ require 'serializer.jar'
18
+ require 'xalan.jar'
19
+ require 'xml-apis.jar'
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ class SyntaxError < ::StandardError
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ require_relative "version/constant"
3
+ require_relative "version/info"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ # The version of Nokogiri you are using
4
+ VERSION = "1.11.0.rc4"
5
+ end
@@ -0,0 +1,182 @@
1
+ # frozen_string_literal: true
2
+ require "singleton"
3
+ require "shellwords"
4
+
5
+ module Nokogiri
6
+ class VersionInfo # :nodoc:
7
+ include Singleton
8
+
9
+ def jruby?
10
+ ::JRUBY_VERSION if ::RUBY_PLATFORM == "java"
11
+ end
12
+
13
+ def engine
14
+ defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "mri"
15
+ end
16
+
17
+ def loaded_libxml_version
18
+ Gem::Version.new(Nokogiri::LIBXML_LOADED_VERSION
19
+ .scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first
20
+ .collect(&:to_i)
21
+ .join("."))
22
+ end
23
+
24
+ def compiled_libxml_version
25
+ Gem::Version.new(Nokogiri::LIBXML_COMPILED_VERSION)
26
+ end
27
+
28
+ def loaded_libxslt_version
29
+ Gem::Version.new(Nokogiri::LIBXSLT_LOADED_VERSION
30
+ .scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first
31
+ .collect(&:to_i)
32
+ .join("."))
33
+ end
34
+
35
+ def compiled_libxslt_version
36
+ Gem::Version.new(Nokogiri::LIBXSLT_COMPILED_VERSION)
37
+ end
38
+
39
+ def libxml2?
40
+ defined?(Nokogiri::LIBXML_COMPILED_VERSION)
41
+ end
42
+
43
+ def libxml2_has_iconv?
44
+ defined?(Nokogiri::LIBXML_ICONV_ENABLED) && Nokogiri::LIBXML_ICONV_ENABLED
45
+ end
46
+
47
+ def libxml2_using_packaged?
48
+ libxml2? && Nokogiri::PACKAGED_LIBRARIES
49
+ end
50
+
51
+ def libxml2_using_system?
52
+ libxml2? && !libxml2_using_packaged?
53
+ end
54
+
55
+ def libxml2_precompiled?
56
+ libxml2_using_packaged? && Nokogiri::PRECOMPILED_LIBRARIES
57
+ end
58
+
59
+ def warnings
60
+ warnings = []
61
+
62
+ if libxml2?
63
+ if compiled_libxml_version != loaded_libxml_version
64
+ warnings << "Nokogiri was built against libxml version #{compiled_libxml_version}, but has dynamically loaded #{loaded_libxml_version}"
65
+ end
66
+
67
+ if compiled_libxslt_version != loaded_libxslt_version
68
+ warnings << "Nokogiri was built against libxslt version #{compiled_libxslt_version}, but has dynamically loaded #{loaded_libxslt_version}"
69
+ end
70
+ end
71
+
72
+ warnings
73
+ end
74
+
75
+ def to_hash
76
+ header_directory = File.expand_path(File.join(File.dirname(__FILE__), "../../../ext/nokogiri"))
77
+ {}.tap do |vi|
78
+ vi["warnings"] = []
79
+ vi["nokogiri"] = {}.tap do |nokogiri|
80
+ nokogiri["version"] = Nokogiri::VERSION
81
+
82
+ unless jruby?
83
+ cppflags = ["-I#{header_directory.shellescape}"]
84
+ if libxml2_using_packaged?
85
+ cppflags << "-I#{File.join(header_directory, "include").shellescape}"
86
+ cppflags << "-I#{File.join(header_directory, "include/libxml2").shellescape}"
87
+ end
88
+ nokogiri["cppflags"] = cppflags
89
+ end
90
+ end
91
+ vi["ruby"] = {}.tap do |ruby|
92
+ ruby["version"] = ::RUBY_VERSION
93
+ ruby["platform"] = ::RUBY_PLATFORM
94
+ ruby["gem_platform"] = ::Gem::Platform.local.to_s
95
+ ruby["description"] = ::RUBY_DESCRIPTION
96
+ ruby["engine"] = engine
97
+ ruby["jruby"] = jruby? if jruby?
98
+ end
99
+
100
+ if libxml2?
101
+ vi["libxml"] = {}.tap do |libxml|
102
+ if libxml2_using_packaged?
103
+ libxml["source"] = "packaged"
104
+ libxml["precompiled"] = libxml2_precompiled?
105
+ libxml["patches"] = Nokogiri::LIBXML2_PATCHES
106
+
107
+ # this is for nokogumbo and shouldn't be forever
108
+ libxml["libxml2_path"] = header_directory
109
+ else
110
+ libxml["source"] = "system"
111
+ end
112
+ libxml["iconv_enabled"] = libxml2_has_iconv?
113
+ libxml["compiled"] = compiled_libxml_version.to_s
114
+ libxml["loaded"] = loaded_libxml_version.to_s
115
+ end
116
+
117
+ vi["libxslt"] = {}.tap do |libxslt|
118
+ if libxml2_using_packaged?
119
+ libxslt["source"] = "packaged"
120
+ libxslt["precompiled"] = libxml2_precompiled?
121
+ libxslt["patches"] = Nokogiri::LIBXSLT_PATCHES
122
+ else
123
+ libxslt["source"] = "system"
124
+ end
125
+ libxslt["compiled"] = compiled_libxslt_version.to_s
126
+ libxslt["loaded"] = loaded_libxslt_version.to_s
127
+ end
128
+
129
+ vi["warnings"] = warnings
130
+ end
131
+
132
+ if defined?(Nokogiri::OTHER_LIBRARY_VERSIONS)
133
+ # see extconf for how this string is assembled: "lib1name:lib1version,lib2name:lib2version"
134
+ vi["other_libraries"] = Hash[*Nokogiri::OTHER_LIBRARY_VERSIONS.split(/[,:]/)]
135
+ elsif jruby?
136
+ vi["other_libraries"] = {}.tap do |ol|
137
+ ol["xerces"] = Nokogiri::XERCES_VERSION
138
+ ol["nekohtml"] = Nokogiri::NEKO_VERSION
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ def to_markdown
145
+ begin
146
+ require "psych"
147
+ rescue LoadError
148
+ end
149
+ require "yaml"
150
+ "# Nokogiri (#{Nokogiri::VERSION})\n" +
151
+ YAML.dump(to_hash).each_line.map { |line| " #{line}" }.join
152
+ end
153
+
154
+ instance.warnings.each do |warning|
155
+ warn "WARNING: #{warning}"
156
+ end
157
+ end
158
+
159
+ def self.uses_libxml?(requirement = nil) # :nodoc:
160
+ return false unless VersionInfo.instance.libxml2?
161
+ return true unless requirement
162
+ Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
163
+ end
164
+
165
+ def self.jruby? # :nodoc:
166
+ VersionInfo.instance.jruby?
167
+ end
168
+
169
+ # Ensure constants used in this file are loaded - see #1896
170
+ if Nokogiri.jruby?
171
+ require "nokogiri/jruby/dependencies"
172
+ end
173
+ begin
174
+ ::RUBY_VERSION =~ /(\d+\.\d+)/
175
+ require "nokogiri/#{Regexp.last_match(1)}/nokogiri"
176
+ rescue LoadError
177
+ require "nokogiri/nokogiri"
178
+ end
179
+
180
+ # More complete version information about libxml
181
+ VERSION_INFO = VersionInfo.instance.to_hash
182
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+ require 'nokogiri/xml/pp'
3
+ require 'nokogiri/xml/parse_options'
4
+ require 'nokogiri/xml/sax'
5
+ require 'nokogiri/xml/searchable'
6
+ require 'nokogiri/xml/node'
7
+ require 'nokogiri/xml/attribute_decl'
8
+ require 'nokogiri/xml/element_decl'
9
+ require 'nokogiri/xml/element_content'
10
+ require 'nokogiri/xml/character_data'
11
+ require 'nokogiri/xml/namespace'
12
+ require 'nokogiri/xml/attr'
13
+ require 'nokogiri/xml/dtd'
14
+ require 'nokogiri/xml/cdata'
15
+ require 'nokogiri/xml/text'
16
+ require 'nokogiri/xml/document'
17
+ require 'nokogiri/xml/document_fragment'
18
+ require 'nokogiri/xml/processing_instruction'
19
+ require 'nokogiri/xml/node_set'
20
+ require 'nokogiri/xml/syntax_error'
21
+ require 'nokogiri/xml/xpath'
22
+ require 'nokogiri/xml/xpath_context'
23
+ require 'nokogiri/xml/builder'
24
+ require 'nokogiri/xml/reader'
25
+ require 'nokogiri/xml/notation'
26
+ require 'nokogiri/xml/entity_decl'
27
+ require 'nokogiri/xml/entity_reference'
28
+ require 'nokogiri/xml/schema'
29
+ require 'nokogiri/xml/relax_ng'
30
+
31
+ module Nokogiri
32
+ class << self
33
+ ###
34
+ # Parse XML. Convenience method for Nokogiri::XML::Document.parse
35
+ def XML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block
36
+ Nokogiri::XML::Document.parse(thing, url, encoding, options, &block)
37
+ end
38
+ end
39
+
40
+ module XML
41
+ # Original C14N 1.0 spec canonicalization
42
+ XML_C14N_1_0 = 0
43
+ # Exclusive C14N 1.0 spec canonicalization
44
+ XML_C14N_EXCLUSIVE_1_0 = 1
45
+ # C14N 1.1 spec canonicalization
46
+ XML_C14N_1_1 = 2
47
+ class << self
48
+ ###
49
+ # Parse an XML document using the Nokogiri::XML::Reader API. See
50
+ # Nokogiri::XML::Reader for mor information
51
+ def Reader string_or_io, url = nil, encoding = nil, options = ParseOptions::STRICT
52
+
53
+ options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
54
+ # Give the options to the user
55
+ yield options if block_given?
56
+
57
+ if string_or_io.respond_to? :read
58
+ return Reader.from_io(string_or_io, url, encoding, options.to_i)
59
+ end
60
+ Reader.from_memory(string_or_io, url, encoding, options.to_i)
61
+ end
62
+
63
+ ###
64
+ # Parse XML. Convenience method for Nokogiri::XML::Document.parse
65
+ def parse thing, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block
66
+ Document.parse(thing, url, encoding, options, &block)
67
+ end
68
+
69
+ ####
70
+ # Parse a fragment from +string+ in to a NodeSet.
71
+ def fragment string
72
+ XML::DocumentFragment.parse(string)
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Nokogiri
3
+ module XML
4
+ class Attr < Node
5
+ alias :value :content
6
+ alias :to_s :content
7
+ alias :content= :value=
8
+
9
+ private
10
+ def inspect_attributes
11
+ [:name, :namespace, :value]
12
+ end
13
+ end
14
+ end
15
+ end