nokogiri 1.0.0-x86-mswin32-60
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.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data/History.txt +6 -0
- data/Manifest.txt +120 -0
- data/README.ja.txt +86 -0
- data/README.txt +87 -0
- data/Rakefile +264 -0
- data/ext/nokogiri/extconf.rb +59 -0
- data/ext/nokogiri/html_document.c +83 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_sax_parser.c +32 -0
- data/ext/nokogiri/html_sax_parser.h +11 -0
- data/ext/nokogiri/iconv.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/native.c +40 -0
- data/ext/nokogiri/native.h +51 -0
- data/ext/nokogiri/native.so +0 -0
- data/ext/nokogiri/xml_cdata.c +52 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_document.c +159 -0
- data/ext/nokogiri/xml_document.h +10 -0
- data/ext/nokogiri/xml_dtd.c +117 -0
- data/ext/nokogiri/xml_dtd.h +8 -0
- data/ext/nokogiri/xml_node.c +709 -0
- data/ext/nokogiri/xml_node.h +15 -0
- data/ext/nokogiri/xml_node_set.c +124 -0
- data/ext/nokogiri/xml_node_set.h +9 -0
- data/ext/nokogiri/xml_reader.c +429 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_sax_parser.c +174 -0
- data/ext/nokogiri/xml_sax_parser.h +10 -0
- data/ext/nokogiri/xml_syntax_error.c +194 -0
- data/ext/nokogiri/xml_syntax_error.h +11 -0
- data/ext/nokogiri/xml_text.c +29 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath.c +46 -0
- data/ext/nokogiri/xml_xpath.h +11 -0
- data/ext/nokogiri/xml_xpath_context.c +81 -0
- data/ext/nokogiri/xml_xpath_context.h +9 -0
- data/ext/nokogiri/xslt_stylesheet.c +108 -0
- data/ext/nokogiri/xslt_stylesheet.h +9 -0
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/nokogiri.rb +51 -0
- data/lib/nokogiri/css.rb +6 -0
- data/lib/nokogiri/css/generated_parser.rb +653 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +159 -0
- data/lib/nokogiri/css/node.rb +95 -0
- data/lib/nokogiri/css/parser.rb +24 -0
- data/lib/nokogiri/css/parser.y +198 -0
- data/lib/nokogiri/css/tokenizer.rb +9 -0
- data/lib/nokogiri/css/tokenizer.rex +63 -0
- data/lib/nokogiri/css/xpath_visitor.rb +165 -0
- data/lib/nokogiri/decorators.rb +1 -0
- data/lib/nokogiri/decorators/hpricot.rb +3 -0
- data/lib/nokogiri/decorators/hpricot/node.rb +58 -0
- data/lib/nokogiri/decorators/hpricot/node_set.rb +14 -0
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +17 -0
- data/lib/nokogiri/hpricot.rb +47 -0
- data/lib/nokogiri/html.rb +95 -0
- data/lib/nokogiri/html/builder.rb +9 -0
- data/lib/nokogiri/html/document.rb +9 -0
- data/lib/nokogiri/html/sax/parser.rb +21 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/xml.rb +67 -0
- data/lib/nokogiri/xml/after_handler.rb +18 -0
- data/lib/nokogiri/xml/before_handler.rb +32 -0
- data/lib/nokogiri/xml/builder.rb +79 -0
- data/lib/nokogiri/xml/cdata.rb +9 -0
- data/lib/nokogiri/xml/document.rb +30 -0
- data/lib/nokogiri/xml/dtd.rb +6 -0
- data/lib/nokogiri/xml/element.rb +6 -0
- data/lib/nokogiri/xml/entity_declaration.rb +9 -0
- data/lib/nokogiri/xml/node.rb +195 -0
- data/lib/nokogiri/xml/node_set.rb +183 -0
- data/lib/nokogiri/xml/notation.rb +6 -0
- data/lib/nokogiri/xml/reader.rb +14 -0
- data/lib/nokogiri/xml/sax.rb +9 -0
- data/lib/nokogiri/xml/sax/document.rb +59 -0
- data/lib/nokogiri/xml/sax/parser.rb +33 -0
- data/lib/nokogiri/xml/syntax_error.rb +21 -0
- data/lib/nokogiri/xml/text.rb +6 -0
- data/lib/nokogiri/xml/xpath.rb +6 -0
- data/lib/nokogiri/xml/xpath_context.rb +14 -0
- data/lib/nokogiri/xslt.rb +11 -0
- data/lib/nokogiri/xslt/stylesheet.rb +6 -0
- data/nokogiri.gemspec +34 -0
- data/test/css/test_nthiness.rb +159 -0
- data/test/css/test_parser.rb +224 -0
- data/test/css/test_tokenizer.rb +162 -0
- data/test/css/test_xpath_visitor.rb +54 -0
- data/test/files/staff.xml +59 -0
- data/test/files/staff.xslt +32 -0
- data/test/files/tlm.html +850 -0
- data/test/helper.rb +70 -0
- data/test/hpricot/files/basic.xhtml +17 -0
- data/test/hpricot/files/boingboing.html +2266 -0
- data/test/hpricot/files/cy0.html +3653 -0
- data/test/hpricot/files/immob.html +400 -0
- data/test/hpricot/files/pace_application.html +1320 -0
- data/test/hpricot/files/tenderlove.html +16 -0
- data/test/hpricot/files/uswebgen.html +220 -0
- data/test/hpricot/files/utf8.html +1054 -0
- data/test/hpricot/files/week9.html +1723 -0
- data/test/hpricot/files/why.xml +19 -0
- data/test/hpricot/load_files.rb +7 -0
- data/test/hpricot/test_alter.rb +67 -0
- data/test/hpricot/test_builder.rb +27 -0
- data/test/hpricot/test_parser.rb +423 -0
- data/test/hpricot/test_paths.rb +15 -0
- data/test/hpricot/test_preserved.rb +78 -0
- data/test/hpricot/test_xml.rb +30 -0
- data/test/html/sax/test_parser.rb +27 -0
- data/test/html/test_builder.rb +78 -0
- data/test/html/test_document.rb +86 -0
- data/test/test_convert_xpath.rb +180 -0
- data/test/test_nokogiri.rb +36 -0
- data/test/test_reader.rb +222 -0
- data/test/test_xslt_transforms.rb +29 -0
- data/test/xml/sax/test_parser.rb +93 -0
- data/test/xml/test_builder.rb +16 -0
- data/test/xml/test_cdata.rb +18 -0
- data/test/xml/test_document.rb +171 -0
- data/test/xml/test_dtd.rb +43 -0
- data/test/xml/test_node.rb +223 -0
- data/test/xml/test_node_set.rb +116 -0
- data/test/xml/test_text.rb +13 -0
- metadata +217 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module HTML
|
5
|
+
class TestDTD < Nokogiri::TestCase
|
6
|
+
def setup
|
7
|
+
@xml = Nokogiri::XML.parse(File.read(XML_FILE))
|
8
|
+
assert @dtd = @xml.internal_subset
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_external_subsets
|
12
|
+
assert subset = @xml.internal_subset
|
13
|
+
assert_equal 'staff', subset.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_entities
|
17
|
+
assert entities = @dtd.entities
|
18
|
+
assert_equal %w[ ent1 ent2 ent3 ent4 ent5 ].sort, entities.keys.sort
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_attributes
|
22
|
+
assert attributes = @dtd.attributes
|
23
|
+
assert_equal %w[ width ], attributes.keys
|
24
|
+
assert_equal 'width', attributes['width'].name
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_elements
|
28
|
+
assert elements = @dtd.elements
|
29
|
+
assert_equal %w[ br ], elements.keys
|
30
|
+
assert_equal 'br', elements['br'].name
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_notations
|
34
|
+
assert notations = @dtd.notations
|
35
|
+
assert_equal %w[ notation1 notation2 ].sort, notations.keys.sort
|
36
|
+
assert notation1 = notations['notation1']
|
37
|
+
assert_equal 'notation1', notation1.name
|
38
|
+
assert_equal 'notation1File', notation1.public_id
|
39
|
+
assert_nil notation1.system_id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XML
|
5
|
+
class TestNode < Nokogiri::TestCase
|
6
|
+
def test_find_by_css_with_tilde_eql
|
7
|
+
xml = Nokogiri::XML.parse(<<-eoxml)
|
8
|
+
<root>
|
9
|
+
<a>Hello world</a>
|
10
|
+
<a class='foo bar'>Bar</a>
|
11
|
+
<a class='bar foo'>Bar</a>
|
12
|
+
<a class='bar'>Bar</a>
|
13
|
+
<a class='baz bar foo'>Bar</a>
|
14
|
+
<a class='bazbarfoo'>Awesome</a>
|
15
|
+
<a class='bazbar'>Awesome</a>
|
16
|
+
</root>
|
17
|
+
eoxml
|
18
|
+
set = xml.css('a[@class~="bar"]')
|
19
|
+
assert_equal 4, set.length
|
20
|
+
assert_equal ['Bar'], set.map { |node| node.content }.uniq
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_unlink
|
24
|
+
xml = Nokogiri::XML.parse(<<-eoxml)
|
25
|
+
<root>
|
26
|
+
<a class='foo bar'>Bar</a>
|
27
|
+
<a class='bar foo'>Bar</a>
|
28
|
+
<a class='bar'>Bar</a>
|
29
|
+
<a>Hello world</a>
|
30
|
+
<a class='baz bar foo'>Bar</a>
|
31
|
+
<a class='bazbarfoo'>Awesome</a>
|
32
|
+
<a class='bazbar'>Awesome</a>
|
33
|
+
</root>
|
34
|
+
eoxml
|
35
|
+
node = xml.xpath('//a')[3]
|
36
|
+
assert_equal('Hello world', node.text)
|
37
|
+
assert_match(/Hello world/, xml.to_s)
|
38
|
+
assert node.parent
|
39
|
+
assert node.document
|
40
|
+
assert node.previous_sibling
|
41
|
+
assert node.next_sibling
|
42
|
+
assert node.instance_eval{ owned? }
|
43
|
+
node.unlink
|
44
|
+
assert !node.parent
|
45
|
+
# assert !node.document # ugh. libxml doesn't clear node->doc pointer, due to xmlDict implementation.
|
46
|
+
assert !node.previous_sibling
|
47
|
+
assert !node.next_sibling
|
48
|
+
assert !node.instance_eval{ owned? }
|
49
|
+
assert_no_match(/Hello world/, xml.to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_dup
|
53
|
+
html = Nokogiri::HTML.parse(File.read(HTML_FILE), HTML_FILE)
|
54
|
+
found = html.search('//div/a').first
|
55
|
+
dup = found.dup
|
56
|
+
assert dup
|
57
|
+
assert_equal found.content, dup.content
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_search_can_handle_xpath_and_css
|
61
|
+
html = Nokogiri::HTML.parse(File.read(HTML_FILE), HTML_FILE)
|
62
|
+
found = html.search('//div/a', 'div > p')
|
63
|
+
length = html.xpath('//div/a').length +
|
64
|
+
html.css('div > p').length
|
65
|
+
assert_equal length, found.length
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_find_by_xpath
|
69
|
+
html = Nokogiri::HTML.parse(File.read(HTML_FILE), HTML_FILE)
|
70
|
+
found = html.xpath('//div/a')
|
71
|
+
assert_equal 3, found.length
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_find_by_css
|
75
|
+
html = Nokogiri::HTML.parse(File.read(HTML_FILE), HTML_FILE)
|
76
|
+
found = html.css('div > a')
|
77
|
+
assert_equal 3, found.length
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_next_sibling
|
81
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
82
|
+
assert node = xml.root
|
83
|
+
assert sibling = node.child.next_sibling
|
84
|
+
assert_equal('employee', sibling.name)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_previous_sibling
|
88
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
89
|
+
assert node = xml.root
|
90
|
+
assert sibling = node.child.next_sibling
|
91
|
+
assert_equal('employee', sibling.name)
|
92
|
+
assert_equal(sibling.previous_sibling, node.child)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_name=
|
96
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
97
|
+
assert node = xml.root
|
98
|
+
node.name = 'awesome'
|
99
|
+
assert_equal('awesome', node.name)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_child
|
103
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
104
|
+
assert node = xml.root
|
105
|
+
assert child = node.child
|
106
|
+
assert_equal('text', child.name)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_key?
|
110
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
111
|
+
assert node = xml.search('//address').first
|
112
|
+
assert(!node.key?('asdfasdf'))
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_set_property
|
116
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
117
|
+
assert node = xml.search('//address').first
|
118
|
+
node['foo'] = 'bar'
|
119
|
+
assert_equal('bar', node['foo'])
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_attributes
|
123
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
124
|
+
assert node = xml.search('//address').first
|
125
|
+
assert_nil(node['asdfasdfasdf'])
|
126
|
+
assert_equal('Yes', node['domestic'])
|
127
|
+
|
128
|
+
assert node = xml.search('//address')[2]
|
129
|
+
attr = node.attributes
|
130
|
+
assert_equal 2, attr.size
|
131
|
+
assert_equal 'Yes', attr['domestic']
|
132
|
+
assert_equal 'No', attr['street']
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_path
|
136
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
137
|
+
assert set = xml.search('//employee')
|
138
|
+
assert node = set.first
|
139
|
+
assert_equal('/staff/employee[1]', node.path)
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_new_node
|
143
|
+
node = Nokogiri::XML::Node.new('form')
|
144
|
+
assert_equal('form', node.name)
|
145
|
+
assert_nil(node.document)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_content
|
149
|
+
node = Nokogiri::XML::Node.new('form')
|
150
|
+
assert_equal('', node.content)
|
151
|
+
|
152
|
+
node.content = 'hello world!'
|
153
|
+
assert_equal('hello world!', node.content)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_replace
|
157
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE))
|
158
|
+
set = xml.search('//employee')
|
159
|
+
assert 5, set.length
|
160
|
+
assert 0, xml.search('//form').length
|
161
|
+
|
162
|
+
first = set[0]
|
163
|
+
second = set[1]
|
164
|
+
|
165
|
+
node = Nokogiri::XML::Node.new('form')
|
166
|
+
first.replace(node)
|
167
|
+
|
168
|
+
assert set = xml.search('//employee')
|
169
|
+
assert_equal 4, set.length
|
170
|
+
assert 1, xml.search('//form').length
|
171
|
+
|
172
|
+
assert_equal set[0].to_xml, second.to_xml
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_namespace_as_hash
|
176
|
+
xml = Nokogiri::XML.parse(<<-eoxml)
|
177
|
+
<root>
|
178
|
+
<car xmlns:part="http://general-motors.com/">
|
179
|
+
<part:tire>Michelin Model XGV</part:tire>
|
180
|
+
</car>
|
181
|
+
<bicycle xmlns:part="http://schwinn.com/">
|
182
|
+
<part:tire>I'm a bicycle tire!</part:tire>
|
183
|
+
</bicycle>
|
184
|
+
</root>
|
185
|
+
eoxml
|
186
|
+
|
187
|
+
tires = xml.xpath('//bike:tire', {'bike' => 'http://schwinn.com/'})
|
188
|
+
assert_equal 1, tires.length
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_namespaces
|
192
|
+
xml = Nokogiri::XML.parse(<<-EOF)
|
193
|
+
<x xmlns:a='http://foo.com/' xmlns:b='http://bar.com/'>
|
194
|
+
<y xmlns:c='http://bazz.com/'>
|
195
|
+
<a:div>hello a</a:div>
|
196
|
+
<b:div>hello b</b:div>
|
197
|
+
<c:div>hello c</c:div>
|
198
|
+
</y>
|
199
|
+
</x>
|
200
|
+
EOF
|
201
|
+
assert namespaces = xml.root.namespaces
|
202
|
+
assert namespaces.key?('xmlns:a')
|
203
|
+
assert_equal 'http://foo.com/', namespaces['xmlns:a']
|
204
|
+
assert namespaces.key?('xmlns:b')
|
205
|
+
assert_equal 'http://bar.com/', namespaces['xmlns:b']
|
206
|
+
assert ! namespaces.key?('xmlns:c')
|
207
|
+
|
208
|
+
assert namespaces = xml.namespaces
|
209
|
+
assert namespaces.key?('xmlns:a')
|
210
|
+
assert_equal 'http://foo.com/', namespaces['xmlns:a']
|
211
|
+
assert namespaces.key?('xmlns:b')
|
212
|
+
assert_equal 'http://bar.com/', namespaces['xmlns:b']
|
213
|
+
assert namespaces.key?('xmlns:c')
|
214
|
+
assert_equal 'http://bazz.com/', namespaces['xmlns:c']
|
215
|
+
|
216
|
+
assert_equal "hello a", xml.search("//a:div", xml.namespaces).first.inner_text
|
217
|
+
assert_equal "hello b", xml.search("//b:div", xml.namespaces).first.inner_text
|
218
|
+
assert_equal "hello c", xml.search("//c:div", xml.namespaces).first.inner_text
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XML
|
5
|
+
class TestNodeSet < Nokogiri::TestCase
|
6
|
+
def setup
|
7
|
+
@xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_length_size
|
11
|
+
assert node_set = @xml.search('//employee')
|
12
|
+
assert_equal node_set.length, node_set.size
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_at
|
16
|
+
assert node_set = @xml.search('//employee')
|
17
|
+
assert_equal node_set.first, node_set.at(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_push
|
21
|
+
node = Nokogiri::XML::Node.new('foo')
|
22
|
+
node.content = 'bar'
|
23
|
+
|
24
|
+
assert node_set = @xml.search('//employee')
|
25
|
+
node_set.push(node)
|
26
|
+
|
27
|
+
assert node_set.include?(node)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_unlink
|
31
|
+
xml = Nokogiri::XML.parse(<<-eoxml)
|
32
|
+
<root>
|
33
|
+
<a class='foo bar'>Bar</a>
|
34
|
+
<a class='bar foo'>Bar</a>
|
35
|
+
<a class='bar'>Bar</a>
|
36
|
+
<a>Hello world</a>
|
37
|
+
<a class='baz bar foo'>Bar</a>
|
38
|
+
<a class='bazbarfoo'>Awesome</a>
|
39
|
+
<a class='bazbar'>Awesome</a>
|
40
|
+
</root>
|
41
|
+
eoxml
|
42
|
+
set = xml.xpath('//a')
|
43
|
+
set.unlink
|
44
|
+
set.each do |node|
|
45
|
+
assert !node.parent
|
46
|
+
# assert !node.document # ugh. libxml doesn't clear node->doc pointer, due to xmlDict implementation.
|
47
|
+
assert !node.previous_sibling
|
48
|
+
assert !node.next_sibling
|
49
|
+
assert !node.instance_eval{ owned? }
|
50
|
+
end
|
51
|
+
assert !set.document
|
52
|
+
assert_no_match(/Hello world/, xml.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_nodeset_search_takes_namespace
|
56
|
+
@xml = Nokogiri::XML.parse(<<-eoxml)
|
57
|
+
<root>
|
58
|
+
<car xmlns:part="http://general-motors.com/">
|
59
|
+
<part:tire>Michelin Model XGV</part:tire>
|
60
|
+
</car>
|
61
|
+
<bicycle xmlns:part="http://schwinn.com/">
|
62
|
+
<part:tire>I'm a bicycle tire!</part:tire>
|
63
|
+
</bicycle>
|
64
|
+
</root>
|
65
|
+
eoxml
|
66
|
+
set = @xml/'root'
|
67
|
+
assert_equal 1, set.length
|
68
|
+
bike_tire = set.search('//bike:tire', 'bike' => "http://schwinn.com/")
|
69
|
+
assert_equal 1, bike_tire.length
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_new_nodeset
|
73
|
+
node_set = Nokogiri::XML::NodeSet.new
|
74
|
+
assert_equal(0, node_set.length)
|
75
|
+
node = Nokogiri::XML::Node.new('form')
|
76
|
+
node_set << node
|
77
|
+
assert_equal(1, node_set.length)
|
78
|
+
assert_equal(node, node_set.last)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_search_on_nodeset
|
82
|
+
assert node_set = @xml.search('//employee')
|
83
|
+
assert sub_set = node_set.search('.//name')
|
84
|
+
assert_equal(node_set.length, sub_set.length)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_negative_index_works
|
88
|
+
assert node_set = @xml.search('//employee')
|
89
|
+
assert_equal node_set.last, node_set[-1]
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_large_negative_index_returns_nil
|
93
|
+
assert node_set = @xml.search('//employee')
|
94
|
+
assert_nil(node_set[-1 * (node_set.length + 1)])
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_node_set_fetches_private_data
|
98
|
+
assert node_set = @xml.search('//employee')
|
99
|
+
|
100
|
+
set = node_set
|
101
|
+
assert_equal(set[0], set[0])
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_node_set_returns_0
|
105
|
+
assert node_set = @xml.search('//asdkfjhasdlkfjhaldskfh')
|
106
|
+
assert_equal(0, node_set.length)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_wrap
|
110
|
+
employees = (@xml/"//employee").wrap("<wrapper/>")
|
111
|
+
assert_equal 'wrapper', employees[0].parent.name
|
112
|
+
assert_equal 'employee', @xml.search("//wrapper").first.children[0].name
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XML
|
5
|
+
class TestText < Nokogiri::TestCase
|
6
|
+
def test_new
|
7
|
+
node = Text.new('hello world')
|
8
|
+
assert node
|
9
|
+
assert_equal('hello world', node.content)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nokogiri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: x86-mswin32-60
|
6
|
+
authors:
|
7
|
+
- Aaron Patterson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-10-30 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.7.0
|
24
|
+
version:
|
25
|
+
description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser."
|
26
|
+
email:
|
27
|
+
- aaronp@rubyforge.org
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.ja.txt
|
36
|
+
- README.txt
|
37
|
+
files:
|
38
|
+
- History.txt
|
39
|
+
- Manifest.txt
|
40
|
+
- README.ja.txt
|
41
|
+
- README.txt
|
42
|
+
- Rakefile
|
43
|
+
- ext/nokogiri/extconf.rb
|
44
|
+
- ext/nokogiri/html_document.c
|
45
|
+
- ext/nokogiri/html_document.h
|
46
|
+
- ext/nokogiri/html_sax_parser.c
|
47
|
+
- ext/nokogiri/html_sax_parser.h
|
48
|
+
- ext/nokogiri/native.c
|
49
|
+
- ext/nokogiri/native.h
|
50
|
+
- ext/nokogiri/xml_cdata.c
|
51
|
+
- ext/nokogiri/xml_cdata.h
|
52
|
+
- ext/nokogiri/xml_document.c
|
53
|
+
- ext/nokogiri/xml_document.h
|
54
|
+
- ext/nokogiri/xml_dtd.c
|
55
|
+
- ext/nokogiri/xml_dtd.h
|
56
|
+
- ext/nokogiri/xml_node.c
|
57
|
+
- ext/nokogiri/xml_node.h
|
58
|
+
- ext/nokogiri/xml_node_set.c
|
59
|
+
- ext/nokogiri/xml_node_set.h
|
60
|
+
- ext/nokogiri/xml_reader.c
|
61
|
+
- ext/nokogiri/xml_reader.h
|
62
|
+
- ext/nokogiri/xml_sax_parser.c
|
63
|
+
- ext/nokogiri/xml_sax_parser.h
|
64
|
+
- ext/nokogiri/xml_syntax_error.c
|
65
|
+
- ext/nokogiri/xml_syntax_error.h
|
66
|
+
- ext/nokogiri/xml_text.c
|
67
|
+
- ext/nokogiri/xml_text.h
|
68
|
+
- ext/nokogiri/xml_xpath.c
|
69
|
+
- ext/nokogiri/xml_xpath.h
|
70
|
+
- ext/nokogiri/xml_xpath_context.c
|
71
|
+
- ext/nokogiri/xml_xpath_context.h
|
72
|
+
- ext/nokogiri/xslt_stylesheet.c
|
73
|
+
- ext/nokogiri/xslt_stylesheet.h
|
74
|
+
- lib/nokogiri.rb
|
75
|
+
- lib/nokogiri/css.rb
|
76
|
+
- lib/nokogiri/css/generated_parser.rb
|
77
|
+
- lib/nokogiri/css/generated_tokenizer.rb
|
78
|
+
- lib/nokogiri/css/node.rb
|
79
|
+
- lib/nokogiri/css/parser.rb
|
80
|
+
- lib/nokogiri/css/parser.y
|
81
|
+
- lib/nokogiri/css/tokenizer.rb
|
82
|
+
- lib/nokogiri/css/tokenizer.rex
|
83
|
+
- lib/nokogiri/css/xpath_visitor.rb
|
84
|
+
- lib/nokogiri/decorators.rb
|
85
|
+
- lib/nokogiri/decorators/hpricot.rb
|
86
|
+
- lib/nokogiri/decorators/hpricot/node.rb
|
87
|
+
- lib/nokogiri/decorators/hpricot/node_set.rb
|
88
|
+
- lib/nokogiri/decorators/hpricot/xpath_visitor.rb
|
89
|
+
- lib/nokogiri/hpricot.rb
|
90
|
+
- lib/nokogiri/html.rb
|
91
|
+
- lib/nokogiri/html/builder.rb
|
92
|
+
- lib/nokogiri/html/document.rb
|
93
|
+
- lib/nokogiri/html/sax/parser.rb
|
94
|
+
- lib/nokogiri/version.rb
|
95
|
+
- lib/nokogiri/xml.rb
|
96
|
+
- lib/nokogiri/xml/after_handler.rb
|
97
|
+
- lib/nokogiri/xml/before_handler.rb
|
98
|
+
- lib/nokogiri/xml/builder.rb
|
99
|
+
- lib/nokogiri/xml/cdata.rb
|
100
|
+
- lib/nokogiri/xml/document.rb
|
101
|
+
- lib/nokogiri/xml/dtd.rb
|
102
|
+
- lib/nokogiri/xml/element.rb
|
103
|
+
- lib/nokogiri/xml/entity_declaration.rb
|
104
|
+
- lib/nokogiri/xml/node.rb
|
105
|
+
- lib/nokogiri/xml/node_set.rb
|
106
|
+
- lib/nokogiri/xml/notation.rb
|
107
|
+
- lib/nokogiri/xml/reader.rb
|
108
|
+
- lib/nokogiri/xml/sax.rb
|
109
|
+
- lib/nokogiri/xml/sax/document.rb
|
110
|
+
- lib/nokogiri/xml/sax/parser.rb
|
111
|
+
- lib/nokogiri/xml/syntax_error.rb
|
112
|
+
- lib/nokogiri/xml/text.rb
|
113
|
+
- lib/nokogiri/xml/xpath.rb
|
114
|
+
- lib/nokogiri/xml/xpath_context.rb
|
115
|
+
- lib/nokogiri/xslt.rb
|
116
|
+
- lib/nokogiri/xslt/stylesheet.rb
|
117
|
+
- nokogiri.gemspec
|
118
|
+
- test/css/test_nthiness.rb
|
119
|
+
- test/css/test_parser.rb
|
120
|
+
- test/css/test_tokenizer.rb
|
121
|
+
- test/css/test_xpath_visitor.rb
|
122
|
+
- test/files/staff.xml
|
123
|
+
- test/files/staff.xslt
|
124
|
+
- test/files/tlm.html
|
125
|
+
- test/helper.rb
|
126
|
+
- test/hpricot/files/basic.xhtml
|
127
|
+
- test/hpricot/files/boingboing.html
|
128
|
+
- test/hpricot/files/cy0.html
|
129
|
+
- test/hpricot/files/immob.html
|
130
|
+
- test/hpricot/files/pace_application.html
|
131
|
+
- test/hpricot/files/tenderlove.html
|
132
|
+
- test/hpricot/files/uswebgen.html
|
133
|
+
- test/hpricot/files/utf8.html
|
134
|
+
- test/hpricot/files/week9.html
|
135
|
+
- test/hpricot/files/why.xml
|
136
|
+
- test/hpricot/load_files.rb
|
137
|
+
- test/hpricot/test_alter.rb
|
138
|
+
- test/hpricot/test_builder.rb
|
139
|
+
- test/hpricot/test_parser.rb
|
140
|
+
- test/hpricot/test_paths.rb
|
141
|
+
- test/hpricot/test_preserved.rb
|
142
|
+
- test/hpricot/test_xml.rb
|
143
|
+
- test/html/sax/test_parser.rb
|
144
|
+
- test/html/test_builder.rb
|
145
|
+
- test/html/test_document.rb
|
146
|
+
- test/test_convert_xpath.rb
|
147
|
+
- test/test_nokogiri.rb
|
148
|
+
- test/test_reader.rb
|
149
|
+
- test/test_xslt_transforms.rb
|
150
|
+
- test/xml/sax/test_parser.rb
|
151
|
+
- test/xml/test_builder.rb
|
152
|
+
- test/xml/test_cdata.rb
|
153
|
+
- test/xml/test_document.rb
|
154
|
+
- test/xml/test_dtd.rb
|
155
|
+
- test/xml/test_node.rb
|
156
|
+
- test/xml/test_node_set.rb
|
157
|
+
- test/xml/test_text.rb
|
158
|
+
- ext/nokogiri/iconv.dll
|
159
|
+
- ext/nokogiri/libexslt.dll
|
160
|
+
- ext/nokogiri/libxml2.dll
|
161
|
+
- ext/nokogiri/libxslt.dll
|
162
|
+
- ext/nokogiri/zlib1.dll
|
163
|
+
- ext/nokogiri/native.so
|
164
|
+
has_rdoc: true
|
165
|
+
homepage: http://nokogiri.rubyforge.org/
|
166
|
+
post_install_message:
|
167
|
+
rdoc_options:
|
168
|
+
- --main
|
169
|
+
- README.txt
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
- ext
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: "0"
|
178
|
+
version:
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: "0"
|
184
|
+
version:
|
185
|
+
requirements: []
|
186
|
+
|
187
|
+
rubyforge_project: nokogiri
|
188
|
+
rubygems_version: 1.2.0
|
189
|
+
signing_key:
|
190
|
+
specification_version: 2
|
191
|
+
summary: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser."
|
192
|
+
test_files:
|
193
|
+
- test/css/test_nthiness.rb
|
194
|
+
- test/css/test_parser.rb
|
195
|
+
- test/css/test_tokenizer.rb
|
196
|
+
- test/css/test_xpath_visitor.rb
|
197
|
+
- test/hpricot/test_alter.rb
|
198
|
+
- test/hpricot/test_builder.rb
|
199
|
+
- test/hpricot/test_parser.rb
|
200
|
+
- test/hpricot/test_paths.rb
|
201
|
+
- test/hpricot/test_preserved.rb
|
202
|
+
- test/hpricot/test_xml.rb
|
203
|
+
- test/html/sax/test_parser.rb
|
204
|
+
- test/html/test_builder.rb
|
205
|
+
- test/html/test_document.rb
|
206
|
+
- test/test_convert_xpath.rb
|
207
|
+
- test/test_nokogiri.rb
|
208
|
+
- test/test_reader.rb
|
209
|
+
- test/test_xslt_transforms.rb
|
210
|
+
- test/xml/sax/test_parser.rb
|
211
|
+
- test/xml/test_builder.rb
|
212
|
+
- test/xml/test_cdata.rb
|
213
|
+
- test/xml/test_document.rb
|
214
|
+
- test/xml/test_dtd.rb
|
215
|
+
- test/xml/test_node.rb
|
216
|
+
- test/xml/test_node_set.rb
|
217
|
+
- test/xml/test_text.rb
|