libxml-ruby 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/HISTORY +14 -2
  2. data/MANIFEST +1 -0
  3. data/README.rdoc +2 -2
  4. data/ext/libxml/ruby_xml_document.c +191 -29
  5. data/ext/libxml/ruby_xml_document.h +1 -0
  6. data/ext/libxml/ruby_xml_encoding.c +21 -7
  7. data/ext/libxml/ruby_xml_encoding.h +1 -0
  8. data/ext/libxml/ruby_xml_node.c +38 -0
  9. data/ext/libxml/ruby_xml_sax2_handler.c +30 -34
  10. data/ext/libxml/ruby_xml_sax_parser.c +0 -14
  11. data/ext/libxml/ruby_xml_version.h +4 -4
  12. data/lib/libxml/document.rb +18 -16
  13. data/libxml-ruby.gemspec +3 -2
  14. data/test/c14n/given/doc.dtd +1 -0
  15. data/test/c14n/given/example-1.xml +14 -0
  16. data/test/c14n/given/example-2.xml +11 -0
  17. data/test/c14n/given/example-3.xml +18 -0
  18. data/test/c14n/given/example-4.xml +9 -0
  19. data/test/c14n/given/example-5.xml +12 -0
  20. data/test/c14n/given/example-6.xml +2 -0
  21. data/test/c14n/given/example-7.xml +11 -0
  22. data/test/c14n/given/example-8.xml +11 -0
  23. data/test/c14n/given/example-8.xpath +10 -0
  24. data/test/c14n/given/world.txt +1 -0
  25. data/test/c14n/result/1-1-without-comments/example-1 +4 -0
  26. data/test/c14n/result/1-1-without-comments/example-2 +11 -0
  27. data/test/c14n/result/1-1-without-comments/example-3 +14 -0
  28. data/test/c14n/result/1-1-without-comments/example-4 +9 -0
  29. data/test/c14n/result/1-1-without-comments/example-5 +3 -0
  30. data/test/c14n/result/1-1-without-comments/example-6 +1 -0
  31. data/test/c14n/result/1-1-without-comments/example-7 +1 -0
  32. data/test/c14n/result/1-1-without-comments/example-8 +1 -0
  33. data/test/c14n/result/with-comments/example-1 +6 -0
  34. data/test/c14n/result/with-comments/example-2 +11 -0
  35. data/test/c14n/result/with-comments/example-3 +14 -0
  36. data/test/c14n/result/with-comments/example-4 +9 -0
  37. data/test/c14n/result/with-comments/example-5 +4 -0
  38. data/test/c14n/result/with-comments/example-6 +1 -0
  39. data/test/c14n/result/with-comments/example-7 +1 -0
  40. data/test/c14n/result/without-comments/example-1 +4 -0
  41. data/test/c14n/result/without-comments/example-2 +11 -0
  42. data/test/c14n/result/without-comments/example-3 +14 -0
  43. data/test/c14n/result/without-comments/example-4 +9 -0
  44. data/test/c14n/result/without-comments/example-5 +3 -0
  45. data/test/c14n/result/without-comments/example-6 +1 -0
  46. data/test/c14n/result/without-comments/example-7 +1 -0
  47. data/test/tc_canonicalize.rb +125 -0
  48. data/test/tc_document.rb +2 -18
  49. data/test/tc_encoding.rb +7 -5
  50. data/test/tc_encoding_sax.rb +115 -0
  51. data/test/tc_node_pi.rb +40 -0
  52. data/test/tc_xpath.rb +23 -0
  53. data/test/test_suite.rb +7 -1
  54. metadata +45 -6
  55. data/test/new_main.rb +0 -29
@@ -0,0 +1,40 @@
1
+ # encoding: UTF-8
2
+
3
+ require './test_helper'
4
+
5
+ require 'test/unit'
6
+
7
+ class NodeCommentTest < Test::Unit::TestCase
8
+ def setup
9
+ xp = XML::Parser.string('<root></root>')
10
+ @doc = xp.parse
11
+ assert_instance_of(XML::Document, @doc)
12
+ @root = @doc.root
13
+ end
14
+
15
+ def test_libxml_node_add_pi_01
16
+ @root << XML::Node.new_pi('mypi')
17
+ assert_equal '<root><?mypi?></root>',
18
+ @root.to_s.gsub(/\n\s*/,'')
19
+ end
20
+
21
+ def test_libxml_node_add_pi_02
22
+ @root << XML::Node.new_pi('mypi')
23
+ assert_equal 'pi',
24
+ @root.child.node_type_name
25
+ end
26
+
27
+ def test_libxml_node_add_pi_03
28
+ @root << el = XML::Node.new_pi('mypi')
29
+ el << "_this_is_added"
30
+ assert_equal '<root><?mypi _this_is_added?></root>',
31
+ @root.to_s.gsub(/\n\s*/,'')
32
+ end
33
+
34
+ def test_libxml_node_add_pi_04
35
+ @root << XML::Node.new_pi('mypi','mycontent')
36
+ assert_equal '<root><?mypi mycontent?></root>',
37
+ @root.to_s.gsub(/\n\s*/,'')
38
+ end
39
+
40
+ end
@@ -207,4 +207,27 @@ class TestXPath < Test::Unit::TestCase
207
207
  end
