nokogiri 1.6.2.rc1-x64-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.
- checksums.yaml +7 -0
- data/.autotest +26 -0
- data/.editorconfig +17 -0
- data/.gemtest +0 -0
- data/.travis.yml +25 -0
- data/CHANGELOG.ja.rdoc +857 -0
- data/CHANGELOG.rdoc +880 -0
- data/C_CODING_STYLE.rdoc +33 -0
- data/Gemfile +21 -0
- data/Manifest.txt +371 -0
- data/README.ja.rdoc +112 -0
- data/README.rdoc +180 -0
- data/ROADMAP.md +89 -0
- data/Rakefile +351 -0
- data/STANDARD_RESPONSES.md +47 -0
- data/Y_U_NO_GEMSPEC.md +155 -0
- data/bin/nokogiri +78 -0
- data/build_all +130 -0
- data/dependencies.yml +4 -0
- data/ext/nokogiri/depend +358 -0
- data/ext/nokogiri/extconf.rb +453 -0
- data/ext/nokogiri/html_document.c +170 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +279 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +116 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/html_sax_push_parser.c +87 -0
- data/ext/nokogiri/html_sax_push_parser.h +9 -0
- data/ext/nokogiri/nokogiri.c +148 -0
- data/ext/nokogiri/nokogiri.h +164 -0
- data/ext/nokogiri/xml_attr.c +94 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +56 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +54 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +577 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +56 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +78 -0
- data/ext/nokogiri/xml_namespace.h +13 -0
- data/ext/nokogiri/xml_node.c +1541 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +467 -0
- data/ext/nokogiri/xml_node_set.h +14 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +681 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +161 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +312 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +262 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +115 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +205 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +63 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +52 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +307 -0
- data/ext/nokogiri/xml_xpath_context.h +10 -0
- data/ext/nokogiri/xslt_stylesheet.c +270 -0
- data/ext/nokogiri/xslt_stylesheet.h +14 -0
- data/lib/nokogiri.rb +137 -0
- data/lib/nokogiri/2.0/nokogiri.so +0 -0
- data/lib/nokogiri/2.1/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +27 -0
- data/lib/nokogiri/css/node.rb +52 -0
- data/lib/nokogiri/css/parser.rb +715 -0
- data/lib/nokogiri/css/parser.y +249 -0
- data/lib/nokogiri/css/parser_extras.rb +91 -0
- data/lib/nokogiri/css/syntax_error.rb +7 -0
- data/lib/nokogiri/css/tokenizer.rb +152 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +219 -0
- data/lib/nokogiri/decorators/slop.rb +35 -0
- data/lib/nokogiri/html.rb +37 -0
- data/lib/nokogiri/html/builder.rb +35 -0
- data/lib/nokogiri/html/document.rb +333 -0
- data/lib/nokogiri/html/document_fragment.rb +41 -0
- data/lib/nokogiri/html/element_description.rb +23 -0
- data/lib/nokogiri/html/element_description_defaults.rb +671 -0
- data/lib/nokogiri/html/entity_lookup.rb +13 -0
- data/lib/nokogiri/html/sax/parser.rb +52 -0
- data/lib/nokogiri/html/sax/parser_context.rb +16 -0
- data/lib/nokogiri/html/sax/push_parser.rb +16 -0
- data/lib/nokogiri/syntax_error.rb +4 -0
- data/lib/nokogiri/version.rb +106 -0
- data/lib/nokogiri/xml.rb +73 -0
- data/lib/nokogiri/xml/attr.rb +14 -0
- data/lib/nokogiri/xml/attribute_decl.rb +18 -0
- data/lib/nokogiri/xml/builder.rb +443 -0
- data/lib/nokogiri/xml/cdata.rb +11 -0
- data/lib/nokogiri/xml/character_data.rb +7 -0
- data/lib/nokogiri/xml/document.rb +279 -0
- data/lib/nokogiri/xml/document_fragment.rb +112 -0
- data/lib/nokogiri/xml/dtd.rb +32 -0
- data/lib/nokogiri/xml/element_content.rb +36 -0
- data/lib/nokogiri/xml/element_decl.rb +13 -0
- data/lib/nokogiri/xml/entity_decl.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +13 -0
- data/lib/nokogiri/xml/node.rb +982 -0
- data/lib/nokogiri/xml/node/save_options.rb +61 -0
- data/lib/nokogiri/xml/node_set.rb +355 -0
- data/lib/nokogiri/xml/notation.rb +6 -0
- data/lib/nokogiri/xml/parse_options.rb +98 -0
- data/lib/nokogiri/xml/pp.rb +2 -0
- data/lib/nokogiri/xml/pp/character_data.rb +18 -0
- data/lib/nokogiri/xml/pp/node.rb +56 -0
- data/lib/nokogiri/xml/processing_instruction.rb +8 -0
- data/lib/nokogiri/xml/reader.rb +112 -0
- data/lib/nokogiri/xml/relax_ng.rb +32 -0
- data/lib/nokogiri/xml/sax.rb +4 -0
- data/lib/nokogiri/xml/sax/document.rb +171 -0
- data/lib/nokogiri/xml/sax/parser.rb +123 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
- data/lib/nokogiri/xml/schema.rb +63 -0
- data/lib/nokogiri/xml/syntax_error.rb +47 -0
- data/lib/nokogiri/xml/text.rb +9 -0
- data/lib/nokogiri/xml/xpath.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +11 -0
- data/lib/nokogiri/xml/xpath_context.rb +16 -0
- data/lib/nokogiri/xslt.rb +56 -0
- data/lib/nokogiri/xslt/stylesheet.rb +25 -0
- data/lib/xsd/xmlparser/nokogiri.rb +102 -0
- data/suppressions/README.txt +1 -0
- data/suppressions/nokogiri_ree-1.8.7.358.supp +61 -0
- data/suppressions/nokogiri_ruby-1.8.7.370.supp +0 -0
- data/suppressions/nokogiri_ruby-1.9.2.320.supp +28 -0
- data/suppressions/nokogiri_ruby-1.9.3.327.supp +28 -0
- data/tasks/nokogiri.org.rb +24 -0
- data/tasks/test.rb +95 -0
- data/test/css/test_nthiness.rb +222 -0
- data/test/css/test_parser.rb +358 -0
- data/test/css/test_tokenizer.rb +198 -0
- data/test/css/test_xpath_visitor.rb +96 -0
- data/test/decorators/test_slop.rb +16 -0
- data/test/files/2ch.html +108 -0
- data/test/files/address_book.rlx +12 -0
- data/test/files/address_book.xml +10 -0
- data/test/files/atom.xml +344 -0
- data/test/files/bar/bar.xsd +4 -0
- data/test/files/bogus.xml +0 -0
- data/test/files/dont_hurt_em_why.xml +422 -0
- data/test/files/encoding.html +82 -0
- data/test/files/encoding.xhtml +84 -0
- data/test/files/exslt.xml +8 -0
- data/test/files/exslt.xslt +35 -0
- data/test/files/foo/foo.xsd +4 -0
- data/test/files/metacharset.html +10 -0
- data/test/files/noencoding.html +47 -0
- data/test/files/po.xml +32 -0
- data/test/files/po.xsd +66 -0
- data/test/files/saml/saml20assertion_schema.xsd +283 -0
- data/test/files/saml/saml20protocol_schema.xsd +302 -0
- data/test/files/saml/xenc_schema.xsd +146 -0
- data/test/files/saml/xmldsig_schema.xsd +318 -0
- data/test/files/shift_jis.html +10 -0
- data/test/files/shift_jis.xml +5 -0
- data/test/files/shift_jis_no_charset.html +9 -0
- data/test/files/snuggles.xml +3 -0
- data/test/files/staff.dtd +10 -0
- data/test/files/staff.xml +59 -0
- data/test/files/staff.xslt +32 -0
- data/test/files/test_document_url/bar.xml +2 -0
- data/test/files/test_document_url/document.dtd +4 -0
- data/test/files/test_document_url/document.xml +6 -0
- data/test/files/tlm.html +850 -0
- data/test/files/to_be_xincluded.xml +2 -0
- data/test/files/valid_bar.xml +2 -0
- data/test/files/xinclude.xml +4 -0
- data/test/helper.rb +164 -0
- data/test/html/sax/test_parser.rb +141 -0
- data/test/html/sax/test_parser_context.rb +46 -0
- data/test/html/test_builder.rb +164 -0
- data/test/html/test_document.rb +619 -0
- data/test/html/test_document_encoding.rb +148 -0
- data/test/html/test_document_fragment.rb +261 -0
- data/test/html/test_element_description.rb +105 -0
- data/test/html/test_named_characters.rb +14 -0
- data/test/html/test_node.rb +196 -0
- data/test/html/test_node_encoding.rb +27 -0
- data/test/namespaces/test_additional_namespaces_in_builder_doc.rb +14 -0
- data/test/namespaces/test_namespaces_in_builder_doc.rb +75 -0
- data/test/namespaces/test_namespaces_in_cloned_doc.rb +31 -0
- data/test/namespaces/test_namespaces_in_created_doc.rb +75 -0
- data/test/namespaces/test_namespaces_in_parsed_doc.rb +66 -0
- data/test/test_convert_xpath.rb +135 -0
- data/test/test_css_cache.rb +45 -0
- data/test/test_encoding_handler.rb +46 -0
- data/test/test_memory_leak.rb +156 -0
- data/test/test_nokogiri.rb +138 -0
- data/test/test_reader.rb +558 -0
- data/test/test_soap4r_sax.rb +52 -0
- data/test/test_xslt_transforms.rb +279 -0
- data/test/xml/node/test_save_options.rb +28 -0
- data/test/xml/node/test_subclass.rb +44 -0
- data/test/xml/sax/test_parser.rb +382 -0
- data/test/xml/sax/test_parser_context.rb +115 -0
- data/test/xml/sax/test_push_parser.rb +157 -0
- data/test/xml/test_attr.rb +64 -0
- data/test/xml/test_attribute_decl.rb +86 -0
- data/test/xml/test_builder.rb +315 -0
- data/test/xml/test_c14n.rb +161 -0
- data/test/xml/test_cdata.rb +48 -0
- data/test/xml/test_comment.rb +29 -0
- data/test/xml/test_document.rb +934 -0
- data/test/xml/test_document_encoding.rb +28 -0
- data/test/xml/test_document_fragment.rb +228 -0
- data/test/xml/test_dtd.rb +187 -0
- data/test/xml/test_dtd_encoding.rb +33 -0
- data/test/xml/test_element_content.rb +56 -0
- data/test/xml/test_element_decl.rb +73 -0
- data/test/xml/test_entity_decl.rb +122 -0
- data/test/xml/test_entity_reference.rb +245 -0
- data/test/xml/test_namespace.rb +95 -0
- data/test/xml/test_node.rb +1155 -0
- data/test/xml/test_node_attributes.rb +113 -0
- data/test/xml/test_node_encoding.rb +107 -0
- data/test/xml/test_node_inheritance.rb +32 -0
- data/test/xml/test_node_reparenting.rb +374 -0
- data/test/xml/test_node_set.rb +755 -0
- data/test/xml/test_parse_options.rb +64 -0
- data/test/xml/test_processing_instruction.rb +30 -0
- data/test/xml/test_reader_encoding.rb +142 -0
- data/test/xml/test_relax_ng.rb +60 -0
- data/test/xml/test_schema.rb +129 -0
- data/test/xml/test_syntax_error.rb +12 -0
- data/test/xml/test_text.rb +45 -0
- data/test/xml/test_unparented_node.rb +422 -0
- data/test/xml/test_xinclude.rb +83 -0
- data/test/xml/test_xpath.rb +376 -0
- data/test/xslt/test_custom_functions.rb +133 -0
- data/test/xslt/test_exception_handling.rb +37 -0
- data/test_all +81 -0
- metadata +601 -0
data/README.rdoc
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
= Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri] {<img src="https://codeclimate.com/github/sparklemotion/nokogiri.png" />}[https://codeclimate.com/github/sparklemotion/nokogiri] {<img src="https://www.versioneye.com/ruby/nokogiri/badge.png" alt="Dependency Status" />}[https://www.versioneye.com/ruby/nokogiri]
|
2
|
+
* http://nokogiri.org
|
3
|
+
* https://github.com/sparklemotion/nokogiri/wikis
|
4
|
+
* https://github.com/sparklemotion/nokogiri/tree/master
|
5
|
+
* https://groups.google.com/group/nokogiri-talk
|
6
|
+
* https://github.com/sparklemotion/nokogiri/issues
|
7
|
+
|
8
|
+
== DESCRIPTION:
|
9
|
+
|
10
|
+
Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's
|
11
|
+
many features is the ability to search documents via XPath or CSS3 selectors.
|
12
|
+
|
13
|
+
XML is like violence - if it doesn’t solve your problems, you are not using
|
14
|
+
enough of it.
|
15
|
+
|
16
|
+
== FEATURES:
|
17
|
+
|
18
|
+
* XPath 1.0 support for document searching
|
19
|
+
* CSS3 selector support for document searching
|
20
|
+
* XML/HTML builder
|
21
|
+
|
22
|
+
Nokogiri parses and searches XML/HTML very quickly, and also has
|
23
|
+
correctly implemented CSS3 selector support as well as XPath 1.0 support.
|
24
|
+
|
25
|
+
== SUPPORT:
|
26
|
+
|
27
|
+
Before filing a bug report, please read our {submission guidelines}[http://nokogiri.org/tutorials/getting_help.html] at:
|
28
|
+
|
29
|
+
* http://nokogiri.org/tutorials/getting_help.html
|
30
|
+
|
31
|
+
The Nokogiri {mailing list}[https://groups.google.com/group/nokogiri-talk]
|
32
|
+
is available here:
|
33
|
+
|
34
|
+
* https://groups.google.com/group/nokogiri-talk
|
35
|
+
|
36
|
+
The {bug tracker}[https://github.com/sparklemotion/nokogiri/issues]
|
37
|
+
is available here:
|
38
|
+
|
39
|
+
* https://github.com/sparklemotion/nokogiri/issues
|
40
|
+
|
41
|
+
The IRC channel is #nokogiri on freenode.
|
42
|
+
|
43
|
+
== SYNOPSIS:
|
44
|
+
|
45
|
+
require 'nokogiri'
|
46
|
+
require 'open-uri'
|
47
|
+
|
48
|
+
# Get a Nokogiri::HTML::Document for the page we’re interested in...
|
49
|
+
|
50
|
+
doc = Nokogiri::HTML(open('http://www.google.com/search?q=sparklemotion'))
|
51
|
+
|
52
|
+
# Do funky things with it using Nokogiri::XML::Node methods...
|
53
|
+
|
54
|
+
####
|
55
|
+
# Search for nodes by css
|
56
|
+
doc.css('h3.r a').each do |link|
|
57
|
+
puts link.content
|
58
|
+
end
|
59
|
+
|
60
|
+
####
|
61
|
+
# Search for nodes by xpath
|
62
|
+
doc.xpath('//h3/a').each do |link|
|
63
|
+
puts link.content
|
64
|
+
end
|
65
|
+
|
66
|
+
####
|
67
|
+
# Or mix and match.
|
68
|
+
doc.search('h3.r a.l', '//h3/a').each do |link|
|
69
|
+
puts link.content
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
== REQUIREMENTS:
|
74
|
+
|
75
|
+
* ruby 1.9.3 or higher
|
76
|
+
|
77
|
+
* in Nokogiri 1.6.0 and later libxml2 and libxslt are bundled with the
|
78
|
+
gem, but if you want to use them installed on the system:
|
79
|
+
|
80
|
+
* libxml2 >=2.6.17 and <2.9.0, with iconv support
|
81
|
+
(libxml2-dev/-devel is required too)
|
82
|
+
|
83
|
+
* libxslt, built with and supported by the given libxml2
|
84
|
+
(libxslt-dev/-devel is required too)
|
85
|
+
|
86
|
+
== ENCODING:
|
87
|
+
|
88
|
+
Strings are always stored as UTF-8 internally. Methods that return
|
89
|
+
text values will always return UTF-8 encoded strings. Methods that
|
90
|
+
return XML (like to_xml, to_html and inner_html) will return a string
|
91
|
+
encoded like the source document.
|
92
|
+
|
93
|
+
*WARNING*
|
94
|
+
|
95
|
+
Some documents declare one particular encoding, but use a different
|
96
|
+
one. So, which encoding should the parser choose?
|
97
|
+
|
98
|
+
Remember that data is just a stream of bytes. Only we humans add
|
99
|
+
meaning to that stream. Any particular set of bytes could be valid
|
100
|
+
characters in multiple encodings, so detecting encoding with 100%
|
101
|
+
accuracy is not possible. libxml2 does its best, but it can't be right
|
102
|
+
100% of the time.
|
103
|
+
|
104
|
+
If you want Nokogiri to handle the document encoding properly, your
|
105
|
+
best bet is to explicitly set the encoding. Here is an example of
|
106
|
+
explicitly setting the encoding to EUC-JP on the parser:
|
107
|
+
|
108
|
+
doc = Nokogiri.XML('<foo><bar /><foo>', nil, 'EUC-JP')
|
109
|
+
|
110
|
+
== INSTALL:
|
111
|
+
|
112
|
+
* sudo gem install nokogiri
|
113
|
+
|
114
|
+
=== Binary packages
|
115
|
+
|
116
|
+
Binary packages are available for:
|
117
|
+
|
118
|
+
* SuSE[https://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/]
|
119
|
+
* Fedora[http://s390.koji.fedoraproject.org/koji/packageinfo?packageID=6756]
|
120
|
+
|
121
|
+
== DEVELOPMENT:
|
122
|
+
|
123
|
+
=== Developing on C Ruby (MRI)
|
124
|
+
|
125
|
+
Developing Nokogiri requires racc and rexical to generate the parser and
|
126
|
+
tokenizer. To start development, make sure you have `libxml2` and `libxslt`
|
127
|
+
installed.
|
128
|
+
|
129
|
+
Then install core gems and bootstrap:
|
130
|
+
|
131
|
+
$ gem install hoe rake-compiler mini_portile
|
132
|
+
$ rake newb
|
133
|
+
|
134
|
+
=== Developing on JRuby
|
135
|
+
|
136
|
+
Currently, development with JRuby depends on CRuby being installed. With
|
137
|
+
CRuby, install racc and rexical:
|
138
|
+
|
139
|
+
$ gem install racc rexical
|
140
|
+
|
141
|
+
Make sure hoe and rake compiler are installed with JRuby:
|
142
|
+
|
143
|
+
$ jgem install hoe rake-compiler
|
144
|
+
|
145
|
+
Then run rake:
|
146
|
+
|
147
|
+
$ jruby -S rake
|
148
|
+
|
149
|
+
== LICENSE:
|
150
|
+
|
151
|
+
(The MIT License)
|
152
|
+
|
153
|
+
Copyright (c) 2008 - 2013:
|
154
|
+
|
155
|
+
* {Aaron Patterson}[http://tenderlovemaking.com]
|
156
|
+
* {Mike Dalessio}[http://mike.daless.io]
|
157
|
+
* {Charles Nutter}[http://blog.headius.com]
|
158
|
+
* {Sergio Arbeo}[http://www.serabe.com]
|
159
|
+
* {Patrick Mahoney}[http://polycrystal.org]
|
160
|
+
* {Yoko Harada}[http://yokolet.blogspot.com]
|
161
|
+
* {Akinori MUSHA}[https://akinori.org]
|
162
|
+
|
163
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
164
|
+
a copy of this software and associated documentation files (the
|
165
|
+
'Software'), to deal in the Software without restriction, including
|
166
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
167
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
168
|
+
permit persons to whom the Software is furnished to do so, subject to
|
169
|
+
the following conditions:
|
170
|
+
|
171
|
+
The above copyright notice and this permission notice shall be
|
172
|
+
included in all copies or substantial portions of the Software.
|
173
|
+
|
174
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
175
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
176
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
177
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
178
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
179
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
180
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/ROADMAP.md
ADDED
@@ -0,0 +1,89 @@
|
|
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
|
+
* Some ideas for a better attributes API?
|
23
|
+
* (closed) https://github.com/sparklemotion/nokogiri/issues/666
|
24
|
+
* https://github.com/sparklemotion/nokogiri/issues/765
|
25
|
+
|
26
|
+
|
27
|
+
## improve CSS query parsing
|
28
|
+
|
29
|
+
* https://github.com/sparklemotion/nokogiri/issues/528
|
30
|
+
support `:not()` with a nontrivial argument, like `:not(div p.c)`
|
31
|
+
|
32
|
+
* https://github.com/sparklemotion/nokogiri/issues/451
|
33
|
+
chained :not pseudoselectors
|
34
|
+
|
35
|
+
* better jQuery selector and CSS pseudo-selector support:
|
36
|
+
* https://github.com/sparklemotion/nokogiri/issues/621
|
37
|
+
* https://github.com/sparklemotion/nokogiri/issues/342
|
38
|
+
* https://github.com/sparklemotion/nokogiri/issues/628
|
39
|
+
* https://github.com/sparklemotion/nokogiri/issues/652
|
40
|
+
* https://github.com/sparklemotion/nokogiri/issues/688
|
41
|
+
|
42
|
+
* https://github.com/sparklemotion/nokogiri/issues/394
|
43
|
+
nth-of-type is wrong, and possibly other selectors as well
|
44
|
+
|
45
|
+
* https://github.com/sparklemotion/nokogiri/issues/309
|
46
|
+
incorrect query being executed
|
47
|
+
|
48
|
+
* https://github.com/sparklemotion/nokogiri/issues/350
|
49
|
+
:has is wrong?
|
50
|
+
|
51
|
+
|
52
|
+
## DocumentFragment
|
53
|
+
|
54
|
+
* there are a few tickets about searches not working properly if you
|
55
|
+
use or do not use the context node as part of the search.
|
56
|
+
- https://github.com/sparklemotion/nokogiri/issues/213
|
57
|
+
- https://github.com/sparklemotion/nokogiri/issues/370
|
58
|
+
- https://github.com/sparklemotion/nokogiri/issues/454
|
59
|
+
- https://github.com/sparklemotion/nokogiri/issues/572
|
60
|
+
|
61
|
+
|
62
|
+
## Better Syntax for custom XPath function handler
|
63
|
+
|
64
|
+
* https://github.com/sparklemotion/nokogiri/pull/464
|
65
|
+
|
66
|
+
|
67
|
+
## Better Syntax around Node#xpath and NodeSet#xpath
|
68
|
+
|
69
|
+
* look at those methods, and use of Node#extract_params in Node#{css,search}
|
70
|
+
* we should standardize on a hash of options for these and other calls
|
71
|
+
* what should NodeSet#xpath return?
|
72
|
+
* https://github.com/sparklemotion/nokogiri/issues/656
|
73
|
+
* also, clean up or unify the implementations of #xpath-and-friends in Node and NodeSet
|
74
|
+
* implementations are very similar, but no shared code :(
|
75
|
+
* decorate nodes in a consistent manner
|
76
|
+
|
77
|
+
## Encoding
|
78
|
+
|
79
|
+
We have a lot of issues open around encoding. How bad are things?
|
80
|
+
Somebody who knows encoding well should head this up.
|
81
|
+
|
82
|
+
* Extract EncodingReader as a real object that can be injected
|
83
|
+
https://groups.google.com/forum/#!msg/nokogiri-talk/arJeAtMqvkg/tGihB-iBRSAJ
|
84
|
+
|
85
|
+
|
86
|
+
## Reader
|
87
|
+
|
88
|
+
It's fundamentally broken, in that we can't stop people from crashing
|
89
|
+
their application if they want to use object reference unsafely.
|
data/Rakefile
ADDED
@@ -0,0 +1,351 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'shellwords'
|
4
|
+
|
5
|
+
gem 'hoe'
|
6
|
+
require 'hoe'
|
7
|
+
Hoe.plugin :debugging
|
8
|
+
Hoe.plugin :git
|
9
|
+
Hoe.plugin :gemspec
|
10
|
+
Hoe.plugin :bundler
|
11
|
+
Hoe.add_include_dirs '.'
|
12
|
+
|
13
|
+
GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
|
14
|
+
GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
|
15
|
+
CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
|
16
|
+
|
17
|
+
def java?
|
18
|
+
/java/ === RUBY_PLATFORM
|
19
|
+
end
|
20
|
+
|
21
|
+
ENV['LANG'] = "en_US.UTF-8" # UBUNTU 10.04, Y U NO DEFAULT TO UTF-8?
|
22
|
+
|
23
|
+
CrossRuby = Struct.new(:version, :host) {
|
24
|
+
def ver
|
25
|
+
@ver ||= version[/\A[^-]+/]
|
26
|
+
end
|
27
|
+
|
28
|
+
def api_ver_suffix
|
29
|
+
case ver
|
30
|
+
when /\A([2-9])\.([0-9])\./
|
31
|
+
"#{$1}#{$2}0"
|
32
|
+
when /\A1\.9\./
|
33
|
+
'191'
|
34
|
+
else
|
35
|
+
raise "unsupported version: #{ver}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def platform
|
40
|
+
@platform ||=
|
41
|
+
case host
|
42
|
+
when /\Ax86_64-/
|
43
|
+
'x64-mingw32'
|
44
|
+
when /\Ai[3-6]86-/
|
45
|
+
'x86-mingw32'
|
46
|
+
else
|
47
|
+
raise "unsupported host: #{host}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def tool(name)
|
52
|
+
(@binutils_prefix ||=
|
53
|
+
case platform
|
54
|
+
when 'x64-mingw32'
|
55
|
+
'x86_64-w64-mingw32-'
|
56
|
+
when 'x86-mingw32'
|
57
|
+
'i686-w64-mingw32-'
|
58
|
+
end) + name
|
59
|
+
end
|
60
|
+
|
61
|
+
def target
|
62
|
+
case platform
|
63
|
+
when 'x64-mingw32'
|
64
|
+
'pei-x86-64'
|
65
|
+
when 'x86-mingw32'
|
66
|
+
'pei-i386'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def libruby_dll
|
71
|
+
case platform
|
72
|
+
when 'x64-mingw32'
|
73
|
+
"x64-msvcrt-ruby#{api_ver_suffix}.dll"
|
74
|
+
when 'x86-mingw32'
|
75
|
+
"msvcrt-ruby#{api_ver_suffix}.dll"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def dlls
|
80
|
+
[
|
81
|
+
'kernel32.dll',
|
82
|
+
'msvcrt.dll',
|
83
|
+
'ws2_32.dll',
|
84
|
+
*(case
|
85
|
+
when ver >= '2.0.0'
|
86
|
+
'user32.dll'
|
87
|
+
end),
|
88
|
+
libruby_dll
|
89
|
+
]
|
90
|
+
end
|
91
|
+
}
|
92
|
+
|
93
|
+
CROSS_RUBIES = File.read('.cross_rubies').lines.flat_map { |line|
|
94
|
+
case line
|
95
|
+
when /\A([^#]+):([^#]+)/
|
96
|
+
CrossRuby.new($1, $2)
|
97
|
+
else
|
98
|
+
[]
|
99
|
+
end
|
100
|
+
}
|
101
|
+
|
102
|
+
ENV['RUBY_CC_VERSION'] ||= CROSS_RUBIES.map(&:ver).uniq.join(":")
|
103
|
+
|
104
|
+
require 'tasks/nokogiri.org'
|
105
|
+
|
106
|
+
HOE = Hoe.spec 'nokogiri' do
|
107
|
+
developer 'Aaron Patterson', 'aaronp@rubyforge.org'
|
108
|
+
developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
|
109
|
+
developer 'Yoko Harada', 'yokolet@gmail.com'
|
110
|
+
developer 'Tim Elliott', 'tle@holymonkey.com'
|
111
|
+
developer 'Akinori MUSHA', 'knu@idaemons.org'
|
112
|
+
|
113
|
+
self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
|
114
|
+
self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
|
115
|
+
|
116
|
+
self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
|
117
|
+
|
118
|
+
|
119
|
+
self.clean_globs += [
|
120
|
+
'nokogiri.gemspec',
|
121
|
+
'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
|
122
|
+
'lib/nokogiri/[0-9].[0-9]',
|
123
|
+
'ports/*.installed',
|
124
|
+
'ports/{i[3-6]86,x86_64}-{w64-,}mingw32*',
|
125
|
+
'ports/libxml2',
|
126
|
+
'ports/libxslt',
|
127
|
+
# GENERATED_PARSER,
|
128
|
+
# GENERATED_TOKENIZER
|
129
|
+
]
|
130
|
+
|
131
|
+
unless java?
|
132
|
+
self.extra_deps += [
|
133
|
+
["mini_portile", "~> 0.5.2"],
|
134
|
+
]
|
135
|
+
end
|
136
|
+
|
137
|
+
self.extra_dev_deps += [
|
138
|
+
["hoe-bundler", ">= 1.1"],
|
139
|
+
["hoe-debugging", ">= 1.0.3"],
|
140
|
+
["hoe-gemspec", ">= 1.0"],
|
141
|
+
["hoe-git", ">= 1.4"],
|
142
|
+
["minitest", "~> 2.2.2"],
|
143
|
+
["rake", ">= 0.9"],
|
144
|
+
["rake-compiler", "~> 0.9.2"],
|
145
|
+
["racc", ">= 1.4.6"],
|
146
|
+
["rexical", ">= 1.0.5"]
|
147
|
+
]
|
148
|
+
|
149
|
+
if java?
|
150
|
+
self.spec_extras = { :platform => 'java' }
|
151
|
+
else
|
152
|
+
self.spec_extras = {
|
153
|
+
:extensions => ["ext/nokogiri/extconf.rb"],
|
154
|
+
:required_ruby_version => '>= 1.9.2'
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
self.testlib = :minitest
|
159
|
+
end
|
160
|
+
HOE.spec.licenses = ['MIT']
|
161
|
+
|
162
|
+
# ----------------------------------------
|
163
|
+
|
164
|
+
def add_file_to_gem relative_path
|
165
|
+
target_path = File.join gem_build_path, relative_path
|
166
|
+
target_dir = File.dirname(target_path)
|
167
|
+
mkdir_p target_dir unless File.directory?(target_dir)
|
168
|
+
rm_f target_path
|
169
|
+
safe_ln relative_path, target_path
|
170
|
+
HOE.spec.files += [relative_path]
|
171
|
+
end
|
172
|
+
|
173
|
+
def gem_build_path
|
174
|
+
File.join 'pkg', HOE.spec.full_name
|
175
|
+
end
|
176
|
+
|
177
|
+
if java?
|
178
|
+
# TODO: clean this section up.
|
179
|
+
require "rake/javaextensiontask"
|
180
|
+
Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
|
181
|
+
jruby_home = RbConfig::CONFIG['prefix']
|
182
|
+
ext.ext_dir = 'ext/java'
|
183
|
+
ext.lib_dir = 'lib/nokogiri'
|
184
|
+
ext.source_version = '1.6'
|
185
|
+
ext.target_version = '1.6'
|
186
|
+
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
|
187
|
+
ext.classpath = jars.map { |x| File.expand_path x }.join ':'
|
188
|
+
end
|
189
|
+
|
190
|
+
task gem_build_path => [:compile] do
|
191
|
+
add_file_to_gem 'lib/nokogiri/nokogiri.jar'
|
192
|
+
end
|
193
|
+
else
|
194
|
+
begin
|
195
|
+
require 'rake/extensioncompiler'
|
196
|
+
# Ensure mingw compiler is installed
|
197
|
+
Rake::ExtensionCompiler.mingw_host
|
198
|
+
mingw_available = true
|
199
|
+
rescue
|
200
|
+
puts "WARNING: cross compilation not available: #{$!}"
|
201
|
+
mingw_available = false
|
202
|
+
end
|
203
|
+
require "rake/extensiontask"
|
204
|
+
|
205
|
+
HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
|
206
|
+
|
207
|
+
dependencies = YAML.load_file("dependencies.yml")
|
208
|
+
|
209
|
+
task gem_build_path do
|
210
|
+
%w[libxml2 libxslt].each do |lib|
|
211
|
+
version = dependencies[lib]
|
212
|
+
archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
|
213
|
+
add_file_to_gem archive
|
214
|
+
patchesdir = File.join("ports", "patches", lib)
|
215
|
+
patches = `#{['git', 'ls-files', patchesdir].shelljoin}`.split("\n").grep(/\.patch\z/)
|
216
|
+
patches.each { |patch|
|
217
|
+
add_file_to_gem patch
|
218
|
+
}
|
219
|
+
(untracked = Dir[File.join(patchesdir, '*.patch')] - patches).empty? or
|
220
|
+
at_exit {
|
221
|
+
untracked.each { |patch|
|
222
|
+
puts "** WARNING: untracked patch file not added to gem: #{patch}"
|
223
|
+
}
|
224
|
+
}
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
|
229
|
+
ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
|
230
|
+
ext.config_options << ENV['EXTOPTS']
|
231
|
+
if mingw_available
|
232
|
+
ext.cross_compile = true
|
233
|
+
ext.cross_platform = CROSS_RUBIES.map(&:platform).uniq
|
234
|
+
ext.cross_config_options << "--enable-cross-build"
|
235
|
+
ext.cross_compiling do |spec|
|
236
|
+
libs = dependencies.map { |name, version| "#{name}-#{version}" }.join(', ')
|
237
|
+
|
238
|
+
spec.post_install_message = <<-EOS
|
239
|
+
Nokogiri is built with the packaged libraries: #{libs}.
|
240
|
+
EOS
|
241
|
+
spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# ----------------------------------------
|
248
|
+
|
249
|
+
desc "Generate css/parser.rb and css/tokenizer.rex"
|
250
|
+
task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
|
251
|
+
task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
|
252
|
+
|
253
|
+
# This is a big hack to make sure that the racc and rexical
|
254
|
+
# dependencies in the Gemfile are constrainted to ruby platforms
|
255
|
+
# (i.e. MRI and Rubinius). There's no way to do that through hoe,
|
256
|
+
# and any solution will require changing hoe and hoe-bundler.
|
257
|
+
old_gemfile_task = Rake::Task['bundler:gemfile'] rescue nil
|
258
|
+
task 'bundler:gemfile' do
|
259
|
+
old_gemfile_task.invoke if old_gemfile_task
|
260
|
+
|
261
|
+
lines = File.open('Gemfile', 'r') { |f| f.readlines }.map do |line|
|
262
|
+
line =~ /racc|rexical/ ? "#{line.strip}, :platform => :ruby" : line
|
263
|
+
end
|
264
|
+
File.open('Gemfile', 'w') { |f| lines.each { |line| f.puts line } }
|
265
|
+
end
|
266
|
+
|
267
|
+
file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
|
268
|
+
racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
|
269
|
+
racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
|
270
|
+
racc = %x{command -v racc}.strip if racc.empty?
|
271
|
+
sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
|
272
|
+
end
|
273
|
+
|
274
|
+
file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
|
275
|
+
sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
|
276
|
+
end
|
277
|
+
|
278
|
+
[:compile, :check_manifest].each do |task_name|
|
279
|
+
Rake::Task[task_name].prerequisites << GENERATED_PARSER
|
280
|
+
Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
|
281
|
+
end
|
282
|
+
|
283
|
+
# ----------------------------------------
|
284
|
+
|
285
|
+
desc "set environment variables to build and/or test with debug options"
|
286
|
+
task :debug do
|
287
|
+
ENV['NOKOGIRI_DEBUG'] = "true"
|
288
|
+
ENV['CFLAGS'] ||= ""
|
289
|
+
ENV['CFLAGS'] += " -DDEBUG"
|
290
|
+
end
|
291
|
+
|
292
|
+
require 'tasks/test'
|
293
|
+
|
294
|
+
task :java_debug do
|
295
|
+
ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
|
296
|
+
end
|
297
|
+
|
298
|
+
if java?
|
299
|
+
task :test_19 => :test
|
300
|
+
task :test_20 do
|
301
|
+
ENV['JRUBY_OPTS'] = "--2.0"
|
302
|
+
Rake::Task["test"].invoke
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
Rake::Task[:test].prerequisites << :compile
|
307
|
+
Rake::Task[:test].prerequisites << :java_debug
|
308
|
+
Rake::Task[:test].prerequisites << :check_extra_deps unless java?
|
309
|
+
|
310
|
+
if Hoe.plugins.include?(:debugging)
|
311
|
+
['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
|
312
|
+
Rake::Task["test:#{task_name}"].prerequisites << :compile
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
# ----------------------------------------
|
317
|
+
|
318
|
+
def verify_dll(dll, cross_ruby)
|
319
|
+
dll_imports = cross_ruby.dlls
|
320
|
+
dump = `#{['env', 'LANG=C', cross_ruby.tool('objdump'), '-p', dll].shelljoin}`
|
321
|
+
raise "unexpected file format for generated dll #{dll}" unless /file format #{Regexp.quote(cross_ruby.target)}\s/ === dump
|
322
|
+
raise "export function Init_nokogiri not in dll #{dll}" unless /Table.*\sInit_nokogiri\s/mi === dump
|
323
|
+
|
324
|
+
# Verify that the expected DLL dependencies match the actual dependencies
|
325
|
+
# and that no further dependencies exist.
|
326
|
+
dll_imports_is = dump.scan(/DLL Name: (.*)$/).map(&:first).map(&:downcase).uniq
|
327
|
+
if dll_imports_is.sort != dll_imports.sort
|
328
|
+
raise "unexpected dll imports #{dll_imports_is.inspect} in #{dll}"
|
329
|
+
end
|
330
|
+
puts "#{dll}: Looks good!"
|
331
|
+
end
|
332
|
+
|
333
|
+
task :cross do
|
334
|
+
rake_compiler_config_path = File.expand_path("~/.rake-compiler/config.yml")
|
335
|
+
unless File.exists? rake_compiler_config_path
|
336
|
+
raise "rake-compiler has not installed any cross rubies. Try using rake-compiler-dev-box for building binary windows gems.'"
|
337
|
+
end
|
338
|
+
|
339
|
+
CROSS_RUBIES.each do |cross_ruby|
|
340
|
+
task "tmp/#{cross_ruby.platform}/nokogiri/#{cross_ruby.ver}/nokogiri.so" do |t|
|
341
|
+
# To reduce the gem file size strip mingw32 dlls before packaging
|
342
|
+
sh [cross_ruby.tool('strip'), '-S', t.name].shelljoin
|
343
|
+
verify_dll t.name, cross_ruby
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
desc "build a windows gem without all the ceremony."
|
349
|
+
task "gem:windows" => %w[cross native gem]
|
350
|
+
|
351
|
+
# vim: syntax=Ruby
|