nokogiri 1.4.3.1-java → 1.5.0-java

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.
Files changed (231) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGELOG.ja.rdoc +113 -0
  3. data/CHANGELOG.rdoc +113 -1
  4. data/Manifest.txt +72 -68
  5. data/README.ja.rdoc +4 -4
  6. data/README.rdoc +31 -7
  7. data/Rakefile +110 -132
  8. data/bin/nokogiri +7 -3
  9. data/ext/java/nokogiri/EncodingHandler.java +124 -0
  10. data/ext/java/nokogiri/HtmlDocument.java +119 -0
  11. data/ext/java/nokogiri/HtmlElementDescription.java +145 -0
  12. data/ext/java/nokogiri/HtmlEntityLookup.java +79 -0
  13. data/ext/java/nokogiri/HtmlSaxParserContext.java +259 -0
  14. data/ext/java/nokogiri/NokogiriService.java +590 -0
  15. data/ext/java/nokogiri/XmlAttr.java +180 -0
  16. data/ext/java/nokogiri/XmlAttributeDecl.java +130 -0
  17. data/ext/java/nokogiri/XmlCdata.java +84 -0
  18. data/ext/java/nokogiri/XmlComment.java +86 -0
  19. data/ext/java/nokogiri/XmlDocument.java +519 -0
  20. data/ext/java/nokogiri/XmlDocumentFragment.java +223 -0
  21. data/ext/java/nokogiri/XmlDtd.java +469 -0
  22. data/ext/java/nokogiri/XmlElement.java +195 -0
  23. data/ext/java/nokogiri/XmlElementContent.java +382 -0
  24. data/ext/java/nokogiri/XmlElementDecl.java +152 -0
  25. data/ext/java/nokogiri/XmlEntityDecl.java +162 -0
  26. data/ext/java/nokogiri/XmlEntityReference.java +97 -0
  27. data/ext/java/nokogiri/XmlNamespace.java +183 -0
  28. data/ext/java/nokogiri/XmlNode.java +1378 -0
  29. data/ext/java/nokogiri/XmlNodeSet.java +267 -0
  30. data/ext/java/nokogiri/XmlProcessingInstruction.java +99 -0
  31. data/ext/java/nokogiri/XmlReader.java +408 -0
  32. data/ext/java/nokogiri/XmlRelaxng.java +144 -0
  33. data/ext/java/nokogiri/XmlSaxParserContext.java +367 -0
  34. data/ext/java/nokogiri/XmlSaxPushParser.java +184 -0
  35. data/ext/java/nokogiri/XmlSchema.java +324 -0
  36. data/ext/java/nokogiri/XmlSyntaxError.java +119 -0
  37. data/ext/java/nokogiri/XmlText.java +119 -0
  38. data/ext/java/nokogiri/XmlXpathContext.java +199 -0
  39. data/ext/java/nokogiri/XsltStylesheet.java +197 -0
  40. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +204 -0
  41. data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +73 -0
  42. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +86 -0
  43. data/ext/java/nokogiri/internals/NokogiriHandler.java +327 -0
  44. data/ext/java/nokogiri/internals/NokogiriHelpers.java +639 -0
  45. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +167 -0
  46. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +130 -0
  47. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +74 -0
  48. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +121 -0
  49. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +79 -0
  50. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +141 -0
  51. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +73 -0
  52. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +67 -0
  53. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +86 -0
  54. data/ext/java/nokogiri/internals/ParserContext.java +276 -0
  55. data/ext/java/nokogiri/internals/PushInputStream.java +411 -0
  56. data/ext/java/nokogiri/internals/ReaderNode.java +531 -0
  57. data/ext/java/nokogiri/internals/SaveContextVisitor.java +567 -0
  58. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +76 -0
  59. data/ext/java/nokogiri/internals/XmlDeclHandler.java +42 -0
  60. data/ext/java/nokogiri/internals/XmlDomParser.java +76 -0
  61. data/ext/java/nokogiri/internals/XmlDomParserContext.java +244 -0
  62. data/ext/java/nokogiri/internals/XmlSaxParser.java +65 -0
  63. data/ext/java/nokogiri/internals/XsltExtensionFunction.java +72 -0
  64. data/ext/nokogiri/depend +358 -32
  65. data/ext/nokogiri/extconf.rb +10 -6
  66. data/ext/nokogiri/nokogiri.c +23 -3
  67. data/ext/nokogiri/nokogiri.h +7 -2
  68. data/ext/nokogiri/xml_document.c +9 -0
  69. data/ext/nokogiri/xml_dtd.c +2 -2
  70. data/ext/nokogiri/xml_io.c +32 -7
  71. data/ext/nokogiri/xml_node.c +45 -25
  72. data/ext/nokogiri/xml_node_set.c +1 -1
  73. data/ext/nokogiri/xml_relax_ng.c +0 -7
  74. data/ext/nokogiri/xml_sax_parser.c +14 -7
  75. data/ext/nokogiri/xml_sax_parser_context.c +40 -0
  76. data/ext/nokogiri/xml_xpath_context.c +33 -2
  77. data/ext/nokogiri/xslt_stylesheet.c +128 -6
  78. data/lib/isorelax.jar +0 -0
  79. data/lib/jing.jar +0 -0
  80. data/lib/nekodtd.jar +0 -0
  81. data/lib/nekohtml.jar +0 -0
  82. data/lib/nokogiri/css/parser.rb +665 -70
  83. data/lib/nokogiri/css/parser.y +3 -1
  84. data/lib/nokogiri/css/parser_extras.rb +91 -0
  85. data/lib/nokogiri/css/tokenizer.rb +148 -3
  86. data/lib/nokogiri/css/tokenizer.rex +1 -1
  87. data/lib/nokogiri/css/xpath_visitor.rb +15 -7
  88. data/lib/nokogiri/css.rb +5 -3
  89. data/lib/nokogiri/decorators/slop.rb +5 -3
  90. data/lib/nokogiri/html/document.rb +142 -19
  91. data/lib/nokogiri/html/document_fragment.rb +19 -17
  92. data/lib/nokogiri/html/element_description_defaults.rb +671 -0
  93. data/lib/nokogiri/html/sax/parser.rb +6 -2
  94. data/lib/nokogiri/html.rb +1 -0
  95. data/lib/nokogiri/nokogiri.jar +0 -0
  96. data/lib/nokogiri/version.rb +76 -26
  97. data/lib/nokogiri/xml/attribute_decl.rb +1 -1
  98. data/lib/nokogiri/xml/builder.rb +7 -0
  99. data/lib/nokogiri/xml/document.rb +43 -2
  100. data/lib/nokogiri/xml/document_fragment.rb +16 -2
  101. data/lib/nokogiri/xml/dtd.rb +12 -1
  102. data/lib/nokogiri/xml/element_decl.rb +1 -1
  103. data/lib/nokogiri/xml/entity_decl.rb +1 -1
  104. data/lib/nokogiri/xml/node/save_options.rb +20 -1
  105. data/lib/nokogiri/xml/node.rb +198 -78
  106. data/lib/nokogiri/xml/node_set.rb +10 -3
  107. data/lib/nokogiri/xml/parse_options.rb +8 -0
  108. data/lib/nokogiri/xml/reader.rb +42 -6
  109. data/lib/nokogiri/xml/sax/document.rb +4 -2
  110. data/lib/nokogiri/xml/schema.rb +7 -1
  111. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  112. data/lib/nokogiri/xslt.rb +9 -5
  113. data/lib/nokogiri.rb +19 -25
  114. data/lib/xercesImpl.jar +0 -0
  115. data/nokogiri_help_responses.md +40 -0
  116. data/tasks/cross_compile.rb +130 -136
  117. data/tasks/nokogiri.org.rb +18 -0
  118. data/tasks/test.rb +2 -2
  119. data/test/css/test_parser.rb +29 -18
  120. data/test/css/test_tokenizer.rb +8 -0
  121. data/test/decorators/test_slop.rb +16 -0
  122. data/test/files/encoding.html +82 -0
  123. data/test/files/encoding.xhtml +84 -0
  124. data/test/files/metacharset.html +10 -0
  125. data/test/files/noencoding.html +47 -0
  126. data/test/helper.rb +5 -1
  127. data/test/html/sax/test_parser.rb +65 -3
  128. data/test/html/test_document.rb +75 -1
  129. data/test/html/test_document_encoding.rb +61 -0
  130. data/test/html/test_document_fragment.rb +50 -5
  131. data/test/html/test_element_description.rb +4 -2
  132. data/test/html/test_node.rb +9 -0
  133. data/test/test_memory_leak.rb +20 -35
  134. data/test/test_nokogiri.rb +14 -20
  135. data/test/test_reader.rb +23 -6
  136. data/test/test_xslt_transforms.rb +6 -2
  137. data/test/xml/node/test_save_options.rb +10 -2
  138. data/test/xml/sax/test_parser.rb +39 -8
  139. data/test/xml/sax/test_parser_context.rb +50 -0
  140. data/test/xml/sax/test_push_parser.rb +18 -1
  141. data/test/xml/test_attribute_decl.rb +7 -3
  142. data/test/xml/test_builder.rb +17 -0
  143. data/test/xml/test_document.rb +34 -5
  144. data/test/xml/test_document_fragment.rb +14 -2
  145. data/test/xml/test_dtd.rb +28 -3
  146. data/test/xml/test_element_content.rb +1 -1
  147. data/test/xml/test_element_decl.rb +1 -1
  148. data/test/xml/test_entity_decl.rb +12 -10
  149. data/test/xml/test_namespace.rb +7 -5
  150. data/test/xml/test_node.rb +65 -13
  151. data/test/xml/test_node_reparenting.rb +72 -31
  152. data/test/xml/test_node_set.rb +57 -0
  153. data/test/xml/test_schema.rb +5 -0
  154. data/test/xml/test_xpath.rb +32 -0
  155. data/test/xslt/test_custom_functions.rb +94 -0
  156. data/test/xslt/test_exception_handling.rb +37 -0
  157. metadata +512 -517
  158. data/deps.rip +0 -5
  159. data/ext/nokogiri/libcharset-1.dll +0 -0
  160. data/ext/nokogiri/libexslt.dll +0 -0
  161. data/ext/nokogiri/libiconv-2.dll +0 -0
  162. data/ext/nokogiri/libxml2.dll +0 -0
  163. data/ext/nokogiri/libxslt.dll +0 -0
  164. data/ext/nokogiri/zlib1.dll +0 -0
  165. data/lib/nokogiri/css/generated_parser.rb +0 -676
  166. data/lib/nokogiri/css/generated_tokenizer.rb +0 -146
  167. data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
  168. data/lib/nokogiri/ffi/html/document.rb +0 -28
  169. data/lib/nokogiri/ffi/html/element_description.rb +0 -81
  170. data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
  171. data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
  172. data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
  173. data/lib/nokogiri/ffi/libxml.rb +0 -411
  174. data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
  175. data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
  176. data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
  177. data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
  178. data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -19
  179. data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
  180. data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
  181. data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
  182. data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
  183. data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
  184. data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
  185. data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
  186. data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
  187. data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
  188. data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
  189. data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
  190. data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
  191. data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
  192. data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -19
  193. data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
  194. data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
  195. data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
  196. data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
  197. data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
  198. data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
  199. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
  200. data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
  201. data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
  202. data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
  203. data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
  204. data/lib/nokogiri/ffi/xml/attr.rb +0 -41
  205. data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
  206. data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
  207. data/lib/nokogiri/ffi/xml/comment.rb +0 -18
  208. data/lib/nokogiri/ffi/xml/document.rb +0 -166
  209. data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
  210. data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
  211. data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
  212. data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
  213. data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
  214. data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
  215. data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
  216. data/lib/nokogiri/ffi/xml/node.rb +0 -554
  217. data/lib/nokogiri/ffi/xml/node_set.rb +0 -149
  218. data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
  219. data/lib/nokogiri/ffi/xml/reader.rb +0 -236
  220. data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
  221. data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -135
  222. data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -67
  223. data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
  224. data/lib/nokogiri/ffi/xml/schema.rb +0 -109
  225. data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
  226. data/lib/nokogiri/ffi/xml/text.rb +0 -18
  227. data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
  228. data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -148
  229. data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -53
  230. data/lib/nokogiri/version_warning.rb +0 -14
  231. data/test/ffi/test_document.rb +0 -35
