hpricot 0.7-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +68 -0
- data/COPYING +18 -0
- data/README +284 -0
- data/Rakefile +260 -0
- data/ext/fast_xs/FastXsService.java +1018 -0
- data/ext/fast_xs/extconf.rb +4 -0
- data/ext/fast_xs/fast_xs.c +200 -0
- data/ext/hpricot_scan/HpricotScanService.java +1305 -0
- data/ext/hpricot_scan/extconf.rb +6 -0
- data/ext/hpricot_scan/hpricot_common.rl +76 -0
- data/ext/hpricot_scan/hpricot_css.c +3502 -0
- data/ext/hpricot_scan/hpricot_css.rl +115 -0
- data/ext/hpricot_scan/hpricot_scan.c +6704 -0
- data/ext/hpricot_scan/hpricot_scan.h +79 -0
- data/ext/hpricot_scan/hpricot_scan.java.rl +373 -0
- data/ext/hpricot_scan/hpricot_scan.rl +722 -0
- data/ext/hpricot_scan/test.rb +4 -0
- data/extras/mingw-rbconfig.rb +176 -0
- data/lib/fast_xs.so +0 -0
- data/lib/hpricot.rb +26 -0
- data/lib/hpricot/blankslate.rb +63 -0
- data/lib/hpricot/builder.rb +216 -0
- data/lib/hpricot/elements.rb +510 -0
- data/lib/hpricot/htmlinfo.rb +691 -0
- data/lib/hpricot/inspect.rb +103 -0
- data/lib/hpricot/modules.rb +38 -0
- data/lib/hpricot/parse.rb +38 -0
- data/lib/hpricot/tag.rb +198 -0
- data/lib/hpricot/tags.rb +164 -0
- data/lib/hpricot/traverse.rb +838 -0
- data/lib/hpricot/xchar.rb +94 -0
- data/lib/hpricot_scan.so +0 -0
- data/test/files/basic.xhtml +17 -0
- data/test/files/boingboing.html +2266 -0
- data/test/files/cy0.html +3653 -0
- data/test/files/immob.html +400 -0
- data/test/files/pace_application.html +1320 -0
- data/test/files/tenderlove.html +16 -0
- data/test/files/uswebgen.html +220 -0
- data/test/files/utf8.html +1054 -0
- data/test/files/week9.html +1723 -0
- data/test/files/why.xml +19 -0
- data/test/load_files.rb +7 -0
- data/test/nokogiri-bench.rb +64 -0
- data/test/test_alter.rb +77 -0
- data/test/test_builder.rb +37 -0
- data/test/test_parser.rb +409 -0
- data/test/test_paths.rb +25 -0
- data/test/test_preserved.rb +70 -0
- data/test/test_xml.rb +28 -0
- metadata +111 -0
data/test/test_paths.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'hpricot'
|
5
|
+
require 'load_files'
|
6
|
+
|
7
|
+
class TestParser < Test::Unit::TestCase
|
8
|
+
def test_roundtrip
|
9
|
+
@basic = Hpricot.parse(TestFiles::BASIC)
|
10
|
+
%w[link link[2] body #link1 a p.ohmy].each do |css_sel|
|
11
|
+
ele = @basic.at(css_sel)
|
12
|
+
assert_equal ele, @basic.at(ele.css_path)
|
13
|
+
assert_equal ele, @basic.at(ele.xpath)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
def test_attr_brackets
|
17
|
+
doc = Hpricot('<input name="vendor[porkpies]"/>')
|
18
|
+
assert_equal 1, (doc/'input[@name^="vendor[porkpies]"]').length
|
19
|
+
assert_equal 1, (doc/'input[@name="vendor[porkpies]"]').length
|
20
|
+
assert_equal 0, (doc/'input[@name$="]]]]]"]').length
|
21
|
+
|
22
|
+
doc = Hpricot('<input name="vendor[porkpies][meaty]"/>')
|
23
|
+
assert_equal 1, (doc/'input[@name^="vendor[porkpies][meaty]"]').length
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'hpricot'
|
6
|
+
require 'load_files'
|
7
|
+
|
8
|
+
class TestPreserved < Test::Unit::TestCase
|
9
|
+
def assert_roundtrip str
|
10
|
+
doc = Hpricot(str)
|
11
|
+
yield doc if block_given?
|
12
|
+
str2 = doc.to_original_html
|
13
|
+
if RUBY_VERSION =~ /^1.9/
|
14
|
+
str2.force_encoding('UTF-8')
|
15
|
+
end
|
16
|
+
str.lines.zip(str2.lines).each do |s1, s2|
|
17
|
+
assert_equal s1, s2
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def assert_html str1, str2
|
22
|
+
doc = Hpricot(str2)
|
23
|
+
yield doc if block_given?
|
24
|
+
assert_equal str1, doc.to_original_html
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_simple
|
28
|
+
str = "<p>Hpricot is a <b>you know <i>uh</b> fine thing.</p>"
|
29
|
+
assert_html str, str
|
30
|
+
assert_html "<p class=\"new\">Hpricot is a <b>you know <i>uh</b> fine thing.</p>", str do |doc|
|
31
|
+
(doc/:p).set('class', 'new')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_parent
|
36
|
+
str = "<html><base href='/'><head><title>Test</title></head><body><div id='wrap'><p>Paragraph one.</p><p>Paragraph two.</p></div></body></html>"
|
37
|
+
assert_html str, str
|
38
|
+
assert_html "<html><base href='/'><body><div id=\"all\"><div><p>Paragraph one.</p></div><div><p>Paragraph two.</p></div></div></body></html>", str do |doc|
|
39
|
+
(doc/:head).remove
|
40
|
+
(doc/:div).set('id', 'all')
|
41
|
+
(doc/:p).wrap('<div></div>')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_escaping_of_contents
|
46
|
+
doc = Hpricot(TestFiles::BOINGBOING)
|
47
|
+
assert_equal "Fukuda’s Automatic Door opens around your body as you pass through it. The idea is to save energy and keep the room clean.", doc.at("img[@alt='200606131240']").next.to_s.strip
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_files
|
51
|
+
assert_roundtrip TestFiles::BASIC
|
52
|
+
assert_roundtrip TestFiles::BOINGBOING
|
53
|
+
assert_roundtrip TestFiles::CY0
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_escaping_of_attrs
|
57
|
+
# ampersands in URLs
|
58
|
+
str = %{<a href="http://google.com/search?q=hpricot&l=en">Google</a>}
|
59
|
+
link = (doc = Hpricot(str)).at(:a)
|
60
|
+
assert_equal "http://google.com/search?q=hpricot&l=en", link['href']
|
61
|
+
assert_equal "http://google.com/search?q=hpricot&l=en", link.attributes['href']
|
62
|
+
assert_equal "http://google.com/search?q=hpricot&l=en", link.get_attribute('href')
|
63
|
+
assert_equal "http://google.com/search?q=hpricot&l=en", link.raw_attributes['href']
|
64
|
+
assert_equal str, doc.to_html
|
65
|
+
|
66
|
+
# alter the url
|
67
|
+
link['href'] = "javascript:alert(\"AGGA-KA-BOO!\")"
|
68
|
+
assert_equal %{<a href="javascript:alert("AGGA-KA-BOO!")">Google</a>}, doc.to_html
|
69
|
+
end
|
70
|
+
end
|
data/test/test_xml.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'hpricot'
|
5
|
+
require 'load_files'
|
6
|
+
|
7
|
+
class TestParser < Test::Unit::TestCase
|
8
|
+
# normally, the link tags are empty HTML tags.
|
9
|
+
# contributed by laudney.
|
10
|
+
def test_normally_empty
|
11
|
+
doc = Hpricot::XML("<rss><channel><title>this is title</title><link>http://fake.com</link></channel></rss>")
|
12
|
+
assert_equal "this is title", (doc/:rss/:channel/:title).text
|
13
|
+
assert_equal "http://fake.com", (doc/:rss/:channel/:link).text
|
14
|
+
end
|
15
|
+
|
16
|
+
# make sure XML doesn't get downcased
|
17
|
+
def test_casing
|
18
|
+
doc = Hpricot::XML(TestFiles::WHY)
|
19
|
+
assert_equal "hourly", (doc.at "sy:updatePeriod").inner_html
|
20
|
+
assert_equal 1, (doc/"guid[@isPermaLink]").length
|
21
|
+
end
|
22
|
+
|
23
|
+
# be sure tags named "text" are ok
|
24
|
+
def test_text_tags
|
25
|
+
doc = Hpricot::XML("<feed><title>City Poisoned</title><text>Rita Lee has poisoned Brazil.</text></feed>")
|
26
|
+
assert_equal "City Poisoned", (doc/"title").text
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hpricot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.7"
|
5
|
+
platform: x86-mswin32
|
6
|
+
authors:
|
7
|
+
- why the lucky stiff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-17 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: a swift, liberal HTML parser with a fantastic library
|
17
|
+
email: why@ruby-lang.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- CHANGELOG
|
25
|
+
- COPYING
|
26
|
+
files:
|
27
|
+
- CHANGELOG
|
28
|
+
- COPYING
|
29
|
+
- README
|
30
|
+
- Rakefile
|
31
|
+
- test/test_paths.rb
|
32
|
+
- test/test_preserved.rb
|
33
|
+
- test/test_parser.rb
|
34
|
+
- test/files
|
35
|
+
- test/files/cy0.html
|
36
|
+
- test/files/pace_application.html
|
37
|
+
- test/files/basic.xhtml
|
38
|
+
- test/files/utf8.html
|
39
|
+
- test/files/boingboing.html
|
40
|
+
- test/files/week9.html
|
41
|
+
- test/files/tenderlove.html
|
42
|
+
- test/files/immob.html
|
43
|
+
- test/files/why.xml
|
44
|
+
- test/files/uswebgen.html
|
45
|
+
- test/load_files.rb
|
46
|
+
- test/nokogiri-bench.rb
|
47
|
+
- test/test_builder.rb
|
48
|
+
- test/test_xml.rb
|
49
|
+
- test/test_alter.rb
|
50
|
+
- lib/hpricot
|
51
|
+
- lib/hpricot/tags.rb
|
52
|
+
- lib/hpricot/builder.rb
|
53
|
+
- lib/hpricot/traverse.rb
|
54
|
+
- lib/hpricot/elements.rb
|
55
|
+
- lib/hpricot/modules.rb
|
56
|
+
- lib/hpricot/inspect.rb
|
57
|
+
- lib/hpricot/tag.rb
|
58
|
+
- lib/hpricot/blankslate.rb
|
59
|
+
- lib/hpricot/xchar.rb
|
60
|
+
- lib/hpricot/htmlinfo.rb
|
61
|
+
- lib/hpricot/parse.rb
|
62
|
+
- lib/hpricot.rb
|
63
|
+
- extras/mingw-rbconfig.rb
|
64
|
+
- ext/hpricot_scan/hpricot_scan.h
|
65
|
+
- ext/hpricot_scan/HpricotScanService.java
|
66
|
+
- ext/fast_xs/FastXsService.java
|
67
|
+
- ext/hpricot_scan/hpricot_scan.c
|
68
|
+
- ext/hpricot_scan/hpricot_css.c
|
69
|
+
- ext/fast_xs/fast_xs.c
|
70
|
+
- ext/hpricot_scan/test.rb
|
71
|
+
- ext/hpricot_scan/extconf.rb
|
72
|
+
- ext/fast_xs/extconf.rb
|
73
|
+
- ext/hpricot_scan/hpricot_scan.rl
|
74
|
+
- ext/hpricot_scan/hpricot_scan.java.rl
|
75
|
+
- ext/hpricot_scan/hpricot_css.rl
|
76
|
+
- ext/hpricot_scan/hpricot_common.rl
|
77
|
+
- lib/hpricot_scan.so
|
78
|
+
- lib/fast_xs.so
|
79
|
+
has_rdoc: true
|
80
|
+
homepage: http://code.whytheluckystiff.net/hpricot/
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- --quiet
|
84
|
+
- --title
|
85
|
+
- The Hpricot Reference
|
86
|
+
- --main
|
87
|
+
- README
|
88
|
+
- --inline-source
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project: hobix
|
106
|
+
rubygems_version: 1.3.1
|
107
|
+
signing_key:
|
108
|
+
specification_version: 2
|
109
|
+
summary: a swift, liberal HTML parser with a fantastic library
|
110
|
+
test_files: []
|
111
|
+
|