nokogiri 1.5.0.beta.2 → 1.5.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (107) hide show
  1. data/CHANGELOG.ja.rdoc +63 -0
  2. data/CHANGELOG.rdoc +44 -1
  3. data/Manifest.txt +3 -3
  4. data/README.ja.rdoc +4 -4
  5. data/README.rdoc +4 -4
  6. data/Rakefile +3 -0
  7. data/bin/nokogiri +6 -1
  8. data/ext/java/nokogiri/EncodingHandler.java +32 -0
  9. data/ext/java/nokogiri/HtmlDocument.java +36 -0
  10. data/ext/java/nokogiri/HtmlElementDescription.java +34 -0
  11. data/ext/java/nokogiri/HtmlEntityLookup.java +34 -0
  12. data/ext/java/nokogiri/HtmlSaxParserContext.java +41 -3
  13. data/ext/java/nokogiri/NokogiriService.java +109 -13
  14. data/ext/java/nokogiri/XmlAttr.java +40 -4
  15. data/ext/java/nokogiri/XmlAttributeDecl.java +32 -0
  16. data/ext/java/nokogiri/XmlCdata.java +41 -2
  17. data/ext/java/nokogiri/XmlComment.java +38 -1
  18. data/ext/java/nokogiri/XmlDocument.java +56 -11
  19. data/ext/java/nokogiri/XmlDocumentFragment.java +39 -30
  20. data/ext/java/nokogiri/XmlDtd.java +37 -0
  21. data/ext/java/nokogiri/XmlElement.java +51 -2
  22. data/ext/java/nokogiri/XmlElementContent.java +32 -0
  23. data/ext/java/nokogiri/XmlElementDecl.java +32 -0
  24. data/ext/java/nokogiri/XmlEntityDecl.java +32 -0
  25. data/ext/java/nokogiri/XmlEntityReference.java +35 -2
  26. data/ext/java/nokogiri/XmlNamespace.java +55 -5
  27. data/ext/java/nokogiri/XmlNode.java +129 -136
  28. data/ext/java/nokogiri/XmlNodeSet.java +36 -0
  29. data/ext/java/nokogiri/XmlProcessingInstruction.java +34 -1
  30. data/ext/java/nokogiri/XmlReader.java +36 -0
  31. data/ext/java/nokogiri/XmlRelaxng.java +34 -1
  32. data/ext/java/nokogiri/XmlSaxParserContext.java +52 -7
  33. data/ext/java/nokogiri/XmlSaxPushParser.java +36 -0
  34. data/ext/java/nokogiri/XmlSchema.java +34 -1
  35. data/ext/java/nokogiri/XmlSyntaxError.java +48 -18
  36. data/ext/java/nokogiri/XmlText.java +45 -6
  37. data/ext/java/nokogiri/XmlXpathContext.java +45 -0
  38. data/ext/java/nokogiri/XsltStylesheet.java +58 -3
  39. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +50 -26
  40. data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +35 -1
  41. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +51 -13
  42. data/ext/java/nokogiri/internals/NokogiriHandler.java +70 -21
  43. data/ext/java/nokogiri/internals/NokogiriHelpers.java +95 -38
  44. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +37 -3
  45. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +39 -1
  46. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +43 -7
  47. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +77 -10
  48. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +49 -20
  49. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +34 -2
  50. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -1
  51. data/ext/java/nokogiri/internals/ParserContext.java +32 -0
  52. data/ext/java/nokogiri/internals/PushInputStream.java +33 -3
  53. data/ext/java/nokogiri/internals/ReaderNode.java +50 -8
  54. data/ext/java/nokogiri/internals/SaveContext.java +35 -2
  55. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +34 -1
  56. data/ext/java/nokogiri/internals/XmlDeclHandler.java +32 -0
  57. data/ext/java/nokogiri/internals/XmlDomParser.java +32 -0
  58. data/ext/java/nokogiri/internals/XmlDomParserContext.java +43 -11
  59. data/ext/java/nokogiri/internals/XmlSaxParser.java +32 -0
  60. data/ext/java/nokogiri/internals/XsltExtensionFunction.java +72 -0
  61. data/ext/nokogiri/depend +358 -32
  62. data/ext/nokogiri/extconf.rb +1 -3
  63. data/ext/nokogiri/nokogiri.c +2 -0
  64. data/ext/nokogiri/nokogiri.h +7 -0
  65. data/ext/nokogiri/xml_dtd.c +2 -2
  66. data/ext/nokogiri/xml_io.c +2 -2
  67. data/ext/nokogiri/xml_node.c +31 -6
  68. data/ext/nokogiri/xml_node_set.c +1 -1
  69. data/ext/nokogiri/xml_sax_parser.c +1 -1
  70. data/ext/nokogiri/xml_sax_parser_context.c +40 -0
  71. data/ext/nokogiri/xml_xpath_context.c +33 -2
  72. data/ext/nokogiri/xslt_stylesheet.c +122 -6
  73. data/lib/nokogiri.rb +12 -5
  74. data/lib/nokogiri/css/generated_tokenizer.rb +1 -2
  75. data/lib/nokogiri/css/xpath_visitor.rb +15 -7
  76. data/lib/nokogiri/decorators/slop.rb +5 -3
  77. data/lib/nokogiri/html/document.rb +3 -3
  78. data/lib/nokogiri/html/document_fragment.rb +19 -17
  79. data/lib/nokogiri/version.rb +1 -1
  80. data/lib/nokogiri/xml/document.rb +26 -1
  81. data/lib/nokogiri/xml/document_fragment.rb +2 -2
  82. data/lib/nokogiri/xml/dtd.rb +11 -0
  83. data/lib/nokogiri/xml/node.rb +156 -45
  84. data/lib/nokogiri/xml/node_set.rb +2 -2
  85. data/lib/nokogiri/xml/reader.rb +36 -0
  86. data/lib/nokogiri/xml/sax/document.rb +4 -2
  87. data/lib/nokogiri/xslt.rb +9 -5
  88. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  89. data/tasks/cross_compile.rb +27 -8
  90. data/test/css/test_parser.rb +29 -18
  91. data/test/decorators/test_slop.rb +16 -0
  92. data/test/html/test_document_fragment.rb +46 -3
  93. data/test/html/test_node.rb +9 -0
  94. data/test/xml/sax/test_parser.rb +11 -3
  95. data/test/xml/sax/test_parser_context.rb +50 -0
  96. data/test/xml/sax/test_push_parser.rb +18 -1
  97. data/test/xml/test_document_fragment.rb +15 -8
  98. data/test/xml/test_dtd.rb +15 -0
  99. data/test/xml/test_node.rb +31 -2
  100. data/test/xml/test_node_reparenting.rb +59 -31
  101. data/test/xml/test_node_set.rb +13 -0
  102. data/test/xml/test_xpath.rb +32 -0
  103. data/test/xslt/test_custom_functions.rb +94 -0
  104. metadata +83 -81
  105. data/lib/nokogiri/nokogiri.jar +0 -0
  106. data/spec/helper.rb +0 -3
  107. data/spec/xml/reader_spec.rb +0 -307
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196439
4
+ hash: 62196437
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
9
  - 0
