hpricot 0.6-mswin32 → 0.6.164-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,16 @@ module Hpricot
20
20
  # Is this object a stranded end tag?
21
21
  def bogusetag?() BogusETag::Trav === self end
22
22
 
23
+ # Parses an HTML string, making an HTML fragment based on
24
+ # the options used to create the container document.
25
+ def make(input = nil, &blk)
26
+ if parent and parent.respond_to? :make
27
+ parent.make(input, &blk)
28
+ else
29
+ Hpricot.make(input, &blk)
30
+ end
31
+ end
32
+
23
33
  # Builds an HTML string from this node and its contents.
24
34
  # If you need to write to a stream, try calling <tt>output(io)</tt>
25
35
  # as a method on this object.
@@ -109,12 +119,12 @@ module Hpricot
109
119
 
110
120
  # Adds elements immediately after this element, contained in the +html+ string.
111
121
  def after(html = nil, &blk)
112
- parent.insert_after(Hpricot.make(html, &blk), self)
122
+ parent.insert_after(make(html, &blk), self)
113
123
  end
114
124
 
115
125
  # Adds elements immediately before this element, contained in the +html+ string.
116
126
  def before(html = nil, &blk)
117
- parent.insert_before(Hpricot.make(html, &blk), self)
127
+ parent.insert_before(make(html, &blk), self)
118
128
  end
119
129
 
120
130
 
@@ -122,7 +132,7 @@ module Hpricot
122
132
  # in the +html+ string.
123
133
  def swap(html = nil, &blk)
124
134
  parent.altered!
125
- parent.replace_child(self, Hpricot.make(html, &blk))
135
+ parent.replace_child(self, make(html, &blk))
126
136
  end
127
137
 
128
138
  def get_subnode(*indexes)
@@ -158,7 +168,7 @@ module Hpricot
158
168
  when Array
159
169
  self.children = inner
160
170
  else
161
- self.children = Hpricot.make(inner, &blk)
171
+ self.children = make(inner, &blk)
162
172
  end
163
173
  reparent self.children
164
174
  else
@@ -513,8 +523,9 @@ module Hpricot
513
523
 
514
524
  def get_elements_by_tag_name(*a)
515
525
  list = Elements[]
526
+ a.delete("*")
516
527
  traverse_element(*a.map { |tag| [tag, "{http://www.w3.org/1999/xhtml}#{tag}"] }.flatten) do |e|
517
- list << e
528
+ list << e if e.elem?
518
529
  end
519
530
  list
520
531
  end
@@ -806,7 +817,7 @@ module Hpricot
806
817
  def set_attribute(name, val)
807
818
  altered!
808
819
  self.raw_attributes ||= {}
809
- self.raw_attributes[name.to_s] = Hpricot.xs(val)
820
+ self.raw_attributes[name.to_s] = val.fast_xs
810
821
  end
811
822
  alias_method :[]=, :set_attribute
812
823
  def remove_attribute(name)
Binary file
data/test/test_alter.rb CHANGED
@@ -58,6 +58,18 @@ class TestAlter < Test::Unit::TestCase
58
58
  assert_changed(@basic, "p[@class]", all_c2) { |p| p['class'].nil? }
59
59
  end
60
60
 
61
+ def test_xml_casing
62
+ doc = Hpricot.XML("<root><wildCat>text</wildCat></root>")
63
+ (doc/:root/:wildCat).after("<beanPole>gravity</beanPole>")
64
+ assert_equal doc.to_s, "<root><wildCat>text</wildCat><beanPole>gravity</beanPole></root>"
65
+
66
+ frag = Hpricot.XML do
67
+ b { i "A bit of HTML" }
68
+ end
69
+ (frag/:b).after("<beanPole>gravity</beanPole>")
70
+ assert_equal frag.to_s, "<b><i>A bit of HTML</i></b><beanPole>gravity</beanPole>"
71
+ end
72
+
61
73
  def assert_changed original, selector, set, &block
62
74
  assert set.all?(&block)
63
75
  assert Hpricot(original.to_html).search(selector).all?(&block)
data/test/test_builder.rb CHANGED
@@ -21,4 +21,17 @@ class TestBuilder < Test::Unit::TestCase
21
21
  assert_equal "<b>&#8364;&#8226;</b>", doc.to_html
22
22
  assert_equal "\342\202\254\342\200\242", doc.at("text()").to_s
23
23
  end
24
+
25
+ def test_escaping_attrs
26
+ text = "<span style='font-family:\"MS Mincho\"'>Some text</span>"
27
+ assert_equal "<span style=\"font-family:\\\"MS Mincho\\\"\">Some text</span>",
28
+ Hpricot(text).to_html
29
+ end
30
+
31
+ def test_korean_utf8_entities
32
+ # a = '한글'
33
+ a = "\xed\x95\x9c\xea\xb8\x80"
34
+ doc = Hpricot() { b a }
35
+ assert_equal "<b>&#54620;&#44544;</b>", doc.to_html
36
+ end
24
37
  end
data/test/test_parser.rb CHANGED
@@ -47,6 +47,13 @@ class TestParser < Test::Unit::TestCase
47
47
  assert_equal 'link1', @basic.get_elements_by_tag_name('a')[0].get_attribute('id')
48
48
  assert_equal 'link1', @basic.get_elements_by_tag_name('body')[0].get_element_by_id('link1').get_attribute('id')
49
49
  end
50
+
51
+ def test_get_elements_by_tag_name_star
52
+ simple = Hpricot.parse("<div><p id='first'>First</p><p id='second'>Second</p></div>")
53
+ assert_equal 3, simple.get_elements_by_tag_name("*").size
54
+ assert_equal 1, simple.get_elements_by_tag_name("div").size
55
+ assert_equal 2, simple.get_elements_by_tag_name("p").size
56
+ end
50
57
 
