hpricot 0.7-x86-mswin32 → 0.8-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fast_xs.so CHANGED
Binary file
@@ -11,7 +11,7 @@ module Hpricot
11
11
 
12
12
  class Doc
13
13
  def pretty_print(q)
14
- q.object_group(self) { children.each {|elt| q.breakable; q.pp elt } }
14
+ q.object_group(self) { children.each {|elt| q.breakable; q.pp elt } if children }
15
15
  end
16
16
  alias inspect pretty_print_inspect
17
17
  end
@@ -47,7 +47,7 @@ module Hpricot
47
47
  children.each {|elt| q.breakable; q.pp elt }
48
48
  end
49
49
  if etag
50
- q.breakable; q.pp etag
50
+ q.breakable; q.text etag
51
51
  end
52
52
  }
53
53
  end
@@ -8,11 +8,13 @@ module Hpricot
8
8
  # :startdoc:
9
9
 
10
10
  module Node; include Hpricot end
11
+ class ETag; include Node end
11
12
  module Container; include Node end
12
13
  class Doc; include Container end
13
14
  class Elem; include Container end
14
15
 
15
16
  module Leaf; include Node end
17
+ class CData; include Leaf end
16
18
  class Text; include Leaf end
17
19
  class XMLDecl; include Leaf end
18
20
  class DocType; include Leaf end
data/lib/hpricot/tag.rb CHANGED
@@ -17,10 +17,11 @@ module Hpricot
17
17
  end
18
18
  end
19
19
 
20
- class BaseEle
20
+ module Node
21
21
  def html_quote(str)
22
22
  "\"" + str.gsub('"', '\\"') + "\""
23
23
  end
24
+ def clear_raw; end
24
25
  def if_output(opts)
25
26
  if opts[:preserve] and not raw_string.nil?
26
27
  raw_string
@@ -77,13 +78,10 @@ module Hpricot
77
78
  if children
78
79
  children.each { |n| n.output(out, opts) }
79
80
  end
80
- if etag
81
- etag.output(out, opts)
82
- elsif !opts[:preserve] && !empty?
83
- out <<
84
- if_output(opts) do
85
- "</#{name}>"
86
- end
81
+ if opts[:preserve]
82
+ out << etag if etag
83
+ elsif etag or !empty?
84
+ out << "</#{name}>"
87
85
  end
88
86
  out
89
87
  end
@@ -101,7 +99,7 @@ module Hpricot
101
99
  end
102
100
  end
103
101
 
104
- class ETag
102
+ class BogusETag
105
103
  def initialize name; self.name = name end
106
104
  def output(out, opts = {})
107
105
  out <<
@@ -111,7 +109,7 @@ module Hpricot
111
109
  end
112
110
  end
113
111
 
114
- class BogusETag
112
+ class ETag < BogusETag
115
113
  def output(out, opts = {}); out << if_output(opts) { '' }; end
116
114
  end
117
115
 
@@ -136,6 +134,8 @@ module Hpricot
136
134
  def initialize content; self.content = content end
137
135
  alias_method :to_s, :content
138
136
  alias_method :to_plain_text, :content
137
+ alias_method :inner_text, :content
138
+ def raw_string; "<![CDATA[#{content}]]>" end
139
139
  def output(out, opts = {})
140
140
  out <<
141
141
  if_output(opts) do
@@ -174,6 +174,7 @@ module Hpricot
174
174
 
175
175
  class ProcIns
176
176
  def pathname; "procins()" end
177
+ def raw_string; output("") end
177
178
  def output(out, opts = {})
178
179
  out <<
179
180
  if_output(opts) do
@@ -186,6 +187,7 @@ module Hpricot
186
187
 
187
188
  class Comment
188
189
  def pathname; "comment()" end
190
+ def raw_string; "<!--#{content}-->" end
189
191
  def output(out, opts = {})
190
192
  out <<
191
193
  if_output(opts) do
data/lib/hpricot_scan.so CHANGED
Binary file
data/test/test_parser.rb CHANGED
@@ -406,4 +406,15 @@ class TestParser < Test::Unit::TestCase
406
406
  assert_equal "\303\251", Hpricot.uxs('&eacute;')
407
407
  end
408
408
  end
409
+
410
+ def test_cdata_inner_text
411
+ xml = Hpricot.XML(%{
412
+ <peon>
413
+ <id>96586</id>
414
+ <stdout><![CDATA[This is STDOUT]]></stdout>
415
+ <stderr><!-- IGNORE --><![CDATA[This is]]> STDERR</stderr>
416
+ </peon>})
417
+ assert_equal "This is STDOUT", (xml/:peon/:stdout).inner_text
418
+ assert_equal "This is STDERR", (xml/:peon/:stderr).inner_text
419
+ end
409
420
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hpricot
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.7"
4
+ version: "0.8"
5
5
  platform: x86-mswin32
6
6
  authors:
7
7
  - why the lucky stiff
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-17 00:00:00 -07:00
12
+ date: 2009-04-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15