@@ -6,7 +6,7 @@ module Nokogiri
6
6
  # an XML::Document with a Stylesheet:
7
7
  #
8
8
  # doc = Nokogiri::XML(File.read('some_file.xml'))
9
- # xslt = Nokogir::XSLT(File.read('some_transformer.xslt'))
9
+ # xslt = Nokogiri::XSLT(File.read('some_transformer.xslt'))
10
10
  #
11
11
  # puts xslt.transform(doc)
12
12
  #
data/lib/nokogiri/xslt.rb CHANGED
@@ -9,8 +9,8 @@ module Nokogiri
9
9
  #
10
10
  # xslt = Nokogiri::XSLT(File.read(ARGV[0]))
11
11
  #
12
- def XSLT stylesheet
13
- XSLT.parse(stylesheet)
12
+ def XSLT stylesheet, modules = {}
13
+ XSLT.parse(stylesheet, modules)
14
14
  end
15
15
  end
16
16
 
@@ -20,11 +20,15 @@ module Nokogiri
20
20
  module XSLT
21
21
  class << self
22
22
  ###
23
- # Parse the stylesheet in +string+
24
- def parse string
23
+ # Parse the stylesheet in +string+, register any +modules+
24
+ def parse string, modules = {}
25
+ modules.each do |url, klass|
26
+ XSLT.register url, klass
27
+ end
28
+
25
29
  Stylesheet.parse_stylesheet_doc(XML.parse(string))
