nokogiri 1.3.0-x86-mingw32

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 (256) hide show
  1. data/.autotest +27 -0
  2. data/CHANGELOG.ja.rdoc +233 -0
  3. data/CHANGELOG.rdoc +222 -0
  4. data/Manifest.txt +247 -0
  5. data/README.ja.rdoc +103 -0
  6. data/README.rdoc +117 -0
  7. data/Rakefile +205 -0
  8. data/bin/nokogiri +47 -0
  9. data/ext/nokogiri/extconf.rb +89 -0
  10. data/ext/nokogiri/html_document.c +183 -0
  11. data/ext/nokogiri/html_document.h +10 -0
  12. data/ext/nokogiri/html_element_description.c +272 -0
  13. data/ext/nokogiri/html_element_description.h +10 -0
  14. data/ext/nokogiri/html_entity_lookup.c +30 -0
  15. data/ext/nokogiri/html_entity_lookup.h +8 -0
  16. data/ext/nokogiri/html_sax_parser.c +57 -0
  17. data/ext/nokogiri/html_sax_parser.h +11 -0
  18. data/ext/nokogiri/iconv.dll +0 -0
  19. data/ext/nokogiri/libexslt.dll +0 -0
  20. data/ext/nokogiri/libxml2.dll +0 -0
  21. data/ext/nokogiri/libxslt.dll +0 -0
  22. data/ext/nokogiri/nokogiri.c +81 -0
  23. data/ext/nokogiri/nokogiri.h +149 -0
  24. data/ext/nokogiri/xml_attr.c +92 -0
  25. data/ext/nokogiri/xml_attr.h +9 -0
  26. data/ext/nokogiri/xml_cdata.c +53 -0
  27. data/ext/nokogiri/xml_cdata.h +9 -0
  28. data/ext/nokogiri/xml_comment.c +51 -0
  29. data/ext/nokogiri/xml_comment.h +9 -0
  30. data/ext/nokogiri/xml_document.c +308 -0
  31. data/ext/nokogiri/xml_document.h +21 -0
  32. data/ext/nokogiri/xml_document_fragment.c +48 -0
  33. data/ext/nokogiri/xml_document_fragment.h +10 -0
  34. data/ext/nokogiri/xml_dtd.c +102 -0
  35. data/ext/nokogiri/xml_dtd.h +8 -0
  36. data/ext/nokogiri/xml_entity_reference.c +50 -0
  37. data/ext/nokogiri/xml_entity_reference.h +9 -0
  38. data/ext/nokogiri/xml_io.c +24 -0
  39. data/ext/nokogiri/xml_io.h +10 -0
  40. data/ext/nokogiri/xml_namespace.c +69 -0
  41. data/ext/nokogiri/xml_namespace.h +12 -0
  42. data/ext/nokogiri/xml_node.c +928 -0
  43. data/ext/nokogiri/xml_node.h +14 -0
  44. data/ext/nokogiri/xml_node_set.c +386 -0
  45. data/ext/nokogiri/xml_node_set.h +9 -0
  46. data/ext/nokogiri/xml_processing_instruction.c +54 -0
  47. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  48. data/ext/nokogiri/xml_reader.c +572 -0
  49. data/ext/nokogiri/xml_reader.h +10 -0
  50. data/ext/nokogiri/xml_relax_ng.c +106 -0
  51. data/ext/nokogiri/xml_relax_ng.h +9 -0
  52. data/ext/nokogiri/xml_sax_parser.c +336 -0
  53. data/ext/nokogiri/xml_sax_parser.h +10 -0
  54. data/ext/nokogiri/xml_sax_push_parser.c +86 -0
  55. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  56. data/ext/nokogiri/xml_schema.c +107 -0
  57. data/ext/nokogiri/xml_schema.h +9 -0
  58. data/ext/nokogiri/xml_syntax_error.c +203 -0
  59. data/ext/nokogiri/xml_syntax_error.h +12 -0
  60. data/ext/nokogiri/xml_text.c +47 -0
  61. data/ext/nokogiri/xml_text.h +9 -0
  62. data/ext/nokogiri/xml_xpath.c +53 -0
  63. data/ext/nokogiri/xml_xpath.h +11 -0
  64. data/ext/nokogiri/xml_xpath_context.c +252 -0
  65. data/ext/nokogiri/xml_xpath_context.h +9 -0
  66. data/ext/nokogiri/xslt_stylesheet.c +131 -0
  67. data/ext/nokogiri/xslt_stylesheet.h +9 -0
  68. data/ext/nokogiri/zlib1.dll +0 -0
  69. data/lib/action-nokogiri.rb +36 -0
  70. data/lib/nokogiri.rb +110 -0
  71. data/lib/nokogiri/1.8/nokogiri.so +0 -0
  72. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  73. data/lib/nokogiri/css.rb +25 -0
  74. data/lib/nokogiri/css/generated_parser.rb +748 -0
  75. data/lib/nokogiri/css/generated_tokenizer.rb +144 -0
  76. data/lib/nokogiri/css/node.rb +107 -0
  77. data/lib/nokogiri/css/parser.rb +82 -0
  78. data/lib/nokogiri/css/parser.y +227 -0
  79. data/lib/nokogiri/css/syntax_error.rb +7 -0
  80. data/lib/nokogiri/css/tokenizer.rb +11 -0
  81. data/lib/nokogiri/css/tokenizer.rex +54 -0
  82. data/lib/nokogiri/css/xpath_visitor.rb +172 -0
  83. data/lib/nokogiri/decorators.rb +2 -0
  84. data/lib/nokogiri/decorators/hpricot.rb +3 -0
  85. data/lib/nokogiri/decorators/hpricot/node.rb +56 -0
  86. data/lib/nokogiri/decorators/hpricot/node_set.rb +54 -0
  87. data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +30 -0
  88. data/lib/nokogiri/decorators/slop.rb +33 -0
  89. data/lib/nokogiri/ffi/html/document.rb +37 -0
  90. data/lib/nokogiri/ffi/html/element_description.rb +85 -0
  91. data/lib/nokogiri/ffi/html/entity_lookup.rb +16 -0
  92. data/lib/nokogiri/ffi/html/sax/parser.rb +21 -0
  93. data/lib/nokogiri/ffi/io_callbacks.rb +32 -0
  94. data/lib/nokogiri/ffi/libxml.rb +314 -0
  95. data/lib/nokogiri/ffi/structs/common_node.rb +26 -0
  96. data/lib/nokogiri/ffi/structs/html_elem_desc.rb +24 -0
  97. data/lib/nokogiri/ffi/structs/html_entity_desc.rb +13 -0
  98. data/lib/nokogiri/ffi/structs/xml_alloc.rb +16 -0
  99. data/lib/nokogiri/ffi/structs/xml_attr.rb +19 -0
  100. data/lib/nokogiri/ffi/structs/xml_buffer.rb +16 -0
  101. data/lib/nokogiri/ffi/structs/xml_document.rb +108 -0
  102. data/lib/nokogiri/ffi/structs/xml_dtd.rb +26 -0
  103. data/lib/nokogiri/ffi/structs/xml_node.rb +28 -0
  104. data/lib/nokogiri/ffi/structs/xml_node_set.rb +53 -0
  105. data/lib/nokogiri/ffi/structs/xml_notation.rb +11 -0
  106. data/lib/nokogiri/ffi/structs/xml_ns.rb +15 -0
  107. data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +14 -0
  108. data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +51 -0
  109. data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +14 -0
  110. data/lib/nokogiri/ffi/structs/xml_schema.rb +13 -0
  111. data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +31 -0
  112. data/lib/nokogiri/ffi/structs/xml_text_reader.rb +12 -0
  113. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +37 -0
  114. data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +35 -0
  115. data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +20 -0
  116. data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +13 -0
  117. data/lib/nokogiri/ffi/xml/attr.rb +41 -0
  118. data/lib/nokogiri/ffi/xml/cdata.rb +19 -0
  119. data/lib/nokogiri/ffi/xml/comment.rb +18 -0
  120. data/lib/nokogiri/ffi/xml/document.rb +107 -0
  121. data/lib/nokogiri/ffi/xml/document_fragment.rb +26 -0
  122. data/lib/nokogiri/ffi/xml/dtd.rb +42 -0
  123. data/lib/nokogiri/ffi/xml/entity_reference.rb +19 -0
  124. data/lib/nokogiri/ffi/xml/namespace.rb +38 -0
  125. data/lib/nokogiri/ffi/xml/node.rb +380 -0
  126. data/lib/nokogiri/ffi/xml/node_set.rb +130 -0
  127. data/lib/nokogiri/ffi/xml/processing_instruction.rb +20 -0
  128. data/lib/nokogiri/ffi/xml/reader.rb +217 -0
  129. data/lib/nokogiri/ffi/xml/relax_ng.rb +51 -0
  130. data/lib/nokogiri/ffi/xml/sax/parser.rb +148 -0
  131. data/lib/nokogiri/ffi/xml/sax/push_parser.rb +38 -0
  132. data/lib/nokogiri/ffi/xml/schema.rb +55 -0
  133. data/lib/nokogiri/ffi/xml/syntax_error.rb +76 -0
  134. data/lib/nokogiri/ffi/xml/text.rb +18 -0
  135. data/lib/nokogiri/ffi/xml/xpath.rb +19 -0
  136. data/lib/nokogiri/ffi/xml/xpath_context.rb +135 -0
  137. data/lib/nokogiri/ffi/xslt/stylesheet.rb +47 -0
  138. data/lib/nokogiri/hpricot.rb +62 -0
  139. data/lib/nokogiri/html.rb +34 -0
  140. data/lib/nokogiri/html/builder.rb +35 -0
  141. data/lib/nokogiri/html/document.rb +71 -0
  142. data/lib/nokogiri/html/document_fragment.rb +15 -0
  143. data/lib/nokogiri/html/element_description.rb +23 -0
  144. data/lib/nokogiri/html/entity_lookup.rb +13 -0
  145. data/lib/nokogiri/html/sax/parser.rb +47 -0
  146. data/lib/nokogiri/nokogiri.rb +1 -0
  147. data/lib/nokogiri/syntax_error.rb +4 -0
  148. data/lib/nokogiri/version.rb +29 -0
  149. data/lib/nokogiri/version_warning.rb +11 -0
  150. data/lib/nokogiri/xml.rb +62 -0
  151. data/lib/nokogiri/xml/attr.rb +9 -0
  152. data/lib/nokogiri/xml/builder.rb +254 -0
  153. data/lib/nokogiri/xml/cdata.rb +11 -0
  154. data/lib/nokogiri/xml/document.rb +100 -0
  155. data/lib/nokogiri/xml/document_fragment.rb +49 -0
  156. data/lib/nokogiri/xml/dtd.rb +11 -0
  157. data/lib/nokogiri/xml/entity_declaration.rb +11 -0
  158. data/lib/nokogiri/xml/fragment_handler.rb +55 -0
  159. data/lib/nokogiri/xml/namespace.rb +7 -0
  160. data/lib/nokogiri/xml/node.rb +745 -0
  161. data/lib/nokogiri/xml/node/save_options.rb +42 -0
  162. data/lib/nokogiri/xml/node_set.rb +238 -0
  163. data/lib/nokogiri/xml/notation.rb +6 -0
  164. data/lib/nokogiri/xml/parse_options.rb +80 -0
  165. data/lib/nokogiri/xml/processing_instruction.rb +8 -0
  166. data/lib/nokogiri/xml/reader.rb +66 -0
  167. data/lib/nokogiri/xml/relax_ng.rb +32 -0
  168. data/lib/nokogiri/xml/sax.rb +3 -0
  169. data/lib/nokogiri/xml/sax/document.rb +143 -0
  170. data/lib/nokogiri/xml/sax/parser.rb +101 -0
  171. data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
  172. data/lib/nokogiri/xml/schema.rb +65 -0
  173. data/lib/nokogiri/xml/syntax_error.rb +34 -0
  174. data/lib/nokogiri/xml/xpath.rb +10 -0
  175. data/lib/nokogiri/xml/xpath/syntax_error.rb +8 -0
  176. data/lib/nokogiri/xml/xpath_context.rb +16 -0
  177. data/lib/nokogiri/xslt.rb +48 -0
  178. data/lib/nokogiri/xslt/stylesheet.rb +25 -0
  179. data/lib/xsd/xmlparser/nokogiri.rb +64 -0
  180. data/tasks/test.rb +161 -0
  181. data/test/css/test_nthiness.rb +160 -0
  182. data/test/css/test_parser.rb +277 -0
  183. data/test/css/test_tokenizer.rb +176 -0
  184. data/test/css/test_xpath_visitor.rb +76 -0
  185. data/test/ffi/test_document.rb +35 -0
  186. data/test/files/address_book.rlx +12 -0
  187. data/test/files/address_book.xml +10 -0
  188. data/test/files/dont_hurt_em_why.xml +422 -0
  189. data/test/files/exslt.xml +8 -0
  190. data/test/files/exslt.xslt +35 -0
  191. data/test/files/po.xml +32 -0
  192. data/test/files/po.xsd +66 -0
  193. data/test/files/staff.xml +59 -0
  194. data/test/files/staff.xslt +32 -0
  195. data/test/files/tlm.html +850 -0
  196. data/test/helper.rb +123 -0
  197. data/test/hpricot/files/basic.xhtml +17 -0
  198. data/test/hpricot/files/boingboing.html +2266 -0
  199. data/test/hpricot/files/cy0.html +3653 -0
  200. data/test/hpricot/files/immob.html +400 -0
  201. data/test/hpricot/files/pace_application.html +1320 -0
  202. data/test/hpricot/files/tenderlove.html +16 -0
  203. data/test/hpricot/files/uswebgen.html +220 -0
  204. data/test/hpricot/files/utf8.html +1054 -0
  205. data/test/hpricot/files/week9.html +1723 -0
  206. data/test/hpricot/files/why.xml +19 -0
  207. data/test/hpricot/load_files.rb +11 -0
  208. data/test/hpricot/test_alter.rb +68 -0
  209. data/test/hpricot/test_builder.rb +20 -0
  210. data/test/hpricot/test_parser.rb +426 -0
  211. data/test/hpricot/test_paths.rb +15 -0
  212. data/test/hpricot/test_preserved.rb +77 -0
  213. data/test/hpricot/test_xml.rb +30 -0
  214. data/test/html/sax/test_parser.rb +52 -0
  215. data/test/html/test_builder.rb +156 -0
  216. data/test/html/test_document.rb +361 -0
  217. data/test/html/test_document_encoding.rb +46 -0
  218. data/test/html/test_document_fragment.rb +97 -0
  219. data/test/html/test_element_description.rb +95 -0
  220. data/test/html/test_named_characters.rb +14 -0
  221. data/test/html/test_node.rb +165 -0
  222. data/test/test_convert_xpath.rb +186 -0
  223. data/test/test_css_cache.rb +56 -0
  224. data/test/test_gc.rb +15 -0
  225. data/test/test_memory_leak.rb +77 -0
  226. data/test/test_nokogiri.rb +127 -0
  227. data/test/test_reader.rb +316 -0
  228. data/test/test_xslt_transforms.rb +131 -0
  229. data/test/xml/node/test_save_options.rb +20 -0
  230. data/test/xml/node/test_subclass.rb +44 -0
  231. data/test/xml/sax/test_parser.rb +169 -0
  232. data/test/xml/sax/test_push_parser.rb +92 -0
  233. data/test/xml/test_attr.rb +38 -0
  234. data/test/xml/test_builder.rb +73 -0
  235. data/test/xml/test_cdata.rb +38 -0
  236. data/test/xml/test_comment.rb +23 -0
  237. data/test/xml/test_document.rb +397 -0
  238. data/test/xml/test_document_encoding.rb +26 -0
  239. data/test/xml/test_document_fragment.rb +76 -0
  240. data/test/xml/test_dtd.rb +42 -0
  241. data/test/xml/test_dtd_encoding.rb +31 -0
  242. data/test/xml/test_entity_reference.rb +21 -0
  243. data/test/xml/test_namespace.rb +43 -0
  244. data/test/xml/test_node.rb +808 -0
  245. data/test/xml/test_node_attributes.rb +34 -0
  246. data/test/xml/test_node_encoding.rb +84 -0
  247. data/test/xml/test_node_set.rb +368 -0
  248. data/test/xml/test_parse_options.rb +52 -0
  249. data/test/xml/test_processing_instruction.rb +30 -0
  250. data/test/xml/test_reader_encoding.rb +126 -0
  251. data/test/xml/test_relax_ng.rb +60 -0
  252. data/test/xml/test_schema.rb +65 -0
  253. data/test/xml/test_text.rb +18 -0
  254. data/test/xml/test_unparented_node.rb +381 -0
  255. data/test/xml/test_xpath.rb +106 -0
  256. metadata +409 -0
