libxml-ruby 2.1.1-x86-mingw32 → 2.1.2-x86-mingw32
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.
- data/HISTORY +8 -0
- data/ext/libxml/extconf.rb +0 -1
- data/ext/libxml/ruby_xml_document.c +21 -2
- data/ext/libxml/ruby_xml_reader.c +6 -1
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/ext/libxml/ruby_xml_xpath_context.c +4 -15
- data/ext/libxml/ruby_xml_xpath_object.c +11 -11
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/lib/libxml.rb +0 -1
- data/lib/libxml/node.rb +1 -1
- data/lib/xml.rb +1 -3
- data/test/model/kml_sample.xml +915 -0
- data/test/tc_gc.rb +86 -0
- data/test/tc_reader.rb +31 -0
- data/test/tc_xpath.rb +1 -1
- data/test/tc_xpath_context.rb +15 -6
- metadata +7 -4
data/test/tc_gc.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require './test_helper'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestFoo < Test::Unit::TestCase
|
6
|
+
def namespaces
|
7
|
+
{'kml' => 'http://earth.google.com/kml/2.2'}
|
8
|
+
end
|
9
|
+
|
10
|
+
def doc
|
11
|
+
path = File.expand_path(File.join('model', 'kml_sample.xml'))
|
12
|
+
data = File.read(path)
|
13
|
+
parser = LibXML::XML::Parser.string(data)
|
14
|
+
doc = parser.parse
|
15
|
+
result = doc.root
|
16
|
+
doc = nil
|
17
|
+
GC.start
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_read
|
21
|
+
1000.times do
|
22
|
+
read_placemarks
|
23
|
+
GC.start
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_placemarks
|
28
|
+
root = doc.root
|
29
|
+
result = Array.new
|
30
|
+
root.find('//kml:Placemark', self.namespaces).each do |entry|
|
31
|
+
result << self.read_placemark(entry)
|
32
|
+
end
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
def read_placemark(entry)
|
37
|
+
geometries = read_geoms(entry)
|
38
|
+
#stop processing this placemark if there aren't any geometries.
|
39
|
+
return if geometries.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def read_geoms(entry)
|
43
|
+
|
44
|
+
geoms = []
|
45
|
+
entry.find('//kml:Point', self.namespaces).each do |point_entry|
|
46
|
+
geoms << parse_point(point_entry)
|
47
|
+
end
|
48
|
+
|
49
|
+
entry.find('//kml:LineString', self.namespaces).each do |point_entry|
|
50
|
+
geoms << parse_point(point_entry)
|
51
|
+
end
|
52
|
+
|
53
|
+
entry.find('//kml:Polygon', self.namespaces).each do |point_entry|
|
54
|
+
geoms << parse_polygon(point_entry)
|
55
|
+
end
|
56
|
+
|
57
|
+
geoms
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_point(entry)
|
61
|
+
coordinate_entry = entry.find('//kml:coordinates',self.namespaces).first
|
62
|
+
coordinate_entry.content.split(",")
|
63
|
+
end
|
64
|
+
|
65
|
+
def parse_coordinate_string(entry)
|
66
|
+
coordinates = entry.content.split
|
67
|
+
end
|
68
|
+
|
69
|
+
def parse_line_string(entry)
|
70
|
+
coord_sequence = parse_coordinate_string(entry.find('kml:coordinates',self.namespaces).first)
|
71
|
+
end
|
72
|
+
|
73
|
+
def parse_linear_ring(entry)
|
74
|
+
coord_sequence = parse_coordinate_string(entry.find('kml:coordinates',self.namespaces).first)
|
75
|
+
end
|
76
|
+
|
77
|
+
def parse_polygon(entry)
|
78
|
+
exterior_ring = parse_linear_ring(entry.find('kml:outerBoundaryIs/kml:LinearRing', self.namespaces).first)
|
79
|
+
|
80
|
+
interior_rings = []
|
81
|
+
entry.find('kml:innerBoundaryIs/kml:LinearRing', self.namespaces).each do |interior_ring|
|
82
|
+
interior_rings << parse_linear_ring(interior_ring)
|
83
|
+
end
|
84
|
+
interior_rings
|
85
|
+
end
|
86
|
+
end
|
data/test/tc_reader.rb
CHANGED
@@ -200,6 +200,37 @@ class TestReader < Test::Unit::TestCase
|
|
200
200
|
assert_equal(1, entries.length)
|
201
201
|
end
|
202
202
|
|
203
|
+
def test_expand_invalid
|
204
|
+
reader = XML::Reader.file(XML_FILE)
|
205
|
+
|
206
|
+
# Expand a node before one has been read
|
207
|
+
error = assert_raise(RuntimeError) do
|
208
|
+
reader.expand
|
209
|
+
end
|
210
|
+
assert_equal("The reader does not have a document. Did you forget to call read?", error.to_s)
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_expand_invalid_access
|
214
|
+
reader = XML::Reader.file(XML_FILE)
|
215
|
+
|
216
|
+
# Read a node
|
217
|
+
reader.read
|
218
|
+
reader.read
|
219
|
+
|
220
|
+
# Expand the node
|
221
|
+
node = reader.expand
|
222
|
+
assert_equal('feed', node.name)
|
223
|
+
|
224
|
+
# Read another node, this makes the last node invalid
|
225
|
+
reader.next
|
226
|
+
|
227
|
+
# The previous node is now invalid
|
228
|
+
error = assert_raise(RuntimeError) do
|
229
|
+
assert_equal('feed', node.name)
|
230
|
+
end
|
231
|
+
assert_equal("This node has already been freed.", error.to_s)
|
232
|
+
end
|
233
|
+
|
203
234
|
def test_mode
|
204
235
|
reader = XML::Reader.string('<xml/>')
|
205
236
|
assert_equal(XML::Reader::MODE_INITIAL, reader.read_state)
|
data/test/tc_xpath.rb
CHANGED
data/test/tc_xpath_context.rb
CHANGED
@@ -20,11 +20,12 @@ class TestXPathContext < Test::Unit::TestCase
|
|
20
20
|
@context = nil
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def test_no_ns
|
24
|
+
error = assert_raise(LibXML::XML::Error) do
|
25
|
+
@context.find('/soap:Envelope')
|
26
|
+
end
|
27
|
+
assert_equal("Error: Undefined namespace prefix.", error.to_s)
|
28
|
+
end
|
28
29
|
|
29
30
|
def test_ns_register
|
30
31
|
@context.register_namespace(SOAP_PREFIX, SOAP_URI)
|
@@ -77,4 +78,12 @@ class TestXPathContext < Test::Unit::TestCase
|
|
77
78
|
@context.enable_cache(10)
|
78
79
|
@context.disable_cache
|
79
80
|
end
|
80
|
-
|
81
|
+
|
82
|
+
def test_require_doc
|
83
|
+
doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
|
84
|
+
error = assert_raise(TypeError) do
|
85
|
+
@context = XML::XPath::Context.new(doc.root)
|
86
|
+
end
|
87
|
+
assert_equal("Supplied argument must be a document or node.", error.to_s)
|
88
|
+
end
|
89
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libxml-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
9
|
+
- 2
|
10
|
+
version: 2.1.2
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Ross Bamform
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2011-08-
|
23
|
+
date: 2011-08-03 00:00:00 Z
|
24
24
|
dependencies: []
|
25
25
|
|
26
26
|
description: " The Libxml-Ruby project provides Ruby language bindings for the GNOME\n Libxml2 XML toolkit. It is free software, released under the MIT License.\n Libxml-ruby's primary advantage over REXML is performance - if speed\n is your need, these are good libraries to consider, as demonstrated\n by the informal benchmark below.\n"
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- test/model/bands.utf-8.xml
|
146
146
|
- test/model/bands.xml
|
147
147
|
- test/model/books.xml
|
148
|
+
- test/model/kml_sample.xml
|
148
149
|
- test/model/merge_bug_data.xml
|
149
150
|
- test/model/ruby-lang.html
|
150
151
|
- test/model/rubynet.xml
|
@@ -163,6 +164,7 @@ files:
|
|
163
164
|
- test/tc_document_write.rb
|
164
165
|
- test/tc_dtd.rb
|
165
166
|
- test/tc_error.rb
|
167
|
+
- test/tc_gc.rb
|
166
168
|
- test/tc_html_parser.rb
|
167
169
|
- test/tc_html_parser_context.rb
|
168
170
|
- test/tc_namespace.rb
|
@@ -240,6 +242,7 @@ test_files:
|
|
240
242
|
- test/tc_document_write.rb
|
241
243
|
- test/tc_dtd.rb
|
242
244
|
- test/tc_error.rb
|
245
|
+
- test/tc_gc.rb
|
243
246
|
- test/tc_html_parser.rb
|
244
247
|
- test/tc_html_parser_context.rb
|
245
248
|
- test/tc_namespace.rb
|