nokogiri 1.5.0.beta.1 → 1.5.0.beta.2
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.
- data/CHANGELOG.ja.rdoc +28 -8
- data/CHANGELOG.rdoc +23 -0
- data/Manifest.txt +63 -1
- data/README.ja.rdoc +1 -1
- data/README.rdoc +22 -4
- data/Rakefile +6 -2
- data/ext/java/nokogiri/EncodingHandler.java +92 -0
- data/ext/java/nokogiri/HtmlDocument.java +116 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +111 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +45 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -0
- data/ext/java/nokogiri/NokogiriService.java +370 -0
- data/ext/java/nokogiri/XmlAttr.java +147 -0
- data/ext/java/nokogiri/XmlAttributeDecl.java +98 -0
- data/ext/java/nokogiri/XmlCdata.java +50 -0
- data/ext/java/nokogiri/XmlComment.java +47 -0
- data/ext/java/nokogiri/XmlDocument.java +463 -0
- data/ext/java/nokogiri/XmlDocumentFragment.java +207 -0
- data/ext/java/nokogiri/XmlDtd.java +427 -0
- data/ext/java/nokogiri/XmlElement.java +172 -0
- data/ext/java/nokogiri/XmlElementContent.java +350 -0
- data/ext/java/nokogiri/XmlElementDecl.java +115 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +129 -0
- data/ext/java/nokogiri/XmlEntityReference.java +42 -0
- data/ext/java/nokogiri/XmlNamespace.java +77 -0
- data/ext/java/nokogiri/XmlNode.java +1399 -0
- data/ext/java/nokogiri/XmlNodeSet.java +248 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +70 -0
- data/ext/java/nokogiri/XmlReader.java +373 -0
- data/ext/java/nokogiri/XmlRelaxng.java +166 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +308 -0
- data/ext/java/nokogiri/XmlSaxPushParser.java +146 -0
- data/ext/java/nokogiri/XmlSchema.java +142 -0
- data/ext/java/nokogiri/XmlSyntaxError.java +84 -0
- data/ext/java/nokogiri/XmlText.java +96 -0
- data/ext/java/nokogiri/XmlXpathContext.java +130 -0
- data/ext/java/nokogiri/XsltStylesheet.java +126 -0
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +181 -0
- data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +39 -0
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +42 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +251 -0
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +526 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +136 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +80 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +37 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +54 -0
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +49 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +88 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +23 -0
- data/ext/java/nokogiri/internals/ParserContext.java +235 -0
- data/ext/java/nokogiri/internals/PushInputStream.java +381 -0
- data/ext/java/nokogiri/internals/ReaderNode.java +431 -0
- data/ext/java/nokogiri/internals/SaveContext.java +249 -0
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +35 -0
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +10 -0
- data/ext/java/nokogiri/internals/XmlDomParser.java +45 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +201 -0
- data/ext/java/nokogiri/internals/XmlSaxParser.java +33 -0
- data/ext/nokogiri/depend +32 -0
- data/ext/nokogiri/extconf.rb +61 -32
- data/ext/nokogiri/nokogiri.c +0 -5
- data/ext/nokogiri/nokogiri.h +2 -2
- data/ext/nokogiri/xml_document.c +5 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_node.c +56 -16
- data/ext/nokogiri/xml_node_set.c +7 -7
- data/ext/nokogiri/xml_reader.c +20 -1
- data/ext/nokogiri/xml_relax_ng.c +0 -7
- data/ext/nokogiri/xml_xpath_context.c +2 -0
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/nokogiri.rb +1 -2
- data/lib/nokogiri/css/generated_parser.rb +155 -148
- data/lib/nokogiri/css/generated_tokenizer.rb +2 -1
- data/lib/nokogiri/css/parser.y +3 -0
- data/lib/nokogiri/css/xpath_visitor.rb +1 -7
- data/lib/nokogiri/html.rb +2 -2
- data/lib/nokogiri/html/document_fragment.rb +7 -4
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +3 -6
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +1 -2
- data/lib/nokogiri/xml/document_fragment.rb +7 -0
- data/lib/nokogiri/xml/node.rb +5 -3
- data/lib/nokogiri/xml/node_set.rb +25 -0
- data/lib/nokogiri/xml/reader.rb +2 -0
- data/lib/nokogiri/xml/sax/document.rb +3 -1
- data/lib/xercesImpl.jar +0 -0
- data/spec/helper.rb +3 -0
- data/spec/xml/reader_spec.rb +307 -0
- data/tasks/test.rb +1 -1
- data/test/css/test_parser.rb +11 -1
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +2 -2
- data/test/html/test_document_fragment.rb +34 -6
- data/test/test_memory_leak.rb +2 -2
- data/test/test_reader.rb +28 -6
- data/test/test_xslt_transforms.rb +2 -3
- data/test/xml/test_attr.rb +31 -4
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +8 -8
- data/test/xml/test_document_fragment.rb +4 -12
- data/test/xml/test_node.rb +1 -1
- data/test/xml/test_node_reparenting.rb +26 -11
- data/test/xml/test_node_set.rb +38 -2
- data/test/xml/test_text.rb +11 -2
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +11 -7
- metadata +68 -5
- data/lib/nokogiri/version_warning.rb +0 -14
data/test/xml/test_node_set.rb
CHANGED
@@ -3,6 +3,27 @@ require "helper"
|
|
3
3
|
module Nokogiri
|
4
4
|
module XML
|
5
5
|
class TestNodeSet < Nokogiri::TestCase
|
6
|
+
class TestNodeSetNamespaces < Nokogiri::TestCase
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@xml = Nokogiri.XML('<foo xmlns:n0="http://example.com" />')
|
10
|
+
@list = @xml.xpath('//namespace::*')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_include?
|
14
|
+
assert @list.include?(@list.first), 'list should have item'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_push
|
18
|
+
@list.push @list.first
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_delete
|
22
|
+
@list.push @list.first
|
23
|
+
@list.delete @list.first
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
6
27
|
def setup
|
7
28
|
super
|
8
29
|
@xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE)
|
@@ -255,11 +276,26 @@ module Nokogiri
|
|
255
276
|
assert_match '<a>', html
|
256
277
|
end
|
257
278
|
|
279
|
+
def test_gt_string_arg
|
280
|
+
assert node_set = @xml.search('//employee')
|
281
|
+
assert_equal node_set.xpath('./employeeId'), (node_set > 'employeeId')
|
282
|
+
end
|
283
|
+
|
258
284
|
def test_at
|
259
285
|
assert node_set = @xml.search('//employee')
|
260
286
|
assert_equal node_set.first, node_set.at(0)
|
261
287
|
end
|
262
288
|
|
289
|
+
def test_at_xpath
|
290
|
+
assert node_set = @xml.search('//employee')
|
291
|
+
assert_equal node_set.first.first_element_child, node_set.at_xpath('./employeeId')
|
292
|
+
end
|
293
|
+
|
294
|
+
def test_at_css
|
295
|
+
assert node_set = @xml.search('//employee')
|
296
|
+
assert_equal node_set.first.first_element_child, node_set.at_css('employeeId')
|
297
|
+
end
|
298
|
+
|
263
299
|
def test_percent
|
264
300
|
assert node_set = @xml.search('//employee')
|
265
301
|
assert_equal node_set.first, node_set % 0
|
@@ -410,7 +446,7 @@ module Nokogiri
|
|
410
446
|
names_len = names.length
|
411
447
|
positions_len = positions.length
|
412
448
|
|
413
|
-
assert_raises(ArgumentError) {
|
449
|
+
assert_raises(ArgumentError) { names + positions.first }
|
414
450
|
|
415
451
|
result = names + positions
|
416
452
|
assert_equal names_len, names.length
|
@@ -434,7 +470,7 @@ module Nokogiri
|
|
434
470
|
employees_len = employees.length
|
435
471
|
females_len = females.length
|
436
472
|
|
437
|
-
assert_raises(ArgumentError) {
|
473
|
+
assert_raises(ArgumentError) { employees - females.first }
|
438
474
|
|
439
475
|
result = employees - females
|
440
476
|
assert_equal employees_len, employees.length
|
data/test/xml/test_text.rb
CHANGED
@@ -3,6 +3,13 @@ require "helper"
|
|
3
3
|
module Nokogiri
|
4
4
|
module XML
|
5
5
|
class TestText < Nokogiri::TestCase
|
6
|
+
def test_css_path
|
7
|
+
doc = Nokogiri.XML "<root> foo <a>something</a> bar bazz </root>"
|
8
|
+
node = doc.root.children[2]
|
9
|
+
assert_instance_of Nokogiri::XML::Text, node
|
10
|
+
assert_equal node, doc.at_css(node.css_path)
|
11
|
+
end
|
12
|
+
|
6
13
|
def test_inspect
|
7
14
|
node = Text.new('hello world', Document.new)
|
8
15
|
assert_equal "#<#{node.class.name}:#{sprintf("0x%x",node.object_id)} #{node.text.inspect}>", node.inspect
|
@@ -19,11 +26,13 @@ module Nokogiri
|
|
19
26
|
100.times { Text.new('hello world', Document.new) }
|
20
27
|
end
|
21
28
|
|
22
|
-
# No assertion because this was a segv
|
23
29
|
def test_new_without_document
|
24
30
|
doc = Document.new
|
25
31
|
node = Nokogiri::XML::Element.new('foo', doc)
|
26
|
-
|
32
|
+
|
33
|
+
assert_nothing_raised do
|
34
|
+
Text.new('hello world', node)
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
def test_content=
|
@@ -129,7 +129,7 @@ module Nokogiri
|
|
129
129
|
def test_add_child_in_same_document
|
130
130
|
child = @node.css('employee').first
|
131
131
|
|
132
|
-
assert
|
132
|
+
assert child.children.last
|
133
133
|
assert new_child = child.children.first
|
134
134
|
|
135
135
|
last = child.children.last
|
data/test/xml/test_xpath.rb
CHANGED
@@ -92,11 +92,13 @@ module Nokogiri
|
|
92
92
|
|
93
93
|
def test_css_search_uses_custom_selectors
|
94
94
|
set = @xml.xpath('//employee')
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
assert_nothing_raised do
|
96
|
+
if Nokogiri.uses_libxml?
|
97
|
+
@xml.css('employee:thing()', @handler)
|
98
|
+
else
|
99
|
+
@xml.xpath("//employee[nokogiri:thing(.)]", @ns, @handler)
|
100
|
+
end
|
101
|
+
end
|
100
102
|
assert_equal(set.length, @handler.things.length)
|
101
103
|
assert_equal(set.to_a, @handler.things.flatten)
|
102
104
|
end
|
@@ -184,7 +186,9 @@ module Nokogiri
|
|
184
186
|
def awesome! ; end
|
185
187
|
end
|
186
188
|
util_decorate(@xml, x)
|
187
|
-
|
189
|
+
|
190
|
+
assert @xml.xpath('//employee/name')
|
191
|
+
|
188
192
|
@xml.xpath('//employee[saves_node_set(name)]', @handler)
|
189
193
|
assert_equal @xml, @handler.things.document
|
190
194
|
assert @handler.things.respond_to?(:awesome!)
|
@@ -194,7 +198,7 @@ module Nokogiri
|
|
194
198
|
doc = "<html><body id='foo'><foo>hi</foo></body></html>"
|
195
199
|
xpath = 'id("foo")//foo'
|
196
200
|
nokogiri = Nokogiri::HTML.parse(doc)
|
197
|
-
|
201
|
+
assert nokogiri.xpath(xpath)
|
198
202
|
end
|
199
203
|
end
|
200
204
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196439
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 1.5.0.beta.
|
11
|
+
- 2
|
12
|
+
version: 1.5.0.beta.2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Aaron Patterson
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-
|
21
|
+
date: 2010-07-30 00:00:00 -07:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -146,6 +146,7 @@ extra_rdoc_files:
|
|
146
146
|
- ext/nokogiri/xml_entity_decl.c
|
147
147
|
- ext/nokogiri/xml_entity_reference.c
|
148
148
|
- ext/nokogiri/xml_io.c
|
149
|
+
- ext/nokogiri/xml_libxml2_hacks.c
|
149
150
|
- ext/nokogiri/xml_namespace.c
|
150
151
|
- ext/nokogiri/xml_node.c
|
151
152
|
- ext/nokogiri/xml_node_set.c
|
@@ -170,6 +171,59 @@ files:
|
|
170
171
|
- Rakefile
|
171
172
|
- bin/nokogiri
|
172
173
|
- deps.rip
|
174
|
+
- ext/java/nokogiri/EncodingHandler.java
|
175
|
+
- ext/java/nokogiri/HtmlDocument.java
|
176
|
+
- ext/java/nokogiri/HtmlElementDescription.java
|
177
|
+
- ext/java/nokogiri/HtmlEntityLookup.java
|
178
|
+
- ext/java/nokogiri/HtmlSaxParserContext.java
|
179
|
+
- ext/java/nokogiri/NokogiriService.java
|
180
|
+
- ext/java/nokogiri/XmlAttr.java
|
181
|
+
- ext/java/nokogiri/XmlAttributeDecl.java
|
182
|
+
- ext/java/nokogiri/XmlCdata.java
|
183
|
+
- ext/java/nokogiri/XmlComment.java
|
184
|
+
- ext/java/nokogiri/XmlDocument.java
|
185
|
+
- ext/java/nokogiri/XmlDocumentFragment.java
|
186
|
+
- ext/java/nokogiri/XmlDtd.java
|
187
|
+
- ext/java/nokogiri/XmlElement.java
|
188
|
+
- ext/java/nokogiri/XmlElementContent.java
|
189
|
+
- ext/java/nokogiri/XmlElementDecl.java
|
190
|
+
- ext/java/nokogiri/XmlEntityDecl.java
|
191
|
+
- ext/java/nokogiri/XmlEntityReference.java
|
192
|
+
- ext/java/nokogiri/XmlNamespace.java
|
193
|
+
- ext/java/nokogiri/XmlNode.java
|
194
|
+
- ext/java/nokogiri/XmlNodeSet.java
|
195
|
+
- ext/java/nokogiri/XmlProcessingInstruction.java
|
196
|
+
- ext/java/nokogiri/XmlReader.java
|
197
|
+
- ext/java/nokogiri/XmlRelaxng.java
|
198
|
+
- ext/java/nokogiri/XmlSaxParserContext.java
|
199
|
+
- ext/java/nokogiri/XmlSaxPushParser.java
|
200
|
+
- ext/java/nokogiri/XmlSchema.java
|
201
|
+
- ext/java/nokogiri/XmlSyntaxError.java
|
202
|
+
- ext/java/nokogiri/XmlText.java
|
203
|
+
- ext/java/nokogiri/XmlXpathContext.java
|
204
|
+
- ext/java/nokogiri/XsltStylesheet.java
|
205
|
+
- ext/java/nokogiri/internals/HtmlDomParserContext.java
|
206
|
+
- ext/java/nokogiri/internals/NokogiriDocumentCache.java
|
207
|
+
- ext/java/nokogiri/internals/NokogiriErrorHandler.java
|
208
|
+
- ext/java/nokogiri/internals/NokogiriHandler.java
|
209
|
+
- ext/java/nokogiri/internals/NokogiriHelpers.java
|
210
|
+
- ext/java/nokogiri/internals/NokogiriNamespaceCache.java
|
211
|
+
- ext/java/nokogiri/internals/NokogiriNamespaceContext.java
|
212
|
+
- ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java
|
213
|
+
- ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java
|
214
|
+
- ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java
|
215
|
+
- ext/java/nokogiri/internals/NokogiriXPathFunction.java
|
216
|
+
- ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java
|
217
|
+
- ext/java/nokogiri/internals/ParserContext.java
|
218
|
+
- ext/java/nokogiri/internals/PushInputStream.java
|
219
|
+
- ext/java/nokogiri/internals/ReaderNode.java
|
220
|
+
- ext/java/nokogiri/internals/SaveContext.java
|
221
|
+
- ext/java/nokogiri/internals/SchemaErrorHandler.java
|
222
|
+
- ext/java/nokogiri/internals/XmlDeclHandler.java
|
223
|
+
- ext/java/nokogiri/internals/XmlDomParser.java
|
224
|
+
- ext/java/nokogiri/internals/XmlDomParserContext.java
|
225
|
+
- ext/java/nokogiri/internals/XmlSaxParser.java
|
226
|
+
- ext/nokogiri/depend
|
173
227
|
- ext/nokogiri/extconf.rb
|
174
228
|
- ext/nokogiri/html_document.c
|
175
229
|
- ext/nokogiri/html_document.h
|
@@ -207,6 +261,8 @@ files:
|
|
207
261
|
- ext/nokogiri/xml_entity_reference.h
|
208
262
|
- ext/nokogiri/xml_io.c
|
209
263
|
- ext/nokogiri/xml_io.h
|
264
|
+
- ext/nokogiri/xml_libxml2_hacks.c
|
265
|
+
- ext/nokogiri/xml_libxml2_hacks.h
|
210
266
|
- ext/nokogiri/xml_namespace.c
|
211
267
|
- ext/nokogiri/xml_namespace.h
|
212
268
|
- ext/nokogiri/xml_node.c
|
@@ -235,6 +291,10 @@ files:
|
|
235
291
|
- ext/nokogiri/xml_xpath_context.h
|
236
292
|
- ext/nokogiri/xslt_stylesheet.c
|
237
293
|
- ext/nokogiri/xslt_stylesheet.h
|
294
|
+
- lib/isorelax.jar
|
295
|
+
- lib/jing.jar
|
296
|
+
- lib/nekodtd.jar
|
297
|
+
- lib/nekohtml.jar
|
238
298
|
- lib/nokogiri.rb
|
239
299
|
- lib/nokogiri/css.rb
|
240
300
|
- lib/nokogiri/css/generated_parser.rb
|
@@ -256,9 +316,9 @@ files:
|
|
256
316
|
- lib/nokogiri/html/entity_lookup.rb
|
257
317
|
- lib/nokogiri/html/sax/parser.rb
|
258
318
|
- lib/nokogiri/html/sax/parser_context.rb
|
319
|
+
- lib/nokogiri/nokogiri.jar
|
259
320
|
- lib/nokogiri/syntax_error.rb
|
260
321
|
- lib/nokogiri/version.rb
|
261
|
-
- lib/nokogiri/version_warning.rb
|
262
322
|
- lib/nokogiri/xml.rb
|
263
323
|
- lib/nokogiri/xml/attr.rb
|
264
324
|
- lib/nokogiri/xml/attribute_decl.rb
|
@@ -296,7 +356,10 @@ files:
|
|
296
356
|
- lib/nokogiri/xml/xpath_context.rb
|
297
357
|
- lib/nokogiri/xslt.rb
|
298
358
|
- lib/nokogiri/xslt/stylesheet.rb
|
359
|
+
- lib/xercesImpl.jar
|
299
360
|
- lib/xsd/xmlparser/nokogiri.rb
|
361
|
+
- spec/helper.rb
|
362
|
+
- spec/xml/reader_spec.rb
|
300
363
|
- tasks/cross_compile.rb
|
301
364
|
- tasks/test.rb
|
302
365
|
- test/css/test_nthiness.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
if self.is_2_6_16?
|
3
|
-
VERSION_INFO['warnings'] << "libxml 2.6.16 is old and buggy."
|
4
|
-
if !defined?(I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2)
|
5
|
-
warn <<-eom
|
6
|
-
HI. You're using libxml2 version 2.6.16 which is over 4 years old and has
|
7
|
-
plenty of bugs. We suggest that for maximum HTML/XML parsing pleasure, you
|
8
|
-
upgrade your version of libxml2 and re-install nokogiri. If you like using
|
9
|
-
libxml2 version 2.6.16, but don't like this warning, please define the constant
|
10
|
-
I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2 before requring nokogiri.
|
11
|
-
eom
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|