@@ -0,0 +1,35 @@
1
+ module Nokogiri
2
+ module HTML
3
+ ###
4
+ # Nokogiri HTML builder is used for building HTML documents. It is very
5
+ # similar to the Nokogiri::XML::Builder. In fact, you should go read the
6
+ # documentation for Nokogiri::XML::Builder before reading this
7
+ # documentation.
8
+ #
9
+ # == Synopsis:
10
+ #
11
+ # Create an HTML document with a body that has an onload attribute, and a
12
+ # span tag with a class of "bold" that has content of "Hello world".
13
+ #
14
+ # builder = Nokogiri::HTML::Builder.new do |doc|
15
+ # doc.html {
16
+ # doc.body(:onload => 'some_func();') {
17
+ # doc.span.bold {
18
+ # doc.text "Hello world"
19
+ # }
20
+ # }
21
+ # }
22
+ # end
23
+ # puts builder.to_html
24
+ #
25
+ # The HTML builder inherits from the XML builder, so make sure to read the
26
+ # Nokogiri::XML::Builder documentation.
27
+ class Builder < Nokogiri::XML::Builder
28
+ ###
29
+ # Convert the builder to HTML
30
+ def to_html
31
+ @doc.to_html
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,71 @@
1
+ module Nokogiri
2
+ module HTML
3
+ class Document < Nokogiri::XML::Document
4
+
5
+ def initialize *args
6
+ super
7
+ end
8
+
9
+ ####
10
+ # Serialize this Document with +encoding+ using +options+
11
+ def serialize *args
12
+ if args.first && !args.first.is_a?(Hash)
13
+ $stderr.puts(<<-eowarn)
14
+ #{self.class}#serialize(encoding, save_opts) is deprecated and will be removed in
15
+ Nokogiri version 1.4.0 *or* after June 1 2009.
16
+ You called serialize from here:
17
+
18
+ #{caller.join("\n")}
19
+
20
+ Please change to #{self.class}#serialize(:encoding => enc, :save_with => opts)
21
+ eowarn
22
+ end
23
+
24
+ options = args.first.is_a?(Hash) ? args.shift : {
25
+ :encoding => args[0],
26
+ :save_with => args[1] || XML::Node::SaveOptions::FORMAT |
27
+ XML::Node::SaveOptions::AS_HTML |
28
+ XML::Node::SaveOptions::NO_DECLARATION |
29
+ XML::Node::SaveOptions::NO_EMPTY_TAGS
30
+ }
31
+ super(options)
32
+ end
33
+
34
+ ####
35
+ # Create a Nokogiri::XML::DocumentFragment from +tags+
36
+ def fragment tags
37
+ DocumentFragment.new(self, tags)
38
+ end
39
+
40
+ class << self
41
+ ###
42
+ # Parse HTML. +thing+ may be a String, or any object that
43
+ # responds to _read_ and _close_ such as an IO, or StringIO.
44
+ # +url+ is resource where this document is located. +encoding+ is the
45
+ # encoding that should be used when processing the document. +options+
46
+ # is a number that sets options in the parser, such as
47
+ # Nokogiri::XML::PARSE_RECOVER. See the constants in
48
+ # Nokogiri::XML.
49
+ def parse string_or_io, url = nil, encoding = nil, options = 2145, &block
50
+
51
+ options = Nokogiri::XML::ParseOptions.new(options) if Fixnum === options
52
+ # Give the options to the user
53
+ yield options if block_given?
54
+
55
+ if string_or_io.respond_to?(:encoding)
56
+ encoding ||= string_or_io.encoding.name
57
+ end
58
+
59
+ if string_or_io.respond_to?(:read)
60
+ url ||= string_or_io.respond_to?(:path) ? string_or_io.path : nil
61
+ return self.read_io(string_or_io, url, encoding, options.to_i)
62
+ end
63
+
64
+ return self.new if(string_or_io.length == 0)
65
+ self.read_memory(string_or_io, url, encoding, options.to_i)
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,15 @@
1
+ module Nokogiri
2
+ module HTML
3
+ class DocumentFragment < Nokogiri::XML::DocumentFragment
4
+
5
+ class << self
6
+ ####
7
+ # Create a Nokogiri::XML::DocumentFragment from +tags+
8
+ def parse tags
9
+ HTML::DocumentFragment.new(HTML::Document.new, tags)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Nokogiri
2
+ module HTML
3
+ class ElementDescription
4
+ ###
5
+ # Is this element a block element?
6
+ def block?
7
+ !inline?
8
+ end
9
+
10
+ ###
11
+ # Convert this description to a string
12
+ def to_s
13
+ "#{name}: #{description}"
14
+ end
15
+
16
+ ###
17
+ # Inspection information
18
+ def inspect
19
+ "#<#{self.class.name}: #{name} #{description}>"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module Nokogiri
2
+ module HTML
3
+ class EntityDescription < Struct.new(:value, :name, :description); end
4
+
5
+ class EntityLookup
6
+ ###
7
+ # Look up entity with +name+
8
+ def [] name
9
+ (val = get(name)) && val.value
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ module Nokogiri
2
+ module HTML
3
+ ###
4
+ # Nokogiri lets you write a SAX parser to process HTML but get HTML
5
+ # correction features.
6
+ #
7
+ # See Nokogiri::HTML::SAX::Parser for a basic example of using a
8
+ # SAX parser with HTML.
9
+ #
10
+ # For more information on SAX parsers, see Nokogiri::XML::SAX
11
+ module SAX
12
+ ###
13
+ # This class lets you perform SAX style parsing on HTML with HTML
14
+ # error correction.
15
+ #
16
+ # Here is a basic usage example:
17
+ #
18
+ # class MyDoc < Nokogiri::XML::SAX::Document
19
+ # def start_element name, attributes = []
20
+ # puts "found a #{name}"
21
+ # end
22
+ # end
23
+ #
24
+ # parser = Nokogiri::HTML::SAX::Parser.new(MyDoc.new)
25
+ # parser.parse(File.read(ARGV[0], 'rb'))
26
+ #
27
+ # For more information on SAX parsers, see Nokogiri::XML::SAX
28
+ class Parser < Nokogiri::XML::SAX::Parser
29
+ ###
30
+ # Parse html stored in +data+ using +encoding+
31
+ def parse_memory data, encoding = 'UTF-8'
32
+ raise ArgumentError unless data
33
+ native_parse_memory(data, encoding)
34
+ end
35
+
36
+ ###
37
+ # Parse a file with +filename+
38
+ def parse_file filename, encoding = 'UTF-8'
39
+ raise ArgumentError unless filename
40
+ raise Errno::ENOENT unless File.exists?(filename)
41
+ raise Errno::EISDIR if File.directory?(filename)
42
+ native_parse_file filename, encoding
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1 @@
1
+ require "nokogiri/#{RUBY_VERSION.sub(/\.\d+$/, '')}/nokogiri"
@@ -0,0 +1,4 @@
1
+ module Nokogiri
2
+ class SyntaxError < ::StandardError
3
+ end
4
+ end
@@ -0,0 +1,29 @@
1
+ module Nokogiri
2
+ # The version of Nokogiri you are using
3
+ VERSION = '1.3.0'
4
+
5
+ # More complete version information about libxml
6
+ VERSION_INFO = {}
7
+ VERSION_INFO['warnings'] = []
8
+ VERSION_INFO['nokogiri'] = VERSION
9
+ if defined?(LIBXML_VERSION) && ! defined?(FFI)
10
+ VERSION_INFO['libxml'] = {}
11
+ VERSION_INFO['libxml']['binding'] = 'extension'
12
+ VERSION_INFO['libxml']['compiled'] = LIBXML_VERSION
13
+ VERSION_INFO['libxml']['loaded'] = LIBXML_PARSER_VERSION.scan(/^(.*)(..)(..)$/).first.collect{|j|j.to_i}.join(".")
14
+
15
+ if VERSION_INFO['libxml']['compiled'] != VERSION_INFO['libxml']['loaded']
16
+ warning = "Nokogiri was built against LibXML version #{VERSION_INFO['libxml']['compiled']}, but has dynamically loaded #{VERSION_INFO['libxml']['loaded']}"
17
+ VERSION_INFO['warnings'] << warning
18
+ warn "WARNING: #{warning}"
19
+ end
20
+ end
21
+
22
+ def self.ffi? # :nodoc:
23
+ Nokogiri::VERSION_INFO['libxml']['binding'] == 'ffi'
24
+ end
25
+
26
+ def self.is_2_6_16? # :nodoc:
27
+ Nokogiri::VERSION_INFO['libxml']['loaded'] <= '2.6.16'
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module Nokogiri
2
+ if self.is_2_6_16? && !defined?(I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2)
3
+ warn <<-eom
4
+ HI. You're using libxml2 version 2.6.16 which is over 4 years old and has
5
+ plenty of bugs. We suggest that for maximum HTML/XML parsing pleasure, you
6
+ upgrade your version of libxml2 and re-install nokogiri. If you like using
7
+ libxml2 version 2.6.16, but don't like this warning, please define the constant
8
+ I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2 before requring nokogiri.
9
+ eom
10
+ end
11
+ end
@@ -0,0 +1,62 @@
1
+ require 'nokogiri/xml/parse_options'
2
+ require 'nokogiri/xml/sax'
3
+ require 'nokogiri/xml/fragment_handler'
4
+ require 'nokogiri/xml/node'
5
+ require 'nokogiri/xml/namespace'
6
+ require 'nokogiri/xml/attr'
7
+ require 'nokogiri/xml/dtd'
8
+ require 'nokogiri/xml/cdata'
9
+ require 'nokogiri/xml/document'
10
+ require 'nokogiri/xml/document_fragment'
11
+ require 'nokogiri/xml/processing_instruction'
12
+ require 'nokogiri/xml/node_set'
13
+ require 'nokogiri/xml/syntax_error'
14
+ require 'nokogiri/xml/xpath'
15
+ require 'nokogiri/xml/xpath_context'
16
+ require 'nokogiri/xml/builder'
17
+ require 'nokogiri/xml/reader'
18
+ require 'nokogiri/xml/notation'
19
+ require 'nokogiri/xml/entity_declaration'
20
+ require 'nokogiri/xml/schema'
21
+ require 'nokogiri/xml/relax_ng'
22
+
23
+ module Nokogiri
24
+ class << self
25
+ ###
26
+ # Parse XML. Convenience method for Nokogiri::XML::Document.parse
27
+ def XML thing, url = nil, encoding = nil, options = 1, &block
28
+ Nokogiri::XML::Document.parse(thing, url, encoding, options, &block)
29
+ end
30
+ end
31
+
32
+ module XML
33
+ class << self
34
+ ###
35
+ # Parse an XML document using the Nokogiri::XML::Reader API. See
36
+ # Nokogiri::XML::Reader for mor information
37
+ def Reader string_or_io, url = nil, encoding = nil, options = 0
38
+
39
+ options = Nokogiri::XML::ParseOptions.new(options) if Fixnum === options
40
+ # Give the options to the user
41
+ yield options if block_given?
42
+
43
+ if string_or_io.respond_to? :read
44
+ return Reader.from_io(string_or_io, url, encoding, options.to_i)
45
+ end
46
+ Reader.from_memory(string_or_io, url, encoding, options.to_i)
47
+ end
48
+
49
+ ###
50
+ # Parse XML. Convenience method for Nokogiri::XML::Document.parse
51
+ def parse thing, url = nil, encoding = nil, options = 1, &block
52
+ Document.parse(thing, url, encoding, options, &block)
53
+ end
54
+
55
+ ####
56
+ # Parse a fragment from +string+ in to a NodeSet.
57
+ def fragment string
58
+ XML::DocumentFragment.parse(string)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,9 @@
1
+ module Nokogiri
2
+ module XML
3
+ class Attr < Node
4
+ alias :value :content
5
+ alias :to_s :content
6
+ alias :content= :value=
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,254 @@
1
+ module Nokogiri
2
+ module XML
3
+ ###
4
+ # Nokogiri builder can be used for building XML and HTML documents.
5
+ #
6
+ # == Synopsis:
7
+ #
8
+ # builder = Nokogiri::XML::Builder.new do |xml|
9
+ # xml.root {
10
+ # xml.products {
11
+ # xml.widget {
12
+ # xml.id_ "10"
13
+ # xml.name "Awesome widget"
14
+ # }
15
+ # }
16
+ # }
17
+ # end
18
+ # puts builder.to_xml
19
+ #
20
+ # === Builder scope
21
+ #
22
+ # The builder allows two forms. When the builder is supplied with a block
23
+ # that has a parameter, the outside scope is maintained. This means you
24
+ # can access variables that are outside your builder. If you don't need
25
+ # outside scope, you can use the builder without the "xml" prefix like
26
+ # this:
27
+ #
28
+ # builder = Nokogiri::XML::Builder.new do
29
+ # root {
30
+ # products {
31
+ # widget {
32
+ # id_ "10"
33
+ # name "Awesome widget"
34
+ # }
35
+ # }
36
+ # }
37
+ # end
38
+ #
39
+ # == Special Tags
40
+ #
41
+ # The builder works by taking advantage of method_missing. Unfortunately
42
+ # some methods are defined in ruby that are difficult or dangerous to
43
+ # remove. You may want to create tags with the name "type", "class", and
44
+ # "id" for example. In that case, you can use an underscore to
45
+ # disambiguate your tag name from the method call.
46
+ #
47
+ # Here is an example of using the underscore to disambiguate tag names from
48
+ # ruby methods:
49
+ #
50
+ # @objects = [Object.new, Object.new, Object.new]
51
+ #
52
+ # builder = Nokogiri::XML::Builder.new do |xml|
53
+ # xml.root {
54
+ # xml.objects {
55
+ # @objects.each do |o|
56
+ # xml.object {
57
+ # xml.type_ o.type
58
+ # xml.class_ o.class.name
59
+ # xml.id_ o.id
60
+ # }
61
+ # end
62
+ # }
63
+ # }
64
+ # end
65
+ # puts builder.to_xml
66
+ #
67
+ # The underscore may be used with any tag name, and the last underscore
68
+ # will just be removed.
69
+ #
70
+ # == Tag Attributes
71
+ #
72
+ # Tag attributes may be supplied as method arguments. Here is our
73
+ # previous example, but using attributes rather than tags:
74
+ #
75
+ # @objects = [Object.new, Object.new, Object.new]
76
+ #
77
+ # builder = Nokogiri::XML::Builder.new do |xml|
78
+ # xml.root {
79
+ # xml.objects {
80
+ # @objects.each do |o|
81
+ # xml.object(:type => o.type, :class => o.class, :id => o.id)
82
+ # end
83
+ # }
84
+ # }
85
+ # end
86
+ # puts builder.to_xml
87
+ #
88
+ # === Tag Attribute Short Cuts
89
+ #
90
+ # A couple attribute short cuts are available when building tags. The
91
+ # short cuts are available by special method calls when building a tag.
92
+ #
93
+ # This example builds an "object" tag with the class attribute "classy"
94
+ # and the id of "thing":
95
+ #
96
+ # builder = Nokogiri::XML::Builder.new do |xml|
97
+ # xml.root {
98
+ # xml.objects {
99
+ # xml.object.classy.thing!
100
+ # }
101
+ # }
102
+ # end
103
+ # puts builder.to_xml
104
+ #
105
+ # All other options are still supported with this syntax, including
106
+ # blocks and extra tag attributes.
107
+ class Builder
108
+ # The current Document object being built
109
+ attr_accessor :doc
110
+
111
+ # The parent of the current node being built
112
+ attr_accessor :parent
113
+
114
+ # A context object for use when the block has no arguments
115
+ attr_accessor :context
116
+
117
+ attr_accessor :arity # :nodoc:
118
+
119
+ ###
120
+ # Create a new Builder object. +options+ are sent to the top level
121
+ # Document that is being built.
122
+ #
123
+ # Building a document with a particular encoding for example:
124
+ #
125
+ # Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
126
+ # ...
127
+ # end
128
+ def initialize options = {}, &block
129
+ namespace = self.class.name.split('::')
130
+ namespace[-1] = 'Document'
131
+ @doc = eval(namespace.join('::')).new
132
+ @parent = @doc
133
+ @context = nil
134
+ @arity = nil
135
+
136
+ options.each do |k,v|
137
+ @doc.send(:"#{k}=", v)
138
+ end
139
+
140
+ return unless block_given?
141
+
142
+ @arity = block.arity
143
+ if @arity <= 0
144
+ @context = eval('self', block.binding)
145
+ instance_eval(&block)
146
+ else
147
+ yield self
148
+ end
149
+
150
+ @parent = @doc
151
+ end
152
+
153
+ ###
154
+ # Create a Text Node with content of +string+
155
+ def text string
156
+ node = Nokogiri::XML::Text.new(string.to_s, @doc)
157
+ insert(node)
158
+ end
159
+
160
+ ###
161
+ # Create a CDATA Node with content of +string+
162
+ def cdata string
163
+ node = Nokogiri::XML::CDATA.new(@doc, string.to_s)
164
+ insert(node)
165
+ end
166
+
167
+ ###
168
+ # Convert this Builder object to XML
169
+ def to_xml
170
+ @doc.to_xml
171
+ end
172
+
173
+ def method_missing method, *args, &block # :nodoc:
174
+ if @context && @context.respond_to?(method)
175
+ @context.send(method, *args, &block)
176
+ else
177
+ node = Nokogiri::XML::Node.new(method.to_s.sub(/[_!]$/, ''), @doc) { |n|
178
+ args.each do |arg|
179
+ case arg
180
+ when Hash
181
+ arg.each { |k,v| n[k.to_s] = v.to_s }
182
+ else
183
+ n.content = arg
184
+ end
185
+ end
186
+ }
187
+ insert(node, &block)
188
+ end
189
+ end
190
+
191
+ private
192
+ ###
193
+ # Insert +node+ as a child of the current Node
194
+ def insert(node, &block)
195
+ node.parent = @parent
196
+ if block_given?
197
+ @parent = node
198
+ @arity ||= block.arity
199
+ if @arity <= 0
200
+ instance_eval(&block)
201
+ else
202
+ block.call(self)
203
+ end
204
+ @parent = node.parent
205
+ end
206
+ NodeBuilder.new(node, self)
207
+ end
208
+
209
+ class NodeBuilder # :nodoc:
210
+ def initialize(node, doc_builder)
211
+ @node = node
212
+ @doc_builder = doc_builder
213
+ end
214
+
215
+ def []= k, v
216
+ @node[k] = v
217
+ end
218
+
219
+ def [] k
220
+ @node[k]
221
+ end
222
+
223
+ def method_missing(method, *args, &block)
224
+ opts = args.last.is_a?(Hash) ? args.pop : {}
225
+ case method.to_s
226
+ when /^(.*)!$/
227
+ @node['id'] = $1
228
+ @node.content = args.first if args.first
229
+ when /^(.*)=/
230
+ @node[$1] = args.first
231
+ else
232
+ @node['class'] =
233
+ ((@node['class'] || '').split(/\s/) + [method.to_s]).join(' ')
234
+ @node.content = args.first if args.first
235
+ end
236
+
237
+ # Assign any extra options
238
+ opts.each do |k,v|
239
+ @node[k.to_s] = ((@node[k.to_s] || '').split(/\s/) + [v]).join(' ')
240
+ end
241
+
242
+ if block_given?
243
+ old_parent = @doc_builder.parent
244
+ @doc_builder.parent = @node
245
+ value = @doc_builder.instance_eval(&block)
246
+ @doc_builder.parent = old_parent
247
+ return value
248
+ end
249
+ self
250
+ end
251
+ end
252
+ end
253
+ end
254
+ end