10
10
  - beta
11
- - 2
12
- version: 1.5.0.beta.2
11
+ - 3
12
+ version: 1.5.0.beta.3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Aaron Patterson
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-07-30 00:00:00 -07:00
21
+ date: 2010-12-02 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -103,12 +103,12 @@ dependencies:
103
103
  requirements:
104
104
  - - ">="
105
105
  - !ruby/object:Gem::Version
106
- hash: 23
106
+ hash: 19
107
107
  segments:
108
108
  - 2
109
109
  - 6
110
- - 0
111
- version: 2.6.0
110
+ - 2
111
+ version: 2.6.2
112
112
  type: :development
113
113
  version_requirements: *id006
114
114
  description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's\n\
@@ -124,43 +124,43 @@ extensions:
124
124
  - ext/nokogiri/extconf.rb
125
125
  extra_rdoc_files:
126
126
  - Manifest.txt
127
- - CHANGELOG.ja.rdoc
128
127
  - CHANGELOG.rdoc
129
- - README.ja.rdoc
128
+ - CHANGELOG.ja.rdoc
130
129
  - README.rdoc
131
- - ext/nokogiri/html_document.c
130
+ - README.ja.rdoc
131
+ - ext/nokogiri/xml_io.c
132
+ - ext/nokogiri/xml_sax_parser.c
133
+ - ext/nokogiri/xml_xpath_context.c
132
134
  - ext/nokogiri/html_element_description.c