26
30
  end
27
-
31
+
28
32
  ###
29
33
  # Quote parameters in +params+ for stylesheet safety
30
34
  def quote_params params
data/lib/nokogiri.rb CHANGED
@@ -6,32 +6,26 @@ ENV['PATH'] = [File.expand_path(
6
6
  File.join(File.dirname(__FILE__), "..", "ext", "nokogiri")
7
7
  ), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw)/i
8
8
 
9
- if ENV['NOKOGIRI_FFI'] || RUBY_PLATFORM =~ /java/
10
- require 'ffi'
11
- require 'nokogiri/ffi/libxml'
12
- else
13
- require 'nokogiri/nokogiri'
9
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
10
+ # The line below caused a problem on non-GAE rack environment.
11
+ # unless defined?(JRuby::Rack::VERSION) || defined?(AppEngine::ApiProxy)
12
+ #
13
+ # However, simply cutting defined?(JRuby::Rack::VERSION) off resulted in
14
+ # an unable-to-load-nokogiri problem. Thus, now, Nokogiri checks the presense
15
+ # of appengine-rack.jar in $LOAD_PATH. If Nokogiri is on GAE, Nokogiri
16
+ # should skip loading xml jars. This is because those are in WEB-INF/lib and
17
+ # already set in the classpath.
18
+ unless $LOAD_PATH.to_s.include?("appengine-rack")
19
+ require 'isorelax.jar'
20
+ require 'jing.jar'
21
+ require 'nekohtml.jar'
22
+ require 'nekodtd.jar'
23
+ require 'xercesImpl.jar'
24
+ end
14
25
  end