51
58
  def test_output_basic
52
59
  @basic = Hpricot.parse(TestFiles::BASIC)
data/test/test_paths.rb CHANGED
@@ -13,4 +13,13 @@ class TestParser < Test::Unit::TestCase
13
13
  assert_equal ele, @basic.at(ele.xpath)
14
14
  end
15
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
16
25
  end
metadata CHANGED
@@ -1,82 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: hpricot
5
3
  version: !ruby/object:Gem::Version
6
- version: "0.6"
7
- date: 2007-06-15 00:00:00 -07:00
8
- summary: a swift, liberal HTML parser with a fantastic library
9
- require_paths:
10
- - lib/i686-linux
11
- - lib
12
- email: why@ruby-lang.org
13
- homepage: http://code.whytheluckystiff.net/hpricot/
14
- rubyforge_project:
15
- description: a swift, liberal HTML parser with a fantastic library
16
- autorequire:
17
- default_executable:
18
- bindir: bin
19
- has_rdoc: true
20
- required_ruby_version: !ruby/object:Gem::Version::Requirement
21
- requirements:
22
- - - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
25
- version:
4
+ version: 0.6.164
26
5
  platform: mswin32
27
- signing_key:
28
- cert_chain:
29
- post_install_message:
30
6
  authors:
31
7
  - why the lucky stiff
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
+
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
32
26
  files:
33
27
  - CHANGELOG
34
28
  - COPYING
35
29
  - README
36
30
  - Rakefile
37
- - test/files
38
- - test/test_preserved.rb
39
31
  - test/test_paths.rb
40
- - test/load_files.rb
41
- - test/test_xml.rb
32
+ - test/test_preserved.rb
42
33
  - test/test_parser.rb
43
- - test/test_alter.rb
44
- - test/test_builder.rb
45
- - test/files/why.xml
34
+ - test/files
35
+ - test/files/cy0.html
36
+ - test/files/pace_application.html
37
+ - test/files/basic.xhtml
38
+ - test/files/utf8.html
46
39
  - test/files/boingboing.html
47
- - test/files/uswebgen.html
48
- - test/files/immob.html
49
40
  - test/files/week9.html
50
- - test/files/utf8.html
51
- - test/files/basic.xhtml
52
- - test/files/cy0.html
53
41
  - test/files/tenderlove.html
54
- - test/files/pace_application.html
42
+ - test/files/immob.html
43
+ - test/files/why.xml
44
+ - test/files/uswebgen.html
45
+ - test/load_files.rb
46
+ - test/test_builder.rb
47
+ - test/test_xml.rb
48
+ - test/test_alter.rb
55
49
  - lib/hpricot
56
- - lib/hpricot.rb
57
- - lib/i686-linux
50
+ - lib/hpricot/tags.rb
58
51
  - lib/hpricot/builder.rb
59
- - lib/hpricot/htmlinfo.rb
60
- - lib/hpricot/xchar.rb
61
- - lib/hpricot/inspect.rb
62
- - lib/hpricot/modules.rb
63
- - lib/hpricot/parse.rb
64
- - lib/hpricot/tag.rb
65
52
  - lib/hpricot/traverse.rb
66
53
  - lib/hpricot/elements.rb
67
- - lib/hpricot/tags.rb
54
+ - lib/hpricot/modules.rb
55
+ - lib/hpricot/inspect.rb
56
+ - lib/hpricot/tag.rb
68
57
  - lib/hpricot/blankslate.rb
58
+ - lib/hpricot/xchar.rb
59
+ - lib/hpricot/htmlinfo.rb
60
+ - lib/hpricot/parse.rb
61
+ - lib/hpricot.rb
69
62
  - extras/mingw-rbconfig.rb
70
63
  - ext/hpricot_scan/hpricot_scan.h
64
+ - ext/hpricot_scan/hpricot_gram.h
71
65
  - ext/hpricot_scan/HpricotScanService.java
66
+ - ext/fast_xs/FastXsService.java
72
67
  - ext/hpricot_scan/hpricot_scan.c
68
+ - ext/hpricot_scan/hpricot_gram.c
69
+ - ext/fast_xs/fast_xs.c
70
+ - ext/hpricot_scan/test.rb
73
71
  - ext/hpricot_scan/extconf.rb
74
- - ext/hpricot_scan/hpricot_common.rl
72
+ - ext/fast_xs/extconf.rb
75
73
  - ext/hpricot_scan/hpricot_scan.rl
76
74
  - ext/hpricot_scan/hpricot_scan.java.rl
77
- - lib/i686-linux/hpricot_scan.so
78
- test_files: []
79
-
75
+ - ext/hpricot_scan/hpricot_common.rl
76
+ - lib/hpricot_scan.so
77
+ - lib/fast_xs.so
78
+ has_rdoc: true
79
+ homepage: http://code.whytheluckystiff.net/hpricot/
80
+ post_install_message:
80
81
  rdoc_options:
81
82
  - --quiet
82
83
  - --title
@@ -84,15 +85,26 @@ rdoc_options:
84
85
  - --main
85
86
  - README
86
87
  - --inline-source
87
- extra_rdoc_files:
88
- - README
89
- - CHANGELOG
90
- - COPYING
91
- executables: []
92
-
93
- extensions: []
94
-
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ version:
95
102
  requirements: []
96
103
 
97
- dependencies: []
104
+ rubyforge_project: hobix
105
+ rubygems_version: 1.3.0
106
+ signing_key:
107
+ specification_version: 2
108
+ summary: a swift, liberal HTML parser with a fantastic library
109
+ test_files: []
98
110
 
Binary file