133
- - ext/nokogiri/html_entity_lookup.c
134
- - ext/nokogiri/html_sax_parser_context.c
135
- - ext/nokogiri/nokogiri.c
136
- - ext/nokogiri/xml_attr.c
135
+ - ext/nokogiri/xml_libxml2_hacks.c
136
+ - ext/nokogiri/xml_sax_parser_context.c
137
+ - ext/nokogiri/xml_sax_push_parser.c
137
138
  - ext/nokogiri/xml_attribute_decl.c
138
- - ext/nokogiri/xml_cdata.c
139
- - ext/nokogiri/xml_comment.c
140
- - ext/nokogiri/xml_document.c
141
- - ext/nokogiri/xml_document_fragment.c
142
- - ext/nokogiri/xml_dtd.c
143
- - ext/nokogiri/xml_element_content.c
139
+ - ext/nokogiri/nokogiri.c
144
140
  - ext/nokogiri/xml_element_decl.c
145
- - ext/nokogiri/xml_encoding_handler.c
146
- - ext/nokogiri/xml_entity_decl.c
141
+ - ext/nokogiri/xml_element_content.c
142
+ - ext/nokogiri/html_entity_lookup.c
143
+ - ext/nokogiri/xml_dtd.c
144
+ - ext/nokogiri/xslt_stylesheet.c
145
+ - ext/nokogiri/xml_node_set.c
146
+ - ext/nokogiri/xml_document_fragment.c
147
+ - ext/nokogiri/xml_text.c
147
148
  - ext/nokogiri/xml_entity_reference.c
148
- - ext/nokogiri/xml_io.c
149
- - ext/nokogiri/xml_libxml2_hacks.c
149
+ - ext/nokogiri/html_sax_parser_context.c
150
+ - ext/nokogiri/xml_comment.c
150
151
  - ext/nokogiri/xml_namespace.c
152
+ - ext/nokogiri/xml_entity_decl.c
151
153
  - ext/nokogiri/xml_node.c
152
- - ext/nokogiri/xml_node_set.c
153
- - ext/nokogiri/xml_processing_instruction.c
154
+ - ext/nokogiri/html_document.c
155
+ - ext/nokogiri/xml_syntax_error.c
156
+ - ext/nokogiri/xml_document.c
157
+ - ext/nokogiri/xml_cdata.c
154
158
  - ext/nokogiri/xml_reader.c
155
- - ext/nokogiri/xml_relax_ng.c
156
- - ext/nokogiri/xml_sax_parser.c
157
- - ext/nokogiri/xml_sax_parser_context.c
158
- - ext/nokogiri/xml_sax_push_parser.c
159
+ - ext/nokogiri/xml_attr.c
160
+ - ext/nokogiri/xml_processing_instruction.c
159
161
  - ext/nokogiri/xml_schema.c
160
- - ext/nokogiri/xml_syntax_error.c
161
- - ext/nokogiri/xml_text.c
162
- - ext/nokogiri/xml_xpath_context.c
163
- - ext/nokogiri/xslt_stylesheet.c
162
+ - ext/nokogiri/xml_encoding_handler.c
163
+ - ext/nokogiri/xml_relax_ng.c
164
164
  files:
165
165
  - .autotest
166
166
  - CHANGELOG.ja.rdoc
@@ -223,6 +223,7 @@ files:
223
223
  - ext/java/nokogiri/internals/XmlDomParser.java
224
224
  - ext/java/nokogiri/internals/XmlDomParserContext.java
225
225
  - ext/java/nokogiri/internals/XmlSaxParser.java
226
+ - ext/java/nokogiri/internals/XsltExtensionFunction.java
226
227
  - ext/nokogiri/depend
227
228
  - ext/nokogiri/extconf.rb
228
229
  - ext/nokogiri/html_document.c