15
26
 
16
- warn(<<-eowarn) if '1.8.6' == RUBY_VERSION && $VERBOSE
17
- !!! DEPRECATION WARNING !!!
18
- Hey Champ! I see you're using Ruby 1.8.6! While I applaud you for sticking to
19
- your guns and using The One True Ruby, I have to let you know that we're going
20
- to stop supporting 1.8.6. I know, it's sad. But, we just don't have time to
21
- support every version of Ruby out there. Whether we like it or not, time moves
22
- forward and so does our software.
23
-
24
- On August 1, 2010, we will no longer support Ruby 1.8.6. If nokogiri happens to
25
- work on 1.8.6 after that date, then great! We will hownever, no longer test,
26
- use, or endorse 1.8.6 as a supported platform.
27
-
28
- Thanks,
29
-
30
- Team Nokogiri
31
- eowarn
32
-
27
+ require 'nokogiri/nokogiri'
33
28
  require 'nokogiri/version'
34
- require 'nokogiri/version_warning'
35
29
  require 'nokogiri/syntax_error'
36
30
  require 'nokogiri/xml'
37
31
  require 'nokogiri/xslt'
@@ -73,13 +67,13 @@ module Nokogiri
73
67
  doc =
74
68
  if string.respond_to?(:read) ||
75
69
  string =~ /^\s*<[^Hh>]*html/i # Probably html
