htree 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data.tar.gz.sig +4 -0
  2. data/Makefile +20 -0
  3. data/Manifest +58 -0
  4. data/README +61 -0
  5. data/Rakefile +37 -0
  6. data/htree.gemspec +32 -0
  7. data/init.rb +1 -0
  8. data/install.rb +112 -0
  9. data/lib/htree.rb +97 -0
  10. data/lib/htree/container.rb +8 -0
  11. data/lib/htree/context.rb +69 -0
  12. data/lib/htree/display.rb +46 -0
  13. data/lib/htree/doc.rb +149 -0
  14. data/lib/htree/elem.rb +262 -0
  15. data/lib/htree/encoder.rb +217 -0
  16. data/lib/htree/equality.rb +219 -0
  17. data/lib/htree/extract_text.rb +37 -0
  18. data/lib/htree/fstr.rb +32 -0
  19. data/lib/htree/gencode.rb +193 -0
  20. data/lib/htree/htmlinfo.rb +672 -0
  21. data/lib/htree/inspect.rb +108 -0
  22. data/lib/htree/leaf.rb +92 -0
  23. data/lib/htree/loc.rb +369 -0
  24. data/lib/htree/modules.rb +49 -0
  25. data/lib/htree/name.rb +122 -0
  26. data/lib/htree/output.rb +212 -0
  27. data/lib/htree/parse.rb +410 -0
  28. data/lib/htree/raw_string.rb +127 -0
  29. data/lib/htree/regexp-util.rb +19 -0
  30. data/lib/htree/rexml.rb +131 -0
  31. data/lib/htree/scan.rb +176 -0
  32. data/lib/htree/tag.rb +113 -0
  33. data/lib/htree/template.rb +961 -0
  34. data/lib/htree/text.rb +115 -0
  35. data/lib/htree/traverse.rb +497 -0
  36. data/test-all.rb +5 -0
  37. data/test/assign.html +1 -0
  38. data/test/template.html +4 -0
  39. data/test/test-attr.rb +67 -0
  40. data/test/test-charset.rb +79 -0
  41. data/test/test-context.rb +29 -0
  42. data/test/test-display_xml.rb +45 -0
  43. data/test/test-elem-new.rb +101 -0
  44. data/test/test-encoder.rb +53 -0
  45. data/test/test-equality.rb +55 -0
  46. data/test/test-extract_text.rb +18 -0
  47. data/test/test-gencode.rb +27 -0
  48. data/test/test-leaf.rb +25 -0
  49. data/test/test-loc.rb +60 -0
  50. data/test/test-namespace.rb +147 -0
  51. data/test/test-output.rb +133 -0
  52. data/test/test-parse.rb +115 -0
  53. data/test/test-raw_string.rb +17 -0
  54. data/test/test-rexml.rb +70 -0
  55. data/test/test-scan.rb +153 -0
  56. data/test/test-security.rb +37 -0
  57. data/test/test-subnode.rb +142 -0
  58. data/test/test-template.rb +313 -0
  59. data/test/test-text.rb +43 -0
  60. data/test/test-traverse.rb +69 -0
  61. metadata +166 -0
  62. metadata.gz.sig +1 -0