@@ -316,7 +317,6 @@ files:
316
317
  - lib/nokogiri/html/entity_lookup.rb
317
318
  - lib/nokogiri/html/sax/parser.rb
318
319
  - lib/nokogiri/html/sax/parser_context.rb
319
- - lib/nokogiri/nokogiri.jar
320
320
  - lib/nokogiri/syntax_error.rb
321
321
  - lib/nokogiri/version.rb
322
322
  - lib/nokogiri/xml.rb
@@ -358,14 +358,13 @@ files:
358
358
  - lib/nokogiri/xslt/stylesheet.rb
359
359
  - lib/xercesImpl.jar
360
360
  - lib/xsd/xmlparser/nokogiri.rb
361
- - spec/helper.rb
362
- - spec/xml/reader_spec.rb
363
361
  - tasks/cross_compile.rb
364
362
  - tasks/test.rb
365
363
  - test/css/test_nthiness.rb
366
364
  - test/css/test_parser.rb
367
365
  - test/css/test_tokenizer.rb
368
366
  - test/css/test_xpath_visitor.rb
367
+ - test/decorators/test_slop.rb
369
368
  - test/files/2ch.html
370
369
  - test/files/address_book.rlx
371
370
  - test/files/address_book.xml
@@ -437,6 +436,7 @@ files:
437
436
  - test/xml/test_text.rb
438
437
  - test/xml/test_unparented_node.rb
439
438
  - test/xml/test_xpath.rb
439
+ - test/xslt/test_custom_functions.rb
440
440
  has_rdoc: true
441
441
  homepage: http://nokogiri.org
442
442
  licenses: []
@@ -475,59 +475,61 @@ signing_key:
475
475
  specification_version: 3
476
476
  summary: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser"
477
477
  test_files:
478
- - test/css/test_nthiness.rb
479
- - test/css/test_parser.rb
480
- - test/css/test_tokenizer.rb
481
- - test/css/test_xpath_visitor.rb
482
- - test/html/sax/test_parser.rb
483
- - test/html/sax/test_parser_context.rb
484
- - test/html/test_builder.rb
485
- - test/html/test_document.rb
486
- - test/html/test_document_encoding.rb
487
- - test/html/test_document_fragment.rb
488
- - test/html/test_element_description.rb
489
- - test/html/test_named_characters.rb
490
- - test/html/test_node.rb
491
- - test/html/test_node_encoding.rb
492
- - test/test_convert_xpath.rb
478
+ - test/test_reader.rb
493
479
  - test/test_css_cache.rb
494
480
  - test/test_encoding_handler.rb
481
+ - test/decorators/test_slop.rb
495
482
  - test/test_memory_leak.rb
496
- - test/test_nokogiri.rb
497
- - test/test_reader.rb
498
- - test/test_soap4r_sax.rb
499
- - test/test_xslt_transforms.rb
500
- - test/xml/node/test_save_options.rb
501
- - test/xml/node/test_subclass.rb
502
- - test/xml/sax/test_parser.rb
503
- - test/xml/sax/test_parser_context.rb
504
- - test/xml/sax/test_push_parser.rb
505
- - test/xml/test_attr.rb
506
- - test/xml/test_attribute_decl.rb
507
- - test/xml/test_builder.rb
483
+ - test/xml/test_document_encoding.rb
484
+ - test/xml/test_relax_ng.rb
485
+ - test/xml/test_text.rb
486
+ - test/xml/test_node_reparenting.rb
487
+ - test/xml/test_syntax_error.rb
488
+ - test/xml/test_unparented_node.rb
489
+ - test/xml/test_node_encoding.rb
490
+ - test/xml/test_reader_encoding.rb
491
+ - test/xml/test_processing_instruction.rb
508
492
  - test/xml/test_cdata.rb
509
- - test/xml/test_comment.rb
493
+ - test/xml/test_node.rb
494
+ - test/xml/test_builder.rb
495
+ - test/xml/test_namespace.rb
510
496
  - test/xml/test_document.rb
511
- - test/xml/test_document_encoding.rb
497
+ - test/xml/test_element_content.rb
512
498
  - test/xml/test_document_fragment.rb
