nokogiri-fitzsimmons 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. data/.autotest +26 -0
  2. data/.gemtest +0 -0
  3. data/CHANGELOG.ja.rdoc +666 -0
  4. data/CHANGELOG.rdoc +659 -0
  5. data/C_CODING_STYLE.rdoc +33 -0
  6. data/Manifest.txt +295 -0
  7. data/README.ja.rdoc +106 -0
  8. data/README.rdoc +178 -0
  9. data/ROADMAP.md +86 -0
  10. data/Rakefile +194 -0
  11. data/STANDARD_RESPONSES.md +47 -0
  12. data/Y_U_NO_GEMSPEC.md +155 -0
  13. data/bin/nokogiri +63 -0
  14. data/build_all +58 -0
  15. data/ext/nokogiri/depend +358 -0
  16. data/ext/nokogiri/extconf.rb +142 -0
  17. data/ext/nokogiri/html_document.c +170 -0
  18. data/ext/nokogiri/html_document.h +10 -0
  19. data/ext/nokogiri/html_element_description.c +276 -0
  20. data/ext/nokogiri/html_element_description.h +10 -0
  21. data/ext/nokogiri/html_entity_lookup.c +32 -0
  22. data/ext/nokogiri/html_entity_lookup.h +8 -0
  23. data/ext/nokogiri/html_sax_parser_context.c +116 -0
  24. data/ext/nokogiri/html_sax_parser_context.h +11 -0
  25. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  26. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  27. data/ext/nokogiri/nokogiri.c +133 -0
  28. data/ext/nokogiri/nokogiri.h +160 -0
  29. data/ext/nokogiri/xml_attr.c +94 -0
  30. data/ext/nokogiri/xml_attr.h +9 -0
  31. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  32. data/ext/nokogiri/xml_attribute_decl.h +9 -0
  33. data/ext/nokogiri/xml_cdata.c +56 -0
  34. data/ext/nokogiri/xml_cdata.h +9 -0
  35. data/ext/nokogiri/xml_comment.c +54 -0
  36. data/ext/nokogiri/xml_comment.h +9 -0
  37. data/ext/nokogiri/xml_document.c +576 -0
  38. data/ext/nokogiri/xml_document.h +23 -0
  39. data/ext/nokogiri/xml_document_fragment.c +48 -0
  40. data/ext/nokogiri/xml_document_fragment.h +10 -0
  41. data/ext/nokogiri/xml_dtd.c +202 -0
  42. data/ext/nokogiri/xml_dtd.h +10 -0
  43. data/ext/nokogiri/xml_element_content.c +123 -0
  44. data/ext/nokogiri/xml_element_content.h +10 -0
  45. data/ext/nokogiri/xml_element_decl.c +69 -0
  46. data/ext/nokogiri/xml_element_decl.h +9 -0
  47. data/ext/nokogiri/xml_encoding_handler.c +79 -0
  48. data/ext/nokogiri/xml_encoding_handler.h +8 -0
  49. data/ext/nokogiri/xml_entity_decl.c +110 -0
  50. data/ext/nokogiri/xml_entity_decl.h +10 -0
  51. data/ext/nokogiri/xml_entity_reference.c +52 -0
  52. data/ext/nokogiri/xml_entity_reference.h +9 -0
  53. data/ext/nokogiri/xml_io.c +56 -0
  54. data/ext/nokogiri/xml_io.h +11 -0
  55. data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
  56. data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
  57. data/ext/nokogiri/xml_namespace.c +78 -0
  58. data/ext/nokogiri/xml_namespace.h +13 -0
  59. data/ext/nokogiri/xml_node.c +1480 -0
  60. data/ext/nokogiri/xml_node.h +13 -0
  61. data/ext/nokogiri/xml_node_set.c +467 -0
  62. data/ext/nokogiri/xml_node_set.h +14 -0
  63. data/ext/nokogiri/xml_processing_instruction.c +56 -0
  64. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  65. data/ext/nokogiri/xml_reader.c +684 -0
  66. data/ext/nokogiri/xml_reader.h +10 -0
  67. data/ext/nokogiri/xml_relax_ng.c +161 -0
  68. data/ext/nokogiri/xml_relax_ng.h +9 -0
  69. data/ext/nokogiri/xml_sax_parser.c +293 -0
  70. data/ext/nokogiri/xml_sax_parser.h +39 -0
  71. data/ext/nokogiri/xml_sax_parser_context.c +222 -0
  72. data/ext/nokogiri/xml_sax_parser_context.h +10 -0
  73. data/ext/nokogiri/xml_sax_push_parser.c +115 -0
  74. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  75. data/ext/nokogiri/xml_schema.c +205 -0
  76. data/ext/nokogiri/xml_schema.h +9 -0
  77. data/ext/nokogiri/xml_syntax_error.c +58 -0
  78. data/ext/nokogiri/xml_syntax_error.h +13 -0
  79. data/ext/nokogiri/xml_text.c +52 -0
  80. data/ext/nokogiri/xml_text.h +9 -0
  81. data/ext/nokogiri/xml_xpath_context.c +319 -0
  82. data/ext/nokogiri/xml_xpath_context.h +10 -0
  83. data/ext/nokogiri/xslt_stylesheet.c +270 -0
  84. data/ext/nokogiri/xslt_stylesheet.h +14 -0
  85. data/lib/nokogiri.rb +127 -0
  86. data/lib/nokogiri/css.rb +27 -0
  87. data/lib/nokogiri/css/node.rb +102 -0
  88. data/lib/nokogiri/css/parser.rb +720 -0
  89. data/lib/nokogiri/css/parser.y +258 -0
  90. data/lib/nokogiri/css/parser_extras.rb +91 -0
  91. data/lib/nokogiri/css/syntax_error.rb +7 -0
  92. data/lib/nokogiri/css/tokenizer.rb +152 -0
  93. data/lib/nokogiri/css/tokenizer.rex +55 -0
  94. data/lib/nokogiri/css/xpath_visitor.rb +171 -0
  95. data/lib/nokogiri/decorators/slop.rb +35 -0
  96. data/lib/nokogiri/html.rb +37 -0
  97. data/lib/nokogiri/html/builder.rb +35 -0
  98. data/lib/nokogiri/html/document.rb +254 -0
  99. data/lib/nokogiri/html/document_fragment.rb +41 -0
  100. data/lib/nokogiri/html/element_description.rb +23 -0
  101. data/lib/nokogiri/html/element_description_defaults.rb +671 -0
  102. data/lib/nokogiri/html/entity_lookup.rb +13 -0
  103. data/lib/nokogiri/html/sax/parser.rb +52 -0
  104. data/lib/nokogiri/html/sax/parser_context.rb +16 -0
  105. data/lib/nokogiri/html/sax/push_parser.rb +16 -0
  106. data/lib/nokogiri/syntax_error.rb +4 -0
  107. data/lib/nokogiri/version.rb +88 -0
  108. data/lib/nokogiri/xml.rb +73 -0
  109. data/lib/nokogiri/xml/attr.rb +14 -0
  110. data/lib/nokogiri/xml/attribute_decl.rb +18 -0
  111. data/lib/nokogiri/xml/builder.rb +431 -0
  112. data/lib/nokogiri/xml/cdata.rb +11 -0
  113. data/lib/nokogiri/xml/character_data.rb +7 -0
  114. data/lib/nokogiri/xml/document.rb +267 -0
  115. data/lib/nokogiri/xml/document_fragment.rb +103 -0
  116. data/lib/nokogiri/xml/dtd.rb +22 -0
  117. data/lib/nokogiri/xml/element_content.rb +36 -0
  118. data/lib/nokogiri/xml/element_decl.rb +13 -0
  119. data/lib/nokogiri/xml/entity_decl.rb +19 -0
  120. data/lib/nokogiri/xml/namespace.rb +13 -0
  121. data/lib/nokogiri/xml/node.rb +946 -0
  122. data/lib/nokogiri/xml/node/save_options.rb +61 -0
  123. data/lib/nokogiri/xml/node_set.rb +357 -0
  124. data/lib/nokogiri/xml/notation.rb +6 -0
  125. data/lib/nokogiri/xml/parse_options.rb +98 -0
  126. data/lib/nokogiri/xml/pp.rb +2 -0
  127. data/lib/nokogiri/xml/pp/character_data.rb +18 -0
  128. data/lib/nokogiri/xml/pp/node.rb +56 -0
  129. data/lib/nokogiri/xml/processing_instruction.rb +8 -0
  130. data/lib/nokogiri/xml/reader.rb +112 -0
  131. data/lib/nokogiri/xml/relax_ng.rb +32 -0
  132. data/lib/nokogiri/xml/sax.rb +4 -0
  133. data/lib/nokogiri/xml/sax/document.rb +164 -0
  134. data/lib/nokogiri/xml/sax/parser.rb +115 -0
  135. data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
  136. data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
  137. data/lib/nokogiri/xml/schema.rb +63 -0
  138. data/lib/nokogiri/xml/syntax_error.rb +47 -0
  139. data/lib/nokogiri/xml/text.rb +9 -0
  140. data/lib/nokogiri/xml/xpath.rb +10 -0
  141. data/lib/nokogiri/xml/xpath/syntax_error.rb +11 -0
  142. data/lib/nokogiri/xml/xpath_context.rb +16 -0
  143. data/lib/nokogiri/xslt.rb +56 -0
  144. data/lib/nokogiri/xslt/stylesheet.rb +25 -0
  145. data/lib/xsd/xmlparser/nokogiri.rb +90 -0
  146. data/tasks/cross_compile.rb +153 -0
  147. data/tasks/nokogiri.org.rb +24 -0
  148. data/tasks/test.rb +95 -0
  149. data/test/css/test_nthiness.rb +159 -0
  150. data/test/css/test_parser.rb +341 -0
  151. data/test/css/test_tokenizer.rb +198 -0
  152. data/test/css/test_xpath_visitor.rb +91 -0
  153. data/test/decorators/test_slop.rb +16 -0
  154. data/test/files/2ch.html +108 -0
  155. data/test/files/address_book.rlx +12 -0
  156. data/test/files/address_book.xml +10 -0
  157. data/test/files/bar/bar.xsd +4 -0
  158. data/test/files/dont_hurt_em_why.xml +422 -0
  159. data/test/files/encoding.html +82 -0
  160. data/test/files/encoding.xhtml +84 -0
  161. data/test/files/exslt.xml +8 -0
  162. data/test/files/exslt.xslt +35 -0
  163. data/test/files/foo/foo.xsd +4 -0
  164. data/test/files/metacharset.html +10 -0
  165. data/test/files/noencoding.html +47 -0
  166. data/test/files/po.xml +32 -0
  167. data/test/files/po.xsd +66 -0
  168. data/test/files/shift_jis.html +10 -0
  169. data/test/files/shift_jis.xml +5 -0
  170. data/test/files/snuggles.xml +3 -0
  171. data/test/files/staff.dtd +10 -0
  172. data/test/files/staff.xml +59 -0
  173. data/test/files/staff.xslt +32 -0
  174. data/test/files/tlm.html +850 -0
  175. data/test/files/to_be_xincluded.xml +2 -0
  176. data/test/files/valid_bar.xml +2 -0
  177. data/test/files/xinclude.xml +4 -0
  178. data/test/helper.rb +147 -0
  179. data/test/html/sax/test_parser.rb +138 -0
  180. data/test/html/sax/test_parser_context.rb +46 -0
  181. data/test/html/test_builder.rb +164 -0
  182. data/test/html/test_document.rb +529 -0
  183. data/test/html/test_document_encoding.rb +138 -0
  184. data/test/html/test_document_fragment.rb +254 -0
  185. data/test/html/test_element_description.rb +100 -0
  186. data/test/html/test_named_characters.rb +14 -0
  187. data/test/html/test_node.rb +188 -0
  188. data/test/html/test_node_encoding.rb +27 -0
  189. data/test/test_convert_xpath.rb +135 -0
  190. data/test/test_css_cache.rb +45 -0
  191. data/test/test_encoding_handler.rb +46 -0
  192. data/test/test_memory_leak.rb +152 -0
  193. data/test/test_nokogiri.rb +132 -0
  194. data/test/test_reader.rb +488 -0
  195. data/test/test_soap4r_sax.rb +52 -0
  196. data/test/test_xslt_transforms.rb +254 -0
  197. data/test/xml/node/test_save_options.rb +28 -0
  198. data/test/xml/node/test_subclass.rb +44 -0
  199. data/test/xml/sax/test_parser.rb +338 -0
  200. data/test/xml/sax/test_parser_context.rb +106 -0
  201. data/test/xml/sax/test_push_parser.rb +157 -0
  202. data/test/xml/test_attr.rb +64 -0
  203. data/test/xml/test_attribute_decl.rb +86 -0
  204. data/test/xml/test_builder.rb +248 -0
  205. data/test/xml/test_c14n.rb +151 -0
  206. data/test/xml/test_cdata.rb +48 -0
  207. data/test/xml/test_comment.rb +29 -0
  208. data/test/xml/test_document.rb +742 -0
  209. data/test/xml/test_document_encoding.rb +28 -0
  210. data/test/xml/test_document_fragment.rb +216 -0
  211. data/test/xml/test_dtd.rb +103 -0
  212. data/test/xml/test_dtd_encoding.rb +33 -0
  213. data/test/xml/test_element_content.rb +56 -0
  214. data/test/xml/test_element_decl.rb +73 -0
  215. data/test/xml/test_entity_decl.rb +122 -0
  216. data/test/xml/test_entity_reference.rb +235 -0
  217. data/test/xml/test_namespace.rb +75 -0
  218. data/test/xml/test_node.rb +1029 -0
  219. data/test/xml/test_node_attributes.rb +53 -0
  220. data/test/xml/test_node_encoding.rb +107 -0
  221. data/test/xml/test_node_inheritance.rb +32 -0
  222. data/test/xml/test_node_reparenting.rb +374 -0
  223. data/test/xml/test_node_set.rb +755 -0
  224. data/test/xml/test_parse_options.rb +64 -0
  225. data/test/xml/test_processing_instruction.rb +30 -0
  226. data/test/xml/test_reader_encoding.rb +142 -0
  227. data/test/xml/test_relax_ng.rb +60 -0
  228. data/test/xml/test_schema.rb +94 -0
  229. data/test/xml/test_syntax_error.rb +12 -0
  230. data/test/xml/test_text.rb +45 -0
  231. data/test/xml/test_unparented_node.rb +413 -0
  232. data/test/xml/test_xinclude.rb +83 -0
  233. data/test/xml/test_xpath.rb +295 -0
  234. data/test/xslt/test_custom_functions.rb +129 -0
  235. data/test/xslt/test_exception_handling.rb +37 -0
  236. data/test_all +84 -0
  237. metadata +534 -0