@@ -0,0 +1,43 @@
1
+ require 'test/unit'
2
+ require 'htree/text'
3
+
4
+ class TestText < Test::Unit::TestCase
5
+ def test_new
6
+ assert_equal("abc&amp;amp;def", HTree::Text.new("abc&amp;def").rcdata)
7
+ end
8
+
9
+ =begin
10
+ def test_parse
11
+ assert_equal("abc&amp;def", HTree::Text.parse("abc&amp;def").rcdata)
12
+ end
13
+
14
+ def test_to_s
15
+ assert_equal("abc&def", HTree::Text.parse("abc&amp;def").to_s)
16
+ end
17
+ =end
18
+
19
+ def kcode(kc)
20
+ if "".respond_to? :force_encoding
21
+ if HTree::Encoder.internal_charset.start_with?(kc.upcase)
22
+ yield
23
+ end
24
+ else
25
+ old = $KCODE
26
+ begin
27
+ $KCODE = kc
28
+ yield
29
+ ensure
30
+ $KCODE = old
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_normalize
36
+ kcode('EUC') {
37
+ expected = "<ABC&#38;&#38;&#160;\xa6\xc1"
38
+ expected.force_encoding("euc-jp") if expected.respond_to? :force_encoding
39
+ assert_equal(expected,
40
+ HTree::Text.new_internal("&lt;&#65;&#x42;C&amp;&#38;&nbsp;&alpha;").normalized_rcdata)
41
+ }
42
+ end
43
+ end
@@ -0,0 +1,69 @@
1
+ require 'test/unit'
2
+ require 'htree/traverse'
3
+ require 'htree/parse'
4
+ require 'htree/equality'
5
+
6
+ class TestTraverse < Test::Unit::TestCase
7
+ def test_filter
8
+ l = HTree.parse('<a><b>x</b><b/><a/>').make_loc
9
+ l2 = l.filter {|n| n.path != 'doc()/a/b[1]' }
10
+ assert_equal(HTree.parse('<a><b/><a/>'), l2)
11
+ end
12
+
13
+ def test_title
14
+ inputs = [
15
+ HTree.parse('<html><title>aaa</title></html>'),
16
+ HTree.parse(<<'End')
17
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
18
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
19
+ xmlns="http://purl.org/rss/1.0/">
20
+ <channel>
21
+ <title>aaa</title>
22
+ </channel>
23
+ </rdf:RDF>
24
+ End
25
+ ]
26
+ result = HTree::Text.new('aaa')
27
+
28
+ inputs.each {|input|
29
+ assert_equal(result, input.title)
30
+ }
31
+
32
+ inputs.each {|input|
33
+ assert_equal(result, input.make_loc.title)
34
+ }
35
+
36
+ end
37
+
38
+ def test_author
39
+ inputs = [
40
+ HTree.parse('<html><meta name=author content=xxx></html>'),
41
+ HTree.parse('<html><link rev=made title=xxx></html>'),
42
+ HTree.parse(<<'End'),
43
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
44
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
45
+ xmlns="http://purl.org/rss/1.0/">
46
+ <channel>
47
+ <dc:creator>xxx</dc:creator>
48
+ </channel>
49
+ </rdf:RDF>
50
+ End
51
+ HTree.parse(<<'End')
52
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
53
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
54
+ xmlns="http://purl.org/rss/1.0/">
55
+ <channel>
56
+ <dc:publisher>xxx</dc:publisher>
57
+ </channel>
58
+ </rdf:RDF>
59
+ End
60
+ ]
61
+ result = HTree::Text.new('xxx')
62
+ inputs.each {|input|
63
+ #assert_equal(result, input.author)
64
+ }
65
+ inputs.each {|input|
66
+ assert_equal(result, input.make_loc.author)
67
+ }
68
+ end
69
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: htree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Tanaka Akira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDMjCCAhqgAwIBAgIBADANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhhZ3Bh
14
+ Y2tlcjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTEwMDEyNzIyMDMxOVoXDTExMDEyNzIyMDMxOVowPzERMA8GA1UEAwwIYWdw
16
+ YWNrZXIxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANPdi8ZJbhAOeYtX4sqe
18
+ 3WsjCDKCSZagMAMBExHDnMq+/furdoHcD2v1acBvnCt1UH1u2yJtCHLdLgOK7AQR
19
+ E/XRSNvuAhqjJFfuzWkvqDWBs5Aw5nQEUtWrEt5f7wiU7v4nHNa2FV4zYZCslKCv
20
+ DNFDULy9N7iYv2L4RWUFDw+jxyuHki1sz4gYNWtLhYSZPvuICYm8GburWfOTMBos
21
+ Fi+T5csfU6P2yFpUi59UPX2H/8ckfLA+VuSwALVzj1Kj/qJ2lq9A4lHOwMNTQ1Zy
22
+ QefTffufmADmN6yDasc+qDv0eZxx720TOEBCRxNGDDw8SzpdEWLxeXBxS91fujCR
23
+ 6NcCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFF3L
24
+ +uiqy+uhiRifGsIdqSuIbyblMA0GCSqGSIb3DQEBBQUAA4IBAQDNRaw0HFWyrt9y
25
+ JyjbV1aNs0Jv1vldt2YERlQDUHwaBNSFzkXAbOf2Zn6igBw+cC7J9cEuj+6JkF0d
26
+ VMnDnLe+KP/DI4PaHxKISylusm5hc1J4cjyg5FhF5xQAdnjpp8JvYGvC3/1sq0i6
27
+ CR2+jrvqlNa5n/GBWrUpeAlfbnpxKfto4Jdeg+2+f0F9/nAw0thmpQ1iJs/m3tmA
28
+ iB/7xVX8dpDGeJAGSf+Xfa1lmGe1a//8nEUszlNPtG4a/4r2cN5s2NFk0KKuvlTf
29
+ flvkJ7FlCt2CaB+Xsq+MFmODvF8t26zc4t0ZTv7jyHpkZb21nqiYw+mAZ9BGsbr5
30
+ 1/wPZ84P
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2010-01-27 00:00:00 -05:00
34
+ default_executable:
35
+ dependencies: []
36
+
37
+ description: Htree provides a tree data structure which represent HTML and XML data
38
+ email: akr@fsij.org
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README
45
+ - lib/htree.rb
46
+ - lib/htree/container.rb
47
+ - lib/htree/context.rb
48
+ - lib/htree/display.rb
49
+ - lib/htree/doc.rb
50
+ - lib/htree/elem.rb
51
+ - lib/htree/encoder.rb
52
+ - lib/htree/equality.rb
53
+ - lib/htree/extract_text.rb
54
+ - lib/htree/fstr.rb
55
+ - lib/htree/gencode.rb
56
+ - lib/htree/htmlinfo.rb
57
+ - lib/htree/inspect.rb
58
+ - lib/htree/leaf.rb
59
+ - lib/htree/loc.rb
60
+ - lib/htree/modules.rb
61
+ - lib/htree/name.rb
62
+ - lib/htree/output.rb
63
+ - lib/htree/parse.rb
64
+ - lib/htree/raw_string.rb
65
+ - lib/htree/regexp-util.rb
66
+ - lib/htree/rexml.rb
67
+ - lib/htree/scan.rb
68
+ - lib/htree/tag.rb
69
+ - lib/htree/template.rb
70
+ - lib/htree/text.rb
71
+ - lib/htree/traverse.rb
72
+ files:
73
+ - Makefile
74
+ - README
75
+ - Rakefile
76
+ - init.rb
77
+ - install.rb
78
+ - lib/htree.rb
79
+ - lib/htree/container.rb
80
+ - lib/htree/context.rb
81
+ - lib/htree/display.rb
82
+ - lib/htree/doc.rb
83
+ - lib/htree/elem.rb
84
+ - lib/htree/encoder.rb
85
+ - lib/htree/equality.rb
86
+ - lib/htree/extract_text.rb
87
+ - lib/htree/fstr.rb
88
+ - lib/htree/gencode.rb
89
+ - lib/htree/htmlinfo.rb
90
+ - lib/htree/inspect.rb
91
+ - lib/htree/leaf.rb
92
+ - lib/htree/loc.rb
93
+ - lib/htree/modules.rb
94
+ - lib/htree/name.rb
95
+ - lib/htree/output.rb
96
+ - lib/htree/parse.rb
97
+ - lib/htree/raw_string.rb
98
+ - lib/htree/regexp-util.rb
99
+ - lib/htree/rexml.rb
100
+ - lib/htree/scan.rb
101
+ - lib/htree/tag.rb
102
+ - lib/htree/template.rb
103
+ - lib/htree/text.rb
104
+ - lib/htree/traverse.rb
105
+ - test-all.rb
106
+ - test/assign.html
107
+ - test/template.html
108
+ - test/test-attr.rb
109
+ - test/test-charset.rb
110
+ - test/test-context.rb
111
+ - test/test-display_xml.rb
112
+ - test/test-elem-new.rb
113
+ - test/test-encoder.rb
114
+ - test/test-equality.rb
115
+ - test/test-extract_text.rb
116
+ - test/test-gencode.rb
117
+ - test/test-leaf.rb
118
+ - test/test-loc.rb
119
+ - test/test-namespace.rb
120
+ - test/test-output.rb
121
+ - test/test-parse.rb
122
+ - test/test-raw_string.rb
123
+ - test/test-rexml.rb
124
+ - test/test-scan.rb
125
+ - test/test-security.rb
126
+ - test/test-subnode.rb
127
+ - test/test-template.rb
128
+ - test/test-text.rb
129
+ - test/test-traverse.rb
130
+ - Manifest
131
+ - htree.gemspec
132
+ has_rdoc: true
133
+ homepage: http://www.a-k-r.org/htree/
134
+ licenses: []
135
+
136
+ post_install_message:
137
+ rdoc_options:
138
+ - --line-numbers
139
+ - --inline-source
140
+ - --title
141
+ - Htree
142
+ - --main
143
+ - README
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: "0"
151
+ version:
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: "1.2"
157
+ version:
158
+ requirements: []
159
+
160
+ rubyforge_project: htree
161
+ rubygems_version: 1.3.5
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: HTML/XML tree library
165
+ test_files: []
166
+
@@ -0,0 +1 @@
1
+ ���w�o���p�U}��8�ƭ�c�ٛ����ue��b0k~�O����Y{��u�}�/Ʃ��T<�W79V"w���Ҭ%G�� �x��B�tA5�}:݀��c��Ue�5N^��$}G�.LD�;�o�Yk�ڣ�m,ڽ�Eԯ�+�³��g�!Dw���!i*E�HyS^�ʃ�&A�|����f6��������^C�� _��ls��;��(��Ǯ��T�Ԫ�=I�ٴ�:���N��Ҭ1�@��=�}���