208
208
  assert_equal("Error: Invalid expression.", error.to_s)
209
209
  end
210
+
211
+ def test_find_cdata
212
+ doc = LibXML::XML::Document.string('<root>hi there <![CDATA[ mycdata ]]> bye!</root>')
213
+
214
+ nodes = doc.find('/root/text()')
215
+ assert_equal(3, nodes.length)
216
+ assert_equal(nodes[0].node_type, LibXML::XML::Node::TEXT_NODE)
217
+ assert_equal(nodes[0].content, 'hi there ')
218
+
219
+ assert_equal(nodes[1].node_type, LibXML::XML::Node::CDATA_SECTION_NODE)
220
+ assert_equal(nodes[1].content, ' mycdata ')
221
+
222
+ assert_equal(nodes[2].node_type, LibXML::XML::Node::TEXT_NODE)
223
+ assert_equal(nodes[2].content, ' bye!')
224
+ end
225
+
226
+ def test_find_comment
227
+ doc = LibXML::XML::Document.string('<root>hi there <!-- my comment --> bye!</root>')
228
+
229
+ nodes = doc.find('//comment()')
230
+ assert_equal(1, nodes.length)
231
+ assert_equal(nodes[0].content, ' my comment ')
232
+ end
210
233
  end
@@ -8,10 +8,10 @@ Dir.chdir(dir)
8
8
  require './tc_attr'
9
9
  require './tc_attr_decl'
10
10
  require './tc_attributes'
11
+ require './tc_canonicalize'
11
12
  require './tc_document'
12
13
  require './tc_document_write'
13
14
  require './tc_dtd'
14
- require './tc_encoding'
15
15
  require './tc_error'
16
16
  require './tc_html_parser'
17
17
  require './tc_html_parser_context'
@@ -22,6 +22,7 @@ require './tc_node_cdata'
22
22
  require './tc_node_comment'
23
23
  require './tc_node_copy'
24
24
  require './tc_node_edit'
25
+ require './tc_node_pi'
25
26
  require './tc_node_text'
26
27
  require './tc_node_write'
27
28
  require './tc_node_xlink'
@@ -38,6 +39,11 @@ require './tc_xpath_context'
38
39
  require './tc_xpath_expression'
39
40
  require './tc_xpointer'
40
41
 
42
+
43
+ if defined?(Encoding)
44
+ require './tc_encoding'
45
+ require './tc_encoding_sax'
46
+ end
41
47
  # Compatibility
42
48
  require './tc_properties'
43
49
  require './tc_deprecated_require'
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 2
9
- - 2
10
- version: 2.2.2
8
+ - 3
9
+ - 0
10
+ version: 2.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ross Bamform
@@ -16,11 +16,12 @@ authors:
16
16
  - Dan Janwoski
17
17
  - Anurag Priyam
18
18
  - Charlie Savage
19
+ - Ryan Johnson
19
20
  autorequire:
20
21
  bindir: bin
21
22
  cert_chain: []
22
23
 
23
- date: 2011-08-29 00:00:00 Z
24
+ date: 2012-03-18 00:00:00 Z
24
25
  dependencies: []
25
26
 
26
27
  description: " The Libxml-Ruby project provides Ruby language bindings for the GNOME\n Libxml2 XML toolkit. It is free software, released under the MIT License.\n Libxml-ruby's primary advantage over REXML is performance - if speed\n is your need, these are good libraries to consider, as demonstrated\n by the informal benchmark below.\n"
@@ -134,6 +135,39 @@ files:
134
135
  - script/benchmark/sock_entries.xml
135
136
  - script/benchmark/throughput
136
137
  - script/test