data/ROADMAP.md ADDED
@@ -0,0 +1,86 @@
1
+ # Roadmap for 2.0
2
+
3
+ ## overhaul serialize/pretty printing API
4
+
5
+ * https://github.com/sparklemotion/nokogiri/issues/530
6
+ XHTML formatting can't be turned off
7
+
8
+ * https://github.com/sparklemotion/nokogiri/issues/415
9
+ XML formatting should be no formatting
10
+
11
+
12
+ ## overhaul and optimize the SAX parsing
13
+
14
+ * see fairy wing throwdown - SAX parsing is wicked slow.
15
+
16
+
17
+ ## Node should not be Enumerable; and should have a better attributes API
18
+
19
+ * https://github.com/sparklemotion/nokogiri/issues/679
20
+ Mixing in Enumerable has some unintended consequences; plus we want to improve the attributes API
21
+
22
+ * (closed) https://github.com/sparklemotion/nokogiri/issues/666
23
+ Some ideas for a better attributes API?
24
+
25
+
26
+ ## improve CSS query parsing
27
+
28
+ * https://github.com/sparklemotion/nokogiri/issues/528
29
+ support `:not()` with a nontrivial argument, like `:not(div p.c)`
30
+
31
+ * https://github.com/sparklemotion/nokogiri/issues/451
32
+ chained :not pseudoselectors
33
+
34
+ * better jQuery selector support:
35
+ * https://github.com/sparklemotion/nokogiri/issues/621
36
+ * https://github.com/sparklemotion/nokogiri/issues/342
37
+ * https://github.com/sparklemotion/nokogiri/issues/628
38
+ * https://github.com/sparklemotion/nokogiri/issues/652
39
+ * https://github.com/sparklemotion/nokogiri/issues/688
40
+
41
+ * https://github.com/sparklemotion/nokogiri/issues/394
42
+ nth-of-type is wrong, and possibly other selectors as well
43
+
44
+ * https://github.com/sparklemotion/nokogiri/issues/309
45
+ incorrect query being executed
46
+
47
+ * https://github.com/sparklemotion/nokogiri/issues/350
48
+ :has is wrong?
49
+
50
+
51
+ ## DocumentFragment
52
+
53
+ * there are a few tickets about searches not working properly if you
54
+ use or do not use the context node as part of the search.
55
+ - https://github.com/sparklemotion/nokogiri/issues/213
56
+ - https://github.com/sparklemotion/nokogiri/issues/370
57
+ - https://github.com/sparklemotion/nokogiri/issues/454
58
+ - https://github.com/sparklemotion/nokogiri/issues/572
59
+
60
+
61
+ ## Better Syntax for custom XPath function handler
62
+
63
+ * https://github.com/sparklemotion/nokogiri/pull/464
64
+
65
+
66
+ ## Better Syntax around Node#xpath and NodeSet#xpath
67
+
68
+ * look at those methods, and use of Node#extract_params in Node#{css,search}
69
+ * we should standardize on a hash of options for these and other calls
70
+ * what should NodeSet#xpath return?
71
+ * https://github.com/sparklemotion/nokogiri/issues/656
72
+
73
+ ## Encoding
74
+
75
+ We have a lot of issues open around encoding. How bad are things?
76
+ Would it help if we deprecated support for Ruby 1.8.7? Somebody who
77
+ knows encoding well should head this up.
78
+
79
+ * Extract EncodingReader as a real object that can be injected
80
+ https://groups.google.com/forum/#!msg/nokogiri-talk/arJeAtMqvkg/tGihB-iBRSAJ
81
+
82
+
83
+ ## Reader
84
+
85
+ It's fundamentally broken, in that we can't stop people from crashing
86
+ their application if they want to use object reference unsafely.
data/Rakefile ADDED
@@ -0,0 +1,194 @@
1
+ # -*- ruby -*-
2
+ require 'rubygems'
3
+
4
+ gem 'hoe'
5
+ require 'hoe'
6
+ Hoe.plugin :debugging
7
+ Hoe.plugin :git
8
+ Hoe.plugin :gemspec
9
+ Hoe.plugin :bundler
10
+ Hoe.add_include_dirs '.' # for ruby 1.9.2
11
+
12
+ GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
13
+ GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
14
+ CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
15
+
16
+ def java?
17
+ !! (RUBY_PLATFORM =~ /java/)
18
+ end
19
+
20
+ require 'tasks/nokogiri.org'
21
+
22
+ HOE = Hoe.spec 'nokogiri-fitzsimmons' do
23
+ developer 'Aaron Patterson', 'aaronp@rubyforge.org'
24
+ developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
25
+ developer 'Yoko Harada', 'yokolet@gmail.com'
26
+ developer 'Tim Elliott', 'tle@holymonkey.com'
27
+ developer 'Justin Fitzsimmons', 'justin@fitzsimmons.ca'
28
+
29
+ self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
30
+ self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
31
+
32
+ self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
33
+
34
+ self.clean_globs += [
35
+ 'nokogiri.gemspec',
36
+ 'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
37
+ 'lib/nokogiri/1.{8,9}',
38
+ # GENERATED_PARSER,
39
+ # GENERATED_TOKENIZER
40
+ ]
41
+
42
+ self.extra_dev_deps += [
43
+ ["hoe-bundler", ">= 1.1"],
44
+ ["hoe-debugging", ">= 1.0.3"],
45
+ ["hoe-gemspec", ">= 1.0"],
46
+ ["hoe-git", ">= 1.4"],
47
+ ["mini_portile", ">= 0.2.2"],
48
+ ["minitest", "~> 2.2.2"],
49
+ ["rake", ">= 0.9"],
50
+ ["rake-compiler", "= 0.8.0"]
51
+ ]
52
+ if ! java?
53
+ self.extra_dev_deps += [
54
+ ["racc", ">= 1.4.6"],
55
+ ["rexical", ">= 1.0.5"]
56
+ ]
57
+ end
58
+
59
+ if java?
60
+ self.spec_extras = { :platform => 'java' }
61
+ else
62
+ self.spec_extras = {
63
+ :extensions => ["ext/nokogiri/extconf.rb"],
64
+ :required_ruby_version => '>= 1.8.7'
65
+ }
66
+ end
67
+
68
+ self.testlib = :minitest
69
+ end
70
+
71
+ # ----------------------------------------
72
+
73
+ if java?
74
+ # TODO: clean this section up.
75
+ require "rake/javaextensiontask"
76
+ Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
77
+ jruby_home = RbConfig::CONFIG['prefix']
78
+ ext.ext_dir = 'ext/java'
79
+ ext.lib_dir = 'lib/nokogiri'
80
+ jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
81
+ ext.classpath = jars.map { |x| File.expand_path x }.join ':'
82
+ end
83
+
84
+ gem_build_path = File.join 'pkg', HOE.spec.full_name
85
+
86
+ task gem_build_path => [:compile] do
87
+ cp 'lib/nokogiri/nokogiri.jar', File.join(gem_build_path, 'lib', 'nokogiri')
88
+ HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
89
+ end
90
+ else
91
+ mingw_available = true
92
+ begin
93
+ require 'tasks/cross_compile'
94
+ rescue
95
+ mingw_available = false
96
+ end
97
+ require "rake/extensiontask"
98
+
99
+ HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
100
+
101
+ Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
102
+ ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
103
+ ext.config_options << ENV['EXTOPTS']
104
+ if mingw_available
105
+ ext.cross_compile = true
106
+ ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
107
+ ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
108
+ ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes[:libxml2].path, 'lib')}"
109
+ ext.cross_config_options << "--with-iconv-dir=#{$recipes[:libiconv].path}"
110
+ ext.cross_config_options << "--with-xslt-dir=#{$recipes[:libxslt].path}"
111
+ ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
112
+ end
113
+ end
114
+ end
115
+
116
+ # ----------------------------------------
117
+
118
+ desc "Generate css/parser.rb and css/tokenizer.rex"
119
+ task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
120
+ task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
121
+
122
+ file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
123
+ racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
124
+ racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
125
+ racc = %x{command -v racc}.strip if racc.empty?
126
+ sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
127
+ end
128
+
129
+ file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
130
+ sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
131
+ end
132
+
133
+ [:compile, :check_manifest].each do |task_name|
134
+ Rake::Task[task_name].prerequisites << GENERATED_PARSER
135
+ Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
136
+ end
137
+
138
+ # ----------------------------------------
139
+
140
+ desc "set environment variables to build and/or test with debug options"
141
+ task :debug do
142
+ ENV['NOKOGIRI_DEBUG'] = "true"
143
+ ENV['CFLAGS'] ||= ""
144
+ ENV['CFLAGS'] += " -DDEBUG"
145
+ end
146
+
147
+ require 'tasks/test'
148
+
149
+ task :java_debug do
150
+ ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
151
+ end
152
+
153
+ Rake::Task[:test].prerequisites << :compile
154
+ Rake::Task[:test].prerequisites << :java_debug
155
+ Rake::Task[:test].prerequisites << :check_extra_deps unless java?
156
+ if Hoe.plugins.include?(:debugging)
157
+ ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
158
+ Rake::Task["test:#{task_name}"].prerequisites << :compile
159
+ end
160
+ end
161
+
162
+ # ----------------------------------------
163
+
164
+ desc "build a windows gem without all the ceremony."
165
+ task "gem:windows" => "gem" do
166
+ cross_rubies = ["1.8.7-p330", "1.9.2-p136"]
167
+ ruby_cc_version = cross_rubies.collect { |_| _.split("-").first }.join(":") # e.g., "1.8.7:1.9.2"
168
+ rake_compiler_config_path = "#{ENV['HOME']}/.rake-compiler/config.yml"
169
+
170
+ unless File.exists? rake_compiler_config_path
171
+ raise "rake-compiler has not installed any cross rubies. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{cross_rubies.first}'"
172
+ end
173
+ rake_compiler_config = YAML.load_file(rake_compiler_config_path)
174
+
175
+ # check that rake-compiler config contains the right patchlevels. see #279 for background,
176
+ # and http://blog.mmediasys.com/2011/01/22/rake-compiler-updated-list-of-supported-ruby-versions-for-cross-compilation/
177
+ # for more up-to-date docs.
178
+ cross_rubies.each do |version|
179
+ majmin, patchlevel = version.split("-")
180
+ rbconfig = "rbconfig-#{majmin}"
181
+ unless rake_compiler_config.key?(rbconfig) && rake_compiler_config[rbconfig] =~ /-#{patchlevel}/
182
+ raise "rake-compiler '#{rbconfig}' not #{patchlevel}. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{version}'"
183
+ end
184
+ end
185
+
186
+ # verify that --export-all is in the 1.9 rbconfig. see #279,#374,#375.
187
+ rbconfig_19 = rake_compiler_config["rbconfig-1.9.2"]
188
+ raise "rbconfig #{rbconfig_19} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_19).split("\n").grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
189
+
190
+ pkg_config_path = [:libxslt, :libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
191
+ sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=#{ruby_cc_version} rake cross native gem") || raise("build failed!")
192
+ end
193
+
194
+ # vim: syntax=Ruby
@@ -0,0 +1,47 @@
1
+ # Standard Responses to Requests
2
+
3
+ These responses are needed often enough that I figured, let's just
4
+ check them in for future reference and use.
5
+
6
+
7
+ # Not enough information to help
8
+
9
+ Hello!
10
+
11
+ Thanks for asking this question! However, without more information,
12
+ Team Nokogiri cannot reproduce your issue, and so we cannot offer much
13
+ help.
14
+
15
+ Please provide us with:
16
+
17
+ * A self-contained script (one that we can run without modification,
18
+ and preferably without making external network connections).
19
+
20
+ * Please note that you need to include the XML/HTML that you are
21
+ operating on.
22
+
23
+ * The output of `nokogiri -v`, which will provide details about your
24
+ platform and versions of ruby, libxml2 and nokogiri.
25
+
26
+ For more information about requesting help or reporting bugs, please
27
+ take a look at http://bit.ly/nokohelp
28
+
29
+ Thank you so much!
30
+
31
+
32
+ # Not a bug
33
+
34
+ Hello!
35
+
36
+ Thanks for asking this question! Your request for assistance using
37
+ Nokogiri will not go unanswered!
38
+
39
+ However, Nokogiri's Github Issues is reserved for reporting bugs or
40
+ submitting patches. If you ask your question on the mailing list, Team
41
+ Nokogiri promises someone will provide you with an answer in a timely
42
+ manner.
43
+
44
+ If you'd like to read up on Team Nokogiri's rationale for this policy,
45
+ please go to http://bit.ly/nokohelp.
46
+
47
+ Thank you so much for understanding! And thank you for using Nokogiri.
data/Y_U_NO_GEMSPEC.md ADDED
@@ -0,0 +1,155 @@
1
+ (note: this was originally a blog post published at http://blog.flavorjon.es/2012/03/y-u-no-gemspec.html)
2
+
3
+ ## tl;dr
4
+
5
+ 1. Team Nokogiri are not 10-foot-tall code-crunching robots, so `master` is usually unstable.
6
+ 2. Unstable code can corrupt your data and crash your application, which would make everybody look bad.
7
+ 3. Therefore, the _risk_ associated with using unstable code is severe; for you _and_ for Team Nokogiri.
8
+ 4. The absence of a gemspec is a risk mitigation tactic.
9
+ 5. You can always ask for an RC release.
10
+
11
+
12
+ ## Why Isn't There a Gemspec!?
13
+
14
+ OHAI! Thank you for asking this question!
15
+
16
+ Team Nokogiri gets asked this pretty frequently. Just a sample from
17
+ the historical record:
18
+
19
+ * [Issue #274](https://github.com/sparklemotion/nokogiri/issues/274)
20
+ * [Issue #371](https://github.com/sparklemotion/nokogiri/issues/371)
21
+ * [A commit removing nokogiri.gemspec](https://github.com/sparklemotion/nokogiri/commit/7f17a643a05ca381d65131515b54d4a3a61ca2e1#commitcomment-667477)
22
+ * [A nokogiri-talk thread](http://groups.google.com/group/nokogiri-talk/browse_thread/thread/4706b002e492d23f)
23
+ * [Another nokogiri-talk thread](http://groups.google.com/group/nokogiri-talk/browse_thread/thread/0b201bb80ea3eea0)
24
+
25
+ Sometimes people imply that we've forgotten, or that we don't how to
26
+ properly manage our codebase. Those people are super fun to respond
27
+ to!
28
+
29
+ We've gone back and forth a couple of times over the past few years,
30
+ but the current policy of Team Nokogiri is to **not** provide a
31
+ gemspec in the Github repo. This is a conscious choice, not an
32
+ oversight.
33
+
34
+
35
+ ## But You Didn't Answer the Question!
36
+
37
+ Ah, I was hoping you wouldn't notice. Well, OK, let's do this, if
38
+ you're serious about it.
39
+
40
+ I'd like to start by talking about _risk_. Specifically, the risk
41
+ associated with using a known-unstable version of Nokogiri.
42
+
43
+
44
+ ### Risk
45
+
46
+ One common way to evaluate the _risk_ of an incident is:
47
+
48
+ risk = probability x impact
49
+
50
+ You can read more about this on [the internets](http://en.wikipedia.org/wiki/Risk_Matrix).
51
+
52
+ The _risk_ associated with a Nokogiri bug could be loosely defined by
53
+ answering the questions:
54
+
55
+ * "How likely is it that a bug exists?" (probability)
56
+ * "How severe will the consequences of a bug be?" (impact)
57
+
58
+
59
+ ### Probability
60
+
61
+ The `master` branch should be considered unstable. Team Nokogiri are
62
+ not 10-foot-tall code-crunching robots; we are humans. We make
63
+ mistakes, and as a result, any arbitrary commit on `master` is likely
64
+ to contain bugs.
65
+
66
+ Just as an example, Nokogiri `master` was unstable for about five
67
+ months between November 2011 and March 2012. It was unstable not
68
+ because we were sloppy, or didn't care, but because the fixes were
69
+ hard and unobvious.
70
+
71
+ When we release Nokogiri, we test for memory leaks and invalid memory
72
+ access on all kinds of platforms with many flavors of Ruby and lots of
73
+ versions of libxml2. Because these tests are time-consuming, we don't
74
+ run them on every commit. We run them often when preparing a release.
75
+
76
+ If we're releasing Nokogiri, it means we think it's rock solid.
77
+
78
+ And if we're not releasing it, it means there are probably bugs.
79
+
80
+
81
+ ### Impact
82
+
83
+ Nokogiri is a gem with native extensions. This means it's not pure
84
+ Ruby -- there's C or Java code being compiled and run, which means
85
+ that there's always a chance that the gem will crash your application,
86
+ or worse. Possible outcomes include:
87
+
88
+ * leaking memory
89
+ * corrupting data
90
+ * making benign code crash (due to memory corruption)
91
+
92
+ So, then, a bug in a native extension can have much worse downside
93
+ than you might think. It's not just going to do something unexpected;
94
+ it's possibly going to do terrible, awful things to your application
95
+ and data.
96
+
97
+ **Nobody** wants that to happen. Especially Team Nokogiri.
98
+
99
+
100
+ ### Risk, Redux
101
+
102
+ So, if you accept the equation
103
+
104
+ risk = probability x impact
105
+
106
+ and you believe me when I say that:
107
+
108
+ * the probablility of a bug in unreleased code is high, and
109
+ * the impact of a bug is likely to be severe,
110
+
111
+ then you should easily see that the _risk_ associated with a bug in
112
+ Nokogiri is quite high.
113
+
114
+ Part of Team Nokogiri's job is to try to mitigate this risk. We have a
115
+ number of tactics that we use to accomplish this:
116
+
117
+ * we respond quickly to bug reports, particularly when they are possible memory issues
118
+ * we review each others' commits
119
+ * we have a thorough test suite, and we test-drive new features
120
+ * we discuss code design and issues on a core developer mailing list
121
+ * we use valgrind to test for memory issues (leaks and invalid
122
+ access) on multiple combinations of OS, libxml2 and Ruby
123
+ * we package release candidates, and encourage devs to use them
124
+ * **we do NOT commit a gemspec in our git repository**
125
+
126
+ Yes, that's right, the absence of a gemspec is a risk mitigation
127
+ tactic. Not only does Team Nokogiri not want to imply support for
128
+ `master`, we want to **actively discourage** people from using
129
+ it. Because it's not stable.
130
+
131
+
132
+ ## But I Want to Do It Anyway
133
+
134
+ Another option, is to email the [nokogiri-talk
135
+ list](http://groups.google.com/group/nokogiri-talk) and ask for a
136
+ release candidate to be built. We're pretty accommodating if there's a
137
+ bugfix that's a blocker for you. And if we can't release an RC, we'll
138
+ tell you why.
139
+
140
+ And in the end, nothing is stopping you from cloning the repo and
141
+ generating a private gemspec. This is an extra step or two, but it has
142
+ the benefit of making sure developers have thought through the costs
143
+ and risks involved; and it tends to select for developers who know
144
+ what they're doing.
145
+
146
+
147
+ ## In Conclusion
148
+
149
+ Team Nokogiri takes stability very seriously. We want everybody who
150
+ uses Nokogiri to have a pleasant experience. And so we want to make
151
+ sure that you're using the best software we can make.
152
+
153
+ Please keep in mind that we're trying very hard to do the right thing
154
+ for all Nokogiri users out there in Rubyland. Nokogiri loves you very
155
+ much, and we hope you love it back.