76
- Nokogiri::HTML(
70
+ Nokogiri.HTML(
77
71
  string,
78
72
  url,
79
73
  encoding, options || XML::ParseOptions::DEFAULT_HTML
80
74
  )
81
75
  else
82
- Nokogiri::XML(string, url, encoding,
76
+ Nokogiri.XML(string, url, encoding,
83
77
  options || XML::ParseOptions::DEFAULT_XML)
84
78
  end
85
79
  yield doc if block_given?
Binary file
@@ -0,0 +1,40 @@
1
+ # not-enough-information
2
+
3
+ Hello!
4
+
5
+ Thanks for asking this question! However, without more information,
6
+ Team Nokogiri cannot reproduce your issue, and so we cannot offer much
7
+ help.
8
+
9
+ Please provide us with:
10
+
11
+ * A self-contained script (one that we can run without modification,
12
+ and preferably without making external network connections).
13
+
14
+ * Please note that you need to include the XML/HTML that you are
15
+ operating on.
16
+
17
+ * The output of `nokogiri -v`, which will provide details about your
18
+ platform and versions of ruby, libxml2 and nokogiri.
19
+
20
+ For more information about requesting help or reporting bugs, please
21
+ take a look at http://bit.ly/nokohelp
22
+
23
+ Thank you so much!
24
+
25
+ # not-a-bug
26
+
27
+ Hello!
28
+
29
+ Thanks for asking this question! Your request for help will not go
30
+ unanswered!
31
+
32
+ However, Nokogiri's Github Issues is reserved for reporting bugs or
33
+ submitting patches. If you ask your question on the mailing list, Team
34
+ Nokogiri promises someone will provide you with an answer in a timely
35
+ manner.
36
+
37
+ If you'd like to read up on Team Nokogiri's rationale for this policy,
38
+ please go to http://bit.ly/nokohelp.
39
+
40
+ Thank you so much for understanding! And thank you for using Nokogiri.
@@ -1,158 +1,152 @@
1
1
  require 'rake/extensioncompiler'
2
2
  HOST = Rake::ExtensionCompiler.mingw_host
3
- TARGET = 'i386-pc-mingw32'
4
3
 
5
- ZLIB = 'zlib-1.2.5'
6
- ICONV = 'libiconv-1.13.1'
7
- LIBXML = 'libxml2-2.7.7'
8
- LIBXSLT = 'libxslt-1.1.26'
9
-
10
- ### Build zlib ###
11
- file "tmp/cross/download/#{ZLIB}" do |t|
12
- FileUtils.mkdir_p('tmp/cross/download')
13
-
14
- file = ZLIB
15
- url = "http://zlib.net/#{file}.tar.gz"
16
-
17
- Dir.chdir('tmp/cross/download') do
18
- sh "wget #{url} || curl -O #{url}"
19
- sh "tar zxvf #{file}.tar.gz"
20
- end
21
-
22
- Dir.chdir t.name do
23
- mk = File.read('win32/Makefile.gcc')
24
- File.open('win32/Makefile.gcc', 'wb') do |f|
25
- f.puts "BINARY_PATH = #{CROSS_DIR}/bin"
26
- f.puts "LIBRARY_PATH = #{CROSS_DIR}/lib"
27
- f.puts "INCLUDE_PATH = #{CROSS_DIR}/include"
28
-
29
- # FIXME: need to make the cross compiler dynamic
30
- f.puts mk.sub(/^PREFIX\s*=\s*$/, "PREFIX = #{HOST}-") #.
31
- #sub(/^SHARED_MODE=0$/, 'SHARED_MODE=1').
32
- #sub(/^IMPLIB\s*=.*$/, 'IMPLIB=libz.dll.a')
33
- end
4
+ require 'mini_portile'
5
+ $recipes = {}
6
+ $recipes[:zlib] = MiniPortile.new "zlib", "1.2.5"
7
+ $recipes[:libiconv] = MiniPortile.new "libiconv", "1.13.1"
8
+ $recipes[:libxml2] = MiniPortile.new "libxml2", "2.7.7"
9
+ $recipes[:libxslt] = MiniPortile.new "libxslt", "1.1.26"
10
+ $recipes.each { |_, recipe| recipe.host = HOST }
11
+
12
+ file "lib/nokogiri/nokogiri.rb" do
13
+ File.open("lib/nokogiri/nokogiri.rb", 'wb') do |f|
14
+ f.write %Q{require "nokogiri/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/nokogiri"\n}
34
15
  end
35
16
  end
36
17
 
37
- file 'tmp/cross/lib/libz.a' => "tmp/cross/download/#{ZLIB}" do |t|
38
- Dir.chdir t.prerequisites.first do
39
- sh 'make -f win32/Makefile.gcc'
40
- sh 'make -f win32/Makefile.gcc install'
41
- end
42
- end
43
- ### End build zlib ###
44
-
45
- ### Build iconv ###
46
- file "tmp/cross/download/#{ICONV}" do |t|
47
- FileUtils.mkdir_p('tmp/cross/download')
48
-
49
- file = ICONV
50
- url = "http://ftp.gnu.org/pub/gnu/libiconv/#{file}.tar.gz"
51
-
52
- Dir.chdir('tmp/cross/download') do
53
- sh "wget #{url} || curl -O #{url}"
54
- sh "tar zxvf #{file}.tar.gz"
55
- end
56
-
57
- Dir.chdir t.name do
58
- # FIXME: need to make the host dynamic
59
- sh "./configure --disable-shared --enable-static --host=#{HOST} --target=#{TARGET} --prefix=#{CROSS_DIR} CPPFLAGS='-mno-cygwin -Wall' CFLAGS='-mno-cygwin -O2 -g' CXXFLAGS='-mno-cygwin -O2 -g' LDFLAGS=-mno-cygwin"
60
- end
61
- end
62
-
63
- file 'tmp/cross/bin/iconv.exe' => "tmp/cross/download/#{ICONV}" do |t|
64
- Dir.chdir t.prerequisites.first do
65
- sh 'make'
66
- sh 'make install'
67
- end
68
- end
69
- ### End build iconv ###
70
-
71
- ### Build libxml2 ###
72
- file "tmp/cross/download/#{LIBXML}" do |t|
73
- FileUtils.mkdir_p('tmp/cross/download')
74
-
75
- file = LIBXML
76
- url = "ftp://ftp.xmlsoft.org/libxml2/#{file}.tar.gz"
77
-
78
- Dir.chdir('tmp/cross/download') do
79
- sh "wget #{url} || curl -O #{url}"
80
- sh "tar zxvf #{file}.tar.gz"
81
- end
82
-
83
- Dir.chdir t.name do
84
- # FIXME: need to make the host dynamic
85
- sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-zlib=#{CROSS_DIR} --with-iconv=#{CROSS_DIR} --without-python --without-readline"
86
- end
87
- end
18
+ namespace :cross do
19
+ task :zlib do
20
+ recipe = $recipes[:zlib]
21
+ recipe.files = ["http://zlib.net/#{recipe.name}-#{recipe.version}.tar.gz"]
22
+ class << recipe
23
+ def configure
24
+ Dir.chdir work_path do
25
+ mk = File.read 'win32/Makefile.gcc'
26
+ File.open 'win32/Makefile.gcc', 'wb' do |f|
27
+ f.puts "BINARY_PATH = #{CROSS_DIR}/bin"
28
+ f.puts "LIBRARY_PATH = #{CROSS_DIR}/lib"
29
+ f.puts "INCLUDE_PATH = #{CROSS_DIR}/include"
30
+ f.puts mk.sub(/^PREFIX\s*=\s*$/, "PREFIX = #{HOST}-")
31
+ end
32
+ end
33
+ end
34
+
35
+ def configured?
36
+ Dir.chdir work_path do
37
+ !! (File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
38
+ end
39
+ end
40
+
41
+ def compile
42
+ execute "compile", "make -f win32/Makefile.gcc"
43
+ end
44
+
45
+ def install
46
+ execute "install", "make -f win32/Makefile.gcc install"
47
+ end
48
+ end
88
49
 
89
- file 'tmp/cross/bin/xml2-config' => "tmp/cross/download/#{LIBXML}" do |t|
90
- Dir.chdir t.prerequisites.first do
91
- sh 'make LDFLAGS="-avoid-version"'
92
- sh 'make install'
50
+ checkpoint = "#{CROSS_DIR}/#{recipe.name}-#{recipe.version}.installed"
51
+ unless File.exist?(checkpoint)
52
+ recipe.cook
53
+ touch checkpoint
54
+ end
55
+ recipe.activate
93
56
  end
94
- end
95
- ### End build libxml2 ###
96
-
97
- ### Build libxslt ###
98
- file "tmp/cross/download/#{LIBXSLT}" do |t|
99
- FileUtils.mkdir_p('tmp/cross/download')
100
57
 
101
- file = LIBXSLT
102
- url = "ftp://ftp.xmlsoft.org/libxml2/#{file}.tar.gz"
103
-
104
- Dir.chdir('tmp/cross/download') do
105
- sh "wget #{url} || curl -O #{url}"
106
- sh "tar zxvf #{file}.tar.gz"
58
+ task :libiconv do
59
+ recipe = $recipes[:libiconv]
60
+ recipe.files = ["http://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz"]
61
+ recipe.configure_options = [
62
+ "--host=#{HOST}",
63
+ "--enable-static",
64
+ "--disable-shared",
65
+ "CPPFLAGS='-mno-cygwin -Wall'",
66
+ "CFLAGS='-mno-cygwin -O2 -g'",
67
+ "CXXFLAGS='-mno-cygwin -O2 -g'",
68
+ "LDFLAGS=-mno-cygwin"
69
+ ]
70
+
71
+ checkpoint = "#{CROSS_DIR}/#{recipe.name}-#{recipe.version}.installed"
72
+ unless File.exist?(checkpoint)
73
+ recipe.cook
74
+ touch checkpoint
75
+ end
76
+ recipe.activate
107
77
  end
108
78
 
109
- Dir.chdir t.name do
110
- # FIXME: need to make the host dynamic
111
- sh "CFLAGS='-DIN_LIBXML' ./configure --host=#{HOST} --target=#{TARGET} --enable-static --disable-shared --prefix=#{CROSS_DIR} --with-libxml-prefix=#{CROSS_DIR} --without-python"
112
- end
113
- end
79
+ task :libxml2 => ["cross:zlib", "cross:libiconv"] do
80
+ recipe = $recipes[:libxml2]
81
+ recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
82
+ recipe.configure_options = [
83
+ "--host=#{HOST}",
84
+ "--enable-static",
85
+ "--disable-shared",
86
+ "--with-zlib=#{CROSS_DIR}",
87
+ "--with-iconv=#{$recipes[:libiconv].path}",
88
+ "--without-python",
89
+ "--without-readline",
90
+ "CFLAGS='-DIN_LIBXML'"
91
+ ]
92
+ class << recipe
93
+ def download
94
+ Dir.chdir archives_path do
95
+ @files.each do |url|
96
+ sh "wget #{url} || curl -O #{url}"
97
+ end
98
+ end
99
+ end
100
+ end
114
101
 
115
- file 'tmp/cross/bin/xslt-config' => "tmp/cross/download/#{LIBXSLT}" do |t|
116
- Dir.chdir t.prerequisites.first do
117
- sh 'make LDFLAGS="-avoid-version"'
118
- sh 'make install'
102
+ checkpoint = "#{CROSS_DIR}/#{recipe.name}-#{recipe.version}.installed"
103
+ unless File.exist?(checkpoint)
104
+ recipe.cook
105
+ touch checkpoint
106
+ end
107
+ recipe.activate
119
108
  end
120
- end
121
- ### End build libxslt ###
122
109
 
123
- file 'lib/nokogiri/nokogiri.rb' => 'cross:libxslt' do
124
- File.open("lib/#{HOE.name}/#{HOE.name}.rb", 'wb') do |f|
125
- f.write <<-eoruby
126
- require "#{HOE.name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{HOE.name}"
127
- eoruby
128
- end
129
- end
110
+ task :libxslt => ['cross:libxml2'] do
111
+ recipe = $recipes[:libxslt]
112
+ recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
113
+ recipe.configure_options = [
114
+ "--host=#{HOST}",
115
+ "--enable-static",
116
+ "--disable-shared",
117
+ "--with-libxml-prefix=#{$recipes[:libxml2].path}",
118
+ "--without-python",
119
+ "--without-crypto",
120
+ "CFLAGS='-DIN_LIBXML'"
121
+ ]
122
+ class << recipe
123
+ def download
124
+ Dir.chdir archives_path do
125
+ @files.each do |url|
126
+ sh "wget #{url} || curl -O #{url}"
127
+ end
128
+ end
129
+ end
130
+ end
130
131
 
131
- namespace :cross do
132
- task :iconv => 'tmp/cross/bin/iconv.exe'
133
- task :zlib => 'tmp/cross/lib/libz.a'
134
- task :libxml2 => ['cross:zlib', 'cross:iconv', 'tmp/cross/bin/xml2-config']
135
- task :libxslt => ['cross:libxml2', 'tmp/cross/bin/xslt-config']
136
-
137
- task :copy_dlls do
138
- Dir['tmp/cross/bin/*.dll'].each do |file|
139
- cp file, "ext/nokogiri"
132
+ checkpoint = "#{CROSS_DIR}/#{recipe.name}-#{recipe.version}.installed"
133
+ unless File.exist?(checkpoint)
134
+ recipe.cook
135
+ touch checkpoint
140
136
  end
137
+ recipe.activate
141
138
  end
142
139
 
143
- task :file_list => 'cross:copy_dlls' do
144
- HOE.spec.extensions = []
145
- HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
146
- HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/#{HOE.name}.so"]
147
- HOE.spec.files += Dir["ext/nokogiri/*.dll"]
140
+ task :file_list do
141
+ HOE.spec.files += Dir["lib/nokogiri/nokogiri.rb"]
142
+ HOE.spec.files += Dir["lib/nokogiri/1.{8,9}/nokogiri.so"]
148
143
  end
149
144
  end
150
145
 
151
- CLOBBER.include("lib/nokogiri/nokogiri.{so,dylib,rb,bundle}")
152
- CLOBBER.include("lib/nokogiri/1.{8,9}")
153
- CLOBBER.include("ext/nokogiri/*.dll")
146
+ HOE.clean_globs += [
147
+ "#{CROSS_DIR}/*.installed",
148
+ "#{CROSS_DIR}/#{HOST}",
149
+ "tmp/#{HOST}",
150
+ ]
154
151
 
155
- if Rake::Task.task_defined?(:cross)
156
- Rake::Task[:cross].prerequisites << "lib/nokogiri/nokogiri.rb"
157
- Rake::Task[:cross].prerequisites << "cross:file_list"
158
- end
152
+ task :cross => ["cross:libxslt", "lib/nokogiri/nokogiri.rb", "cross:file_list"]
@@ -0,0 +1,18 @@
1
+ namespace :docs do
2
+ desc "generate HTML docs for nokogiri.org"
3
+ task :website do
4
+ title = "#{HOE.name}-#{HOE.version} Documentation"
5
+
6
+ options = []
7
+ options << "--main=#{HOE.readme_file}"
8
+ options << '--format=activerecord'
9
+ options << '--threads=1'
10
+ options << "--title=#{title.inspect}"
11
+
12
+ options += HOE.spec.require_paths
13
+ options += HOE.spec.extra_rdoc_files
14
+ require 'rdoc/rdoc'
15
+ ENV['RAILS_ROOT'] ||= File.expand_path(File.join('..', 'nokogiri_ws'))
16
+ RDoc::RDoc.new.document options
17
+ end
18
+ end
data/tasks/test.rb CHANGED
@@ -64,7 +64,7 @@ namespace :test do
64
64
  end
65
65
 
66
66
  Dir.chdir File.join(MULTI_XML, 'build', filename) do
67
- system "./configure --prefix=#{install_dir}"
67
+ system "./configure --without-http --prefix=#{install_dir}"
68
68
  system "make && make install"
69
69
  end
70
70
  end
@@ -73,7 +73,7 @@ namespace :test do
73
73
  libxslt = Dir[File.join(MULTI_XML, 'install', 'libxslt*')].first
74
74
 
75
75
  directories = ENV['MULTIXML2_DIR'] ? [ENV['MULTIXML2_DIR']] : Dir[File.join(MULTI_XML, 'install', '*')]
76
- directories.sort.reverse.each do |xml2_version|
76
+ directories.sort.reverse_each do |xml2_version|
77
77
  next unless xml2_version =~ /libxml2/
78
78
  extopts = "--with-xml2-include=#{xml2_version}/include/libxml2 --with-xml2-lib=#{xml2_version}/lib --with-xslt-dir=#{libxslt} --with-iconv-dir=/usr"
79
79
  cmd = "#{$0} clean test EXTOPTS='#{extopts}' LD_LIBRARY_PATH='#{xml2_version}/lib'"
@@ -142,30 +142,31 @@ module Nokogiri
142
142
 
143
143
  def test_nonstandard_nth_selectors
144
144
  ## These are non standard CSS
145
- assert_xpath '//a[position() = 99]', @parser.parse('a:eq(99)')
146
- assert_xpath '//a[position() = 1]', @parser.parse('a:first') # no parens
147
- assert_xpath '//a[position() = last()]', @parser.parse('a:last') # no parens
148
- assert_xpath '//a[position() = 99]', @parser.parse('a:nth(99)')
149
- assert_xpath '//a[position() = 1]', @parser.parse('a:first()')
150
- assert_xpath '//a[position() = last()]', @parser.parse('a:last()')
151
- assert_xpath '//a[node()]', @parser.parse('a:parent')
145
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first()')
146
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first') # no parens
147
+ assert_xpath '//a[position() = 99]', @parser.parse('a:eq(99)')
148
+ assert_xpath '//a[position() = 99]', @parser.parse('a:nth(99)')
149
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last()')
150
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last') # no parens
151
+ assert_xpath '//a[node()]', @parser.parse('a:parent')
152
152
  end
153
153
 
154
154
  def test_standard_nth_selectors
155
- assert_xpath '//a[position() = 99]', @parser.parse('a:nth-of-type(99)')
156
- assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type()')
157
- assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type()')
158
- assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type') # no parens
159
- assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type') # no parens
160
- assert_xpath '//a[position() = last() - 99]', @parser.parse('a:nth-last-of-type(99)')
161
- assert_xpath '//a[position() = last() - 99]', @parser.parse('a:nth-last-of-type(99)')
155
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type()')
156
+ assert_xpath '//a[position() = 1]', @parser.parse('a:first-of-type') # no parens
157
+ assert_xpath '//a[position() = 99]', @parser.parse('a:nth-of-type(99)')
158
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type()')
159
+ assert_xpath '//a[position() = last()]', @parser.parse('a:last-of-type') # no parens
160
+ assert_xpath '//a[position() = last()]', @parser.parse('a:nth-last-of-type(1)')
161
+ assert_xpath '//a[position() = last() - 98]', @parser.parse('a:nth-last-of-type(99)')
162
162
  end
163
163
 
164
164
  def test_nth_child_selectors
165
- assert_xpath '//*[position() = 1 and self::a]', @parser.parse('a:first-child')
166
- assert_xpath '//*[position() = last() and self::a]', @parser.parse('a:last-child')
167
- assert_xpath '//*[position() = 99 and self::a]', @parser.parse('a:nth-child(99)')
168
- assert_xpath '//*[position() = last() - 99 and self::a]', @parser.parse('a:nth-last-child(99)')
165
+ assert_xpath '//*[position() = 1 and self::a]', @parser.parse('a:first-child')
166
+ assert_xpath '//*[position() = 99 and self::a]', @parser.parse('a:nth-child(99)')
167
+ assert_xpath '//*[position() = last() and self::a]', @parser.parse('a:last-child')
168
+ assert_xpath '//*[position() = last() and self::a]', @parser.parse('a:nth-last-child(1)')
169
+ assert_xpath '//*[position() = last() - 98 and self::a]', @parser.parse('a:nth-last-child(99)')
169
170
  end
170
171
 
171
172
  def test_miscellaneous_selectors
@@ -185,6 +186,16 @@ module Nokogiri
185
186
  assert_xpath '//a[(position() <= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(-n+3)')
186
187
  assert_xpath '//a[(position() >= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(1n+3)')
187
188
  assert_xpath '//a[(position() >= 3) and (((position()-3) mod 1) = 0)]', @parser.parse('a:nth-of-type(n+3)')
189
+
190
+ assert_xpath '//a[((last()-position()+1) mod 2) = 0]', @parser.parse('a:nth-last-of-type(2n)')
191
+ assert_xpath '//a[((last()-position()+1) >= 1) and ((((last()-position()+1)-1) mod 2) = 0)]', @parser.parse('a:nth-last-of-type(2n+1)')
192
+ assert_xpath '//a[((last()-position()+1) mod 2) = 0]', @parser.parse('a:nth-last-of-type(even)')
193
+ assert_xpath '//a[((last()-position()+1) >= 1) and ((((last()-position()+1)-1) mod 2) = 0)]', @parser.parse('a:nth-last-of-type(odd)')
194
+ assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 4) = 0)]', @parser.parse('a:nth-last-of-type(4n+3)')
195
+ assert_xpath '//a[((last()-position()+1) <= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(-1n+3)')
196
+ assert_xpath '//a[((last()-position()+1) <= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(-n+3)')
197
+ assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(1n+3)')
198
+ assert_xpath '//a[((last()-position()+1) >= 3) and ((((last()-position()+1)-3) mod 1) = 0)]', @parser.parse('a:nth-last-of-type(n+3)')
188
199
  end
189
200
 
190
201
  def test_preceding_selector
@@ -2,6 +2,14 @@
2
2
 
3
3
  require "helper"
4
4
 
5
+ module Nokogiri
6
+ module CSS
7
+ class Tokenizer
8
+ alias :scan :scan_setup
9
+ end
10
+ end
11
+ end
12
+
5
13
  module Nokogiri
6
14
  module CSS
7
15
  class TestTokenizer < Nokogiri::TestCase
@@ -0,0 +1,16 @@
1
+ require "helper"
2
+
3
+ module Nokogiri
4
+ class TestSlop < Nokogiri::TestCase
5
+ def test_description_tag
6
+ doc = Nokogiri.Slop(<<-eoxml)
7
+ <item>
8
+ <title>foo</title>
9
+ <description>this is the foo thing</description>
10
+ </item>
11
+ eoxml
12
+ assert doc.item.title
13
+ assert doc.item._description, 'should have description'
14
+ end
15
+ end
16
+ end