138
+ - test/c14n/given/doc.dtd
139
+ - test/c14n/given/example-1.xml
140
+ - test/c14n/given/example-2.xml
141
+ - test/c14n/given/example-3.xml
142
+ - test/c14n/given/example-4.xml
143
+ - test/c14n/given/example-5.xml
144
+ - test/c14n/given/example-6.xml
145
+ - test/c14n/given/example-7.xml
146
+ - test/c14n/given/example-8.xml
147
+ - test/c14n/given/example-8.xpath
148
+ - test/c14n/given/world.txt
149
+ - test/c14n/result/1-1-without-comments/example-1
150
+ - test/c14n/result/1-1-without-comments/example-2
151
+ - test/c14n/result/1-1-without-comments/example-3
152
+ - test/c14n/result/1-1-without-comments/example-4
153
+ - test/c14n/result/1-1-without-comments/example-5
154
+ - test/c14n/result/1-1-without-comments/example-6
155
+ - test/c14n/result/1-1-without-comments/example-7
156
+ - test/c14n/result/1-1-without-comments/example-8
157
+ - test/c14n/result/with-comments/example-1
158
+ - test/c14n/result/with-comments/example-2
159
+ - test/c14n/result/with-comments/example-3
160
+ - test/c14n/result/with-comments/example-4
161
+ - test/c14n/result/with-comments/example-5
162
+ - test/c14n/result/with-comments/example-6
163
+ - test/c14n/result/with-comments/example-7
164
+ - test/c14n/result/without-comments/example-1
165
+ - test/c14n/result/without-comments/example-2
166
+ - test/c14n/result/without-comments/example-3
167
+ - test/c14n/result/without-comments/example-4
168
+ - test/c14n/result/without-comments/example-5
169
+ - test/c14n/result/without-comments/example-6
170
+ - test/c14n/result/without-comments/example-7
137
171
  - test/etc_doc_to_s.rb
138
172
  - test/ets_doc_file.rb
139
173
  - test/ets_doc_to_s.rb
@@ -157,15 +191,16 @@ files:
157
191
  - test/model/shiporder.xsd
158
192
  - test/model/soap.xml
159
193
  - test/model/xinclude.xml
160
- - test/new_main.rb
161
194
  - test/tc_attr.rb
162
195
  - test/tc_attributes.rb
163
196
  - test/tc_attr_decl.rb
197
+ - test/tc_canonicalize.rb
164
198
  - test/tc_deprecated_require.rb
165
199
  - test/tc_document.rb
166
200
  - test/tc_document_write.rb
167
201
  - test/tc_dtd.rb
168
202
  - test/tc_encoding.rb
203
+ - test/tc_encoding_sax.rb
169
204
  - test/tc_error.rb
170
205
  - test/tc_gc.rb
171
206
  - test/tc_html_parser.rb
@@ -177,6 +212,7 @@ files:
177
212
  - test/tc_node_comment.rb
178
213
  - test/tc_node_copy.rb
179
214
  - test/tc_node_edit.rb
215
+ - test/tc_node_pi.rb
180
216
  - test/tc_node_text.rb
181
217
  - test/tc_node_write.rb
182
218
  - test/tc_node_xlink.rb
@@ -227,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
263
  requirements: []
228
264
 
229
265
  rubyforge_project:
230
- rubygems_version: 1.7.2
266
+ rubygems_version: 1.8.10
231
267
  signing_key:
232
268
  specification_version: 3
233
269
  summary: Ruby Bindings for LibXML2
@@ -235,11 +271,13 @@ test_files:
235
271
  - test/tc_attr.rb
236
272
  - test/tc_attributes.rb
237
273
  - test/tc_attr_decl.rb
274
+ - test/tc_canonicalize.rb
238
275
  - test/tc_deprecated_require.rb
239
276
  - test/tc_document.rb
240
277
  - test/tc_document_write.rb
241
278
  - test/tc_dtd.rb
242
279
  - test/tc_encoding.rb
280
+ - test/tc_encoding_sax.rb
243
281
  - test/tc_error.rb
244
282
  - test/tc_gc.rb
245
283
  - test/tc_html_parser.rb
@@ -251,6 +289,7 @@ test_files:
251
289
  - test/tc_node_comment.rb
252
290
  - test/tc_node_copy.rb
253
291
  - test/tc_node_edit.rb
292
+ - test/tc_node_pi.rb
254
293
  - test/tc_node_text.rb
255
294
  - test/tc_node_write.rb
256
295
  - test/tc_node_xlink.rb
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- string1 = "(ISC)²"
4
- puts string1.encoding
5
- puts string1.bytes.to_a.join(' ')
6
- puts string1
7
-
8
- puts ""
9
- string2 = string1.encode('iso-8859-1')
10
- puts string2.encoding
11
- puts string2.bytes.to_a.join(' ')
12
- puts string2
13
-
14
- puts ""
15
- string3 = string1.force_encoding('iso-8859-1').encode('utf-8')
16
- puts string3.encoding
17
- puts string3.bytes.to_a.join(' ')
18
- puts string3
19
-
20
- #UTF-8
21
- #40 73 83 67 41 194 178
22
- #(ISC)²
23
- #
24
- #ISO-8859-1
25
- #40 73 83 67 41 178
26
- #(ISC)²
27
-
28
-
29
- #40 73 83 67 41 195 130 194 178