499
+ - test/xml/test_entity_reference.rb
500
+ - test/xml/test_attr.rb
513
501
  - test/xml/test_dtd.rb
514
- - test/xml/test_dtd_encoding.rb
515
- - test/xml/test_element_content.rb
502
+ - test/xml/sax/test_parser.rb
503
+ - test/xml/sax/test_parser_context.rb
504
+ - test/xml/sax/test_push_parser.rb
516
505
  - test/xml/test_element_decl.rb
517
- - test/xml/test_entity_decl.rb
518
- - test/xml/test_entity_reference.rb
519
- - test/xml/test_namespace.rb
520
- - test/xml/test_node.rb
521
506
  - test/xml/test_node_attributes.rb
522
- - test/xml/test_node_encoding.rb
523
- - test/xml/test_node_reparenting.rb
507
+ - test/xml/test_xpath.rb
524
508
  - test/xml/test_node_set.rb
525
509
  - test/xml/test_parse_options.rb
526
- - test/xml/test_processing_instruction.rb
527
- - test/xml/test_reader_encoding.rb
528
- - test/xml/test_relax_ng.rb
510
+ - test/xml/test_entity_decl.rb
511
+ - test/xml/node/test_save_options.rb
512
+ - test/xml/node/test_subclass.rb
513
+ - test/xml/test_attribute_decl.rb
529
514
  - test/xml/test_schema.rb
530
- - test/xml/test_syntax_error.rb
531
- - test/xml/test_text.rb
532
- - test/xml/test_unparented_node.rb
533
- - test/xml/test_xpath.rb
515
+ - test/xml/test_dtd_encoding.rb
516
+ - test/xml/test_comment.rb
517
+ - test/test_nokogiri.rb
518
+ - test/html/test_document_encoding.rb
519
+ - test/html/test_node_encoding.rb
520
+ - test/html/test_node.rb
521
+ - test/html/test_builder.rb
522
+ - test/html/test_document.rb
523
+ - test/html/test_document_fragment.rb
524
+ - test/html/sax/test_parser.rb
525
+ - test/html/sax/test_parser_context.rb
526
+ - test/html/test_named_characters.rb
527
+ - test/html/test_element_description.rb
528
+ - test/test_convert_xpath.rb
529
+ - test/test_soap4r_sax.rb
530
+ - test/css/test_nthiness.rb
531
+ - test/css/test_parser.rb
532
+ - test/css/test_tokenizer.rb
533
+ - test/css/test_xpath_visitor.rb
534
+ - test/xslt/test_custom_functions.rb
535
+ - test/test_xslt_transforms.rb
Binary file
@@ -1,3 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
2
-
3
- require 'nokogiri'
@@ -1,307 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'helper')
2
-
3
- include Nokogiri::XML
4
-
5
- describe Nokogiri::XML::Reader do
6
-
7
- it "should return the correct local_names" do
8
- xml = <<-oexml
9
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
10
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
11
- </x>
12
- oexml
13
- r = Nokogiri::XML::Reader.from_memory(xml)
14
- r.should_not be_nil
15
- r.local_name.should be_nil
16
- r.map{|x| x.local_name}.should == ["x","#text","foo","#text","foo","#text","x"]
17
- end
18
-
19
- it "should return the correct names" do
20
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
21
- <x xmlns:edi='http://ecommerce.example.org/schema'>
22
- <edi:foo>hello</edi:foo>
23
- </x>
24
- eoxml
25
- reader.should_not be_nil
26
- reader.name.should be_nil
27
- reader.map{|x| x.name}.should == ["x", "#text", "edi:foo", "#text", "edi:foo", "#text", "x"]
28
- end
29
-
30
- it "should set io as source when called from_io method" do
31
- io = StringIO.new(<<-eoxml)
32
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
33
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
34
- </x>
35
- eoxml
36
- reader = Nokogiri::XML::Reader.from_io(io)
37
- reader.source.should be_equal(io)
38
- end
39
-
40
- it "should raise ArgumentError if nil is passed" do
41
- lambda{
42
- Nokogiri::XML::Reader.from_memory(nil)
43
- }.should raise_error(ArgumentError)
44
- lambda{
45
- Nokogiri::XML::Reader.from_io(nil)
46
- }.should raise_error(ArgumentError)
47
- end
48
-
49
- it "should parse from_io" do
50
- io = StringIO.new(<<-eoxml)
51
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
52
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
53
- </x>
54
- eoxml
55
- reader = Nokogiri::XML::Reader.from_io(io)
56
- reader.should_not be_default
57
- reader.map{ |x| x.default? }.should == [false, false, false, false, false, false, false]
58
- end
59
-
60
- it "should parse when passed an io object" do
61
- io = StringIO.new(<<-eoxml)
62
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
63
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
64
- </x>
65
- eoxml
66
- reader = Nokogiri::XML::Reader(io)
67
- reader.should_not be_default
68
- reader.map{ |x| x.default? }.should == [false, false, false, false, false, false, false]
69
- end
70
-
71
- it "should set string as source when called from_memory" do
72
- xml = <<-eoxml
73
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
74
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
75
- </x>
76
- eoxml
77
- reader = Nokogiri::XML::Reader(xml)
78
- reader.source.should be_equal(xml)
79
- end
80
-
81
- it "should return false for default" do # Sorry for the description. Couldn't avoid to.
82
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
83
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
84
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
85
- </x>
86
- eoxml
87
- reader.should_not be_default
88
- reader.map { |x| x.default? }.should == [false, false, false, false, false, false, false]
89
- end
90
-
91
- it "should return the correct boolean value when asked for value?" do
92
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
93
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
94
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
95
- </x>
96
- eoxml
97
-
98
- reader.value?.should == false # Look for how should I do this in RSpec.
99
- reader.map {|x| x.value? }.should == [false, true, false, true, false, true, false]
100
- end
101
-
102
- it "should be able to deal with errors" do
103
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
104
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
105
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
106
- <foo>
107
- </x>
108
- eoxml
109
-
110
- reader.errors.should have(0).items
111
-
112
- lambda {
113
- reader.each { |node| }
114
- }.should raise_error(Nokogiri::XML::SyntaxError)
115
-
116
- reader.errors.should have(1).item
117
- end
118
-
119
- it "should retrieve the right arguments" do
120
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
121
- <x xmlns:tenderlove='http://tenderlovemaking.com/'
122
- xmlns='http://mothership.connection.com/'
123
- >
124
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
125
- </x>
126
- eoxml
127
- reader.attributes.should be_empty
128
- reader.map { |x| x.attributes }.should == [{'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
129
- 'xmlns'=>'http://mothership.connection.com/'},
130
- {}, {"awesome"=>"true"}, {}, {"awesome"=>"true"}, {},
131
- {'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
132
- 'xmlns'=>'http://mothership.connection.com/'}]
133
- end
134
-
135
- it "should be able to acces the same attribute through both attribute and attributes method" do
136
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
137
- <x xmlns:tenderlove='http://tenderlovemaking.com/'
138
- xmlns='http://mothership.connection.com/'
139
- >
140
- <tenderlove:foo awesome='true' size='giant'>snuggles!</tenderlove:foo>
141
- </x>
142
- eoxml
143
-
144
- reader.attribute(nil).should be_nil
145
-
146
- reader.each do |node|
147
- node.attributes.each do |key, value|
148
- node.attribute(key).should == value
149
- end
150
- end
151
- end
152
-
153
- it "should be able to retrieve an attribute given an index" do
154
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
155
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
156
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
157
- </x>
158
- eoxml
159
-
160
- reader.attribute_at(nil).should be_nil
161
- reader.attribute_at(0).should be_nil
162
-
163
- reader.map {|x| x.attribute_at(0) }.should == ['http://tenderlovemaking.com/', nil, 'true', nil, 'true', nil, 'http://tenderlovemaking.com/']
164
- end
165
-
166
- it "should be able to access an attribute value by its name" do # I should get this test for free
167
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
168
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
169
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
170
- </x>
171
- eoxml
172
-
173
- reader.attribute(nil).should be_nil
174
- reader.attribute('awesome').should be_nil
175
-
176
- reader.map {|x| x.attribute('awesome') }.should ==[nil, nil, 'true', nil, 'true', nil, nil]
177
- end
178
-
179
- it "should retrieve the correct number of attributes" do
180
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
181
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
182
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
183
- </x>
184
- eoxml
185
-
186
- reader.attribute_count.should == 0
187
- reader.map {|x| x.attribute_count}.should == [1, 0, 1, 0, 0, 0, 0]
188
- end
189
-
190
- it "should return the depth of the current node" do
191
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
192
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
193
- <tenderlove:foo>snuggles!</tenderlove:foo>
194
- </x>
195
- eoxml
196
-
197
- reader.depth.should == 0
198
-
199
- reader.map {|x| x.depth}.should == [0,1,1,2,1,1,0]
200
- end
201
-
202
- it "should return the right encoding" do
203
- string = <<-eoxml
204
- <awesome>
205
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
206
- <p xml:lang="ja">日本語が上手です</p>
207
- </awesome>
208
- eoxml
209
- reader = Nokogiri::XML::Reader.from_memory(string, nil, 'UTF-8')
210
- reader.map { |x| x.encoding }.uniq.should == ['UTF-8']
211
- end
212
-
213
- it "should return the right xml version" do
214
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
215
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
216
- <tenderlove:foo>snuggles!</tenderlove:foo>
217
- </x>
218
- eoxml
219
-
220
- reader.xml_version.should be_nil
221
-
222
- reader.map { |x| x.xml_version }.uniq.should == ['1.0']
223
- end
224
-
225
- it "should retrieve the correct lang" do
226
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
227
- <awesome>
228
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
229
- <p xml:lang="ja">日本語が上手です</p>
230
- </awesome>
231
- eoxml
232
-
233
- reader.lang.should be_nil
234
-
235
- reader.map {|x| x.lang}.should == [nil, nil, "en", "en", "en", nil, "ja", "ja", "ja", nil, nil]
236
- end
237
-
238
- it "should retrieve the correct value" do
239
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
240
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
241
- <tenderlove:foo>snuggles!</tenderlove:foo>
242
- </x>
243
- eoxml
244
-
245
- reader.value.should be_nil
246
-
247
- reader.map {|x| x.value }.should == [nil, "\n ", nil, "snuggles!", nil, "\n ", nil]
248
- end
249
-
250
- it "should return the node's prefix" do
251
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
252
- <x xmlns:edi='http://ecommerce.example.org/schema'>
253
- <edi:foo>hello</edi:foo>
254
- </x>
255
- eoxml
256
-
257
- reader.prefix.should be_nil
258
-
259
- reader.map { |n| n.prefix }.should == [nil, nil, "edi", nil, "edi", nil, nil]
260
- end
261
-
262
- it "should return the reader state, whatever it is" do
263
- reader = Nokogiri::XML::Reader.from_memory('<foo>bar</bar>')
264
- reader.state.should_not be_nil
265
- end
266
-
267
- it "should return the namespace's uri" do
268
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
269
- <x xmlns:edi='http://ecommerce.example.org/schema'>
270
- <edi:foo>hello</edi:foo>
271
- </x>
272
- eoxml
273
- reader.namespace_uri.should be_nil
274
-
275
- reader.map { |n| n.namespace_uri }.should == [nil,
276
- nil,
277
- "http://ecommerce.example.org/schema",
278
- nil,
279
- "http://ecommerce.example.org/schema",
280
- nil,
281
- nil]
282
- end
283
-
284
- it "should return the node's local_name" do
285
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
286
- <x xmlns:edi='http://ecommerce.example.org/schema'>
287
- <edi:foo>hello</edi:foo>
288
- </x>
289
- eoxml
290
-
291
- reader.local_name.should be_nil
292
-
293
- reader.map {|n| n.local_name }.should == ["x", "#text", "foo", "#text", "foo", "#text", "x"]
294
- end
295
-
296
- it "should return node's name" do
297
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
298
- <x xmlns:edi='http://ecommerce.example.org/schema'>
299
- <edi:foo>hello</edi:foo>
300
- </x>
301
- eoxml
302
-
303
- reader.name.should be_nil
304
-
305
- reader.map { |n| n.name }.should ==["x", "#text", "edi:foo", "#text", "edi:foo", "#text", "x"]
306
- end
307
- end