libxml-ruby 2.0.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +516 -0
- data/LICENSE +23 -0
- data/MANIFEST +165 -0
- data/README.rdoc +161 -0
- data/Rakefile +82 -0
- data/ext/libxml/extconf.rb +122 -0
- data/ext/libxml/libxml.c +93 -0
- data/ext/libxml/ruby_libxml.h +101 -0
- data/ext/libxml/ruby_xml.c +893 -0
- data/ext/libxml/ruby_xml.h +10 -0
- data/ext/libxml/ruby_xml_attr.c +352 -0
- data/ext/libxml/ruby_xml_attr.h +14 -0
- data/ext/libxml/ruby_xml_attr_decl.c +171 -0
- data/ext/libxml/ruby_xml_attr_decl.h +13 -0
- data/ext/libxml/ruby_xml_attributes.c +277 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_cbg.c +85 -0
- data/ext/libxml/ruby_xml_document.c +958 -0
- data/ext/libxml/ruby_xml_document.h +17 -0
- data/ext/libxml/ruby_xml_dtd.c +257 -0
- data/ext/libxml/ruby_xml_dtd.h +9 -0
- data/ext/libxml/ruby_xml_encoding.c +221 -0
- data/ext/libxml/ruby_xml_encoding.h +16 -0
- data/ext/libxml/ruby_xml_error.c +1004 -0
- data/ext/libxml/ruby_xml_error.h +14 -0
- data/ext/libxml/ruby_xml_html_parser.c +92 -0
- data/ext/libxml/ruby_xml_html_parser.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_input_cbg.c +191 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_io.c +30 -0
- data/ext/libxml/ruby_xml_io.h +9 -0
- data/ext/libxml/ruby_xml_namespace.c +170 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespaces.c +295 -0
- data/ext/libxml/ruby_xml_namespaces.h +11 -0
- data/ext/libxml/ruby_xml_node.c +1386 -0
- data/ext/libxml/ruby_xml_node.h +13 -0
- data/ext/libxml/ruby_xml_parser.c +94 -0
- data/ext/libxml/ruby_xml_parser.h +14 -0
- data/ext/libxml/ruby_xml_parser_context.c +982 -0
- data/ext/libxml/ruby_xml_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_parser_options.c +68 -0
- data/ext/libxml/ruby_xml_parser_options.h +14 -0
- data/ext/libxml/ruby_xml_reader.c +1057 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_relaxng.c +111 -0
- data/ext/libxml/ruby_xml_relaxng.h +10 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +334 -0
- data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
- data/ext/libxml/ruby_xml_sax_parser.c +136 -0
- data/ext/libxml/ruby_xml_sax_parser.h +12 -0
- data/ext/libxml/ruby_xml_schema.c +159 -0
- data/ext/libxml/ruby_xml_schema.h +11 -0
- data/ext/libxml/ruby_xml_version.h +9 -0
- data/ext/libxml/ruby_xml_xinclude.c +18 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +107 -0
- data/ext/libxml/ruby_xml_xpath.h +12 -0
- data/ext/libxml/ruby_xml_xpath_context.c +390 -0
- data/ext/libxml/ruby_xml_xpath_context.h +11 -0
- data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
- data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
- data/ext/libxml/ruby_xml_xpath_object.c +336 -0
- data/ext/libxml/ruby_xml_xpath_object.h +19 -0
- data/ext/libxml/ruby_xml_xpointer.c +101 -0
- data/ext/libxml/ruby_xml_xpointer.h +13 -0
- data/ext/mingw/Rakefile +34 -0
- data/ext/mingw/build.rake +41 -0
- data/ext/vc/libxml_ruby.sln +26 -0
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/lib/libxml.rb +30 -0
- data/lib/libxml/attr.rb +113 -0
- data/lib/libxml/attr_decl.rb +80 -0
- data/lib/libxml/attributes.rb +14 -0
- data/lib/libxml/document.rb +192 -0
- data/lib/libxml/error.rb +90 -0
- data/lib/libxml/hpricot.rb +78 -0
- data/lib/libxml/html_parser.rb +96 -0
- data/lib/libxml/namespace.rb +62 -0
- data/lib/libxml/namespaces.rb +38 -0
- data/lib/libxml/node.rb +399 -0
- data/lib/libxml/ns.rb +22 -0
- data/lib/libxml/parser.rb +367 -0
- data/lib/libxml/properties.rb +23 -0
- data/lib/libxml/reader.rb +29 -0
- data/lib/libxml/sax_callbacks.rb +180 -0
- data/lib/libxml/sax_parser.rb +58 -0
- data/lib/libxml/tree.rb +29 -0
- data/lib/libxml/xpath_object.rb +16 -0
- data/lib/xml.rb +16 -0
- data/lib/xml/libxml.rb +10 -0
- data/libxml-ruby.gemspec +50 -0
- data/script/benchmark/depixelate +634 -0
- data/script/benchmark/hamlet.xml +9055 -0
- data/script/benchmark/parsecount +170 -0
- data/script/benchmark/sock_entries.xml +507 -0
- data/script/benchmark/throughput +41 -0
- data/script/test +6 -0
- data/setup.rb +1585 -0
- data/test/etc_doc_to_s.rb +21 -0
- data/test/ets_doc_file.rb +17 -0
- data/test/ets_doc_to_s.rb +23 -0
- data/test/ets_gpx.rb +28 -0
- data/test/ets_node_gc.rb +23 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +11 -0
- data/test/model/atom.xml +13 -0
- data/test/model/bands.iso-8859-1.xml +5 -0
- data/test/model/bands.utf-8.xml +5 -0
- data/test/model/bands.xml +5 -0
- data/test/model/books.xml +146 -0
- data/test/model/merge_bug_data.xml +58 -0
- data/test/model/ruby-lang.html +238 -0
- data/test/model/rubynet.xml +79 -0
- data/test/model/rubynet_project +1 -0
- data/test/model/shiporder.rnc +28 -0
- data/test/model/shiporder.rng +86 -0
- data/test/model/shiporder.xml +23 -0
- data/test/model/shiporder.xsd +31 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/rb-magic-comment.rb +33 -0
- data/test/tc_attr.rb +181 -0
- data/test/tc_attr_decl.rb +133 -0
- data/test/tc_attributes.rb +135 -0
- data/test/tc_deprecated_require.rb +13 -0
- data/test/tc_document.rb +119 -0
- data/test/tc_document_write.rb +187 -0
- data/test/tc_dtd.rb +125 -0
- data/test/tc_error.rb +138 -0
- data/test/tc_html_parser.rb +140 -0
- data/test/tc_namespace.rb +62 -0
- data/test/tc_namespaces.rb +177 -0
- data/test/tc_node.rb +258 -0
- data/test/tc_node_cdata.rb +51 -0
- data/test/tc_node_comment.rb +33 -0
- data/test/tc_node_copy.rb +42 -0
- data/test/tc_node_edit.rb +160 -0
- data/test/tc_node_text.rb +71 -0
- data/test/tc_node_write.rb +108 -0
- data/test/tc_node_xlink.rb +29 -0
- data/test/tc_parser.rb +336 -0
- data/test/tc_parser_context.rb +189 -0
- data/test/tc_properties.rb +39 -0
- data/test/tc_reader.rb +298 -0
- data/test/tc_relaxng.rb +54 -0
- data/test/tc_sax_parser.rb +276 -0
- data/test/tc_schema.rb +53 -0
- data/test/tc_traversal.rb +222 -0
- data/test/tc_xinclude.rb +21 -0
- data/test/tc_xml.rb +226 -0
- data/test/tc_xpath.rb +195 -0
- data/test/tc_xpath_context.rb +80 -0
- data/test/tc_xpath_expression.rb +38 -0
- data/test/tc_xpointer.rb +74 -0
- data/test/test_helper.rb +14 -0
- data/test/test_suite.rb +39 -0
- metadata +254 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<rubynet xmlns:xlink="http://www.w3.org/1999/xlink">
|
3
|
+
<pkg version="1.0">
|
4
|
+
<meta>
|
5
|
+
<pkgname>REXML</pkgname>
|
6
|
+
<authors>
|
7
|
+
<author>
|
8
|
+
<name>Aaron Malone</name>
|
9
|
+
<email>aaron@munge.net</email>
|
10
|
+
<irc_network>irc.opentprojects.org</irc_network>
|
11
|
+
<irc_channel>#ruby-lang</irc_channel>
|
12
|
+
<irc_handle>AAmalone</irc_handle>
|
13
|
+
</author>
|
14
|
+
</authors>
|
15
|
+
<maintainers>
|
16
|
+
<maintainer>
|
17
|
+
<name>Tools Team</name>
|
18
|
+
<email>tools@gentoo.org</email>
|
19
|
+
<irc_network>irc.opentprojects.org</irc_network>
|
20
|
+
<irc_channel>#ruby-lang</irc_channel>
|
21
|
+
<irc_handle>TinyT</irc_handle>
|
22
|
+
</maintainer>
|
23
|
+
</maintainers>
|
24
|
+
<categories>
|
25
|
+
|
26
|
+
<!-- For pieces of data that are repeated constnatly, could we
|
27
|
+
use XLink to centralize some of these definitions? If we move
|
28
|
+
stuff around on rubynet.org, we don't want to have to do a
|
29
|
+
search/replace: just update the entity, IMHO. -->
|
30
|
+
|
31
|
+
<major_category xlink:type="simple" xlink:href="http://www.rubynet.org/category/xml/">XML</major_category>
|
32
|
+
<minor_category xlink:type="simple" xlink:href="http://www.rubynet.org/category/text%20processing/">Text Processing</minor_category>
|
33
|
+
<minor_category xlink:type="simple" xlink:href="http://www.rubynet.org/category/storage/">Storage</minor_category>
|
34
|
+
</categories>
|
35
|
+
<version>
|
36
|
+
<major_version>1</major_version>
|
37
|
+
<minor_version>2</minor_version>
|
38
|
+
<micro_version>3</micro_version>
|
39
|
+
</version>
|
40
|
+
<copyright>1999-2002 Gentoo Technologies,Inc.</copyright>
|
41
|
+
<license>Ruby</license>
|
42
|
+
<status>Stable</status>
|
43
|
+
<full_name>Ruby Electric XML</full_name>
|
44
|
+
<description>Pure Ruby parser, blah blah. Based of Electrice XML</description>
|
45
|
+
<homepage xlink:type="simple" xlink:href="http://www.germane-software.com/~ser/Software/rexml/">REXML Home</homepage>
|
46
|
+
<download xlink:type="simple" xlink:href="http://www.germane-software.com/~ser/Software/rexml/rexml-1.2.3.bz2/">REXML Download</download>
|
47
|
+
</meta>
|
48
|
+
<dependencies>
|
49
|
+
<dependency name="ruby" uri="http://www.rubynet.org/packages/ruby/">
|
50
|
+
<required_version restriction="no-lower-than">
|
51
|
+
<version>
|
52
|
+
<major_version>1</major_version>
|
53
|
+
<minor_version>6</minor_version>
|
54
|
+
<micro_version>0</micro_version>
|
55
|
+
</version>
|
56
|
+
</required_version>
|
57
|
+
</dependency>
|
58
|
+
</dependencies>
|
59
|
+
<files>
|
60
|
+
<file>
|
61
|
+
<filename>uga.rb</filename>
|
62
|
+
<mode>0444</mode>
|
63
|
+
<content encoding="xml">... the file here</content>
|
64
|
+
</file>
|
65
|
+
<file>
|
66
|
+
<filename>booga.h</filename>
|
67
|
+
<mode>0444</mode>
|
68
|
+
<content encoding="xml">... the file here</content>
|
69
|
+
</file>
|
70
|
+
<file>
|
71
|
+
<filename>foo.so</filename>
|
72
|
+
<mode>0555</mode>
|
73
|
+
<!-- Encode routine: str.to_a.pack('m')
|
74
|
+
Decode routine: str.unpack('m') -->
|
75
|
+
<content encoding="mime64">Li4uIHRoZSBmaWxlIGhlcmU=\n</content>
|
76
|
+
</file>
|
77
|
+
</files>
|
78
|
+
</pkg>
|
79
|
+
</rubynet>
|
@@ -0,0 +1 @@
|
|
1
|
+
This is some text to include in an xml file via XInclude.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# relax ng schema in compact syntax; this cannot be used within libxml but
|
3
|
+
# was used to write the schema as compact syntax makes it easier to handle.
|
4
|
+
# relax ng schema in xml syntax was created using trang.
|
5
|
+
#
|
6
|
+
namespace xsi = "http://www.w3.org/2001/XMLSchema-instance"
|
7
|
+
|
8
|
+
start = shiporder
|
9
|
+
|
10
|
+
shiporder = element shiporder { attribute orderid { text },
|
11
|
+
attribute xsi:noNamespaceSchemaLocation { text },
|
12
|
+
orderperson, shipto, item* }
|
13
|
+
|
14
|
+
orderperson = element orderperson { text }
|
15
|
+
|
16
|
+
shipto = element shipto { name, address, city, country }
|
17
|
+
|
18
|
+
name = element name { text }
|
19
|
+
address = element address { text }
|
20
|
+
city = element city { text }
|
21
|
+
country = element country { text }
|
22
|
+
|
23
|
+
item = element item { title, note?, quantity, price }
|
24
|
+
|
25
|
+
title = element title { text }
|
26
|
+
note = element note { text }
|
27
|
+
quantity = element quantity { text }
|
28
|
+
price = element price { text }
|
@@ -0,0 +1,86 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
relax ng schema in compact syntax; this cannot be used within libxml but
|
5
|
+
was used to write the schema as it's easier to understand
|
6
|
+
|
7
|
+
-->
|
8
|
+
<grammar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://relaxng.org/ns/structure/1.0">
|
9
|
+
<start>
|
10
|
+
<ref name="shiporder"/>
|
11
|
+
</start>
|
12
|
+
<define name="shiporder">
|
13
|
+
<element name="shiporder">
|
14
|
+
<attribute name="orderid"/>
|
15
|
+
<attribute name="xsi:noNamespaceSchemaLocation"/>
|
16
|
+
<ref name="orderperson"/>
|
17
|
+
<ref name="shipto"/>
|
18
|
+
<zeroOrMore>
|
19
|
+
<ref name="item"/>
|
20
|
+
</zeroOrMore>
|
21
|
+
</element>
|
22
|
+
</define>
|
23
|
+
<define name="orderperson">
|
24
|
+
<element name="orderperson">
|
25
|
+
<text/>
|
26
|
+
</element>
|
27
|
+
</define>
|
28
|
+
<define name="shipto">
|
29
|
+
<element name="shipto">
|
30
|
+
<ref name="name"/>
|
31
|
+
<ref name="address"/>
|
32
|
+
<ref name="city"/>
|
33
|
+
<ref name="country"/>
|
34
|
+
</element>
|
35
|
+
</define>
|
36
|
+
<define name="name">
|
37
|
+
<element name="name">
|
38
|
+
<text/>
|
39
|
+
</element>
|
40
|
+
</define>
|
41
|
+
<define name="address">
|
42
|
+
<element name="address">
|
43
|
+
<text/>
|
44
|
+
</element>
|
45
|
+
</define>
|
46
|
+
<define name="city">
|
47
|
+
<element name="city">
|
48
|
+
<text/>
|
49
|
+
</element>
|
50
|
+
</define>
|
51
|
+
<define name="country">
|
52
|
+
<element name="country">
|
53
|
+
<text/>
|
54
|
+
</element>
|
55
|
+
</define>
|
56
|
+
<define name="item">
|
57
|
+
<element name="item">
|
58
|
+
<ref name="title"/>
|
59
|
+
<optional>
|
60
|
+
<ref name="note"/>
|
61
|
+
</optional>
|
62
|
+
<ref name="quantity"/>
|
63
|
+
<ref name="price"/>
|
64
|
+
</element>
|
65
|
+
</define>
|
66
|
+
<define name="title">
|
67
|
+
<element name="title">
|
68
|
+
<text/>
|
69
|
+
</element>
|
70
|
+
</define>
|
71
|
+
<define name="note">
|
72
|
+
<element name="note">
|
73
|
+
<text/>
|
74
|
+
</element>
|
75
|
+
</define>
|
76
|
+
<define name="quantity">
|
77
|
+
<element name="quantity">
|
78
|
+
<text/>
|
79
|
+
</element>
|
80
|
+
</define>
|
81
|
+
<define name="price">
|
82
|
+
<element name="price">
|
83
|
+
<text/>
|
84
|
+
</element>
|
85
|
+
</define>
|
86
|
+
</grammar>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<shiporder orderid="889923"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:noNamespaceSchemaLocation="shiporder.xsd">
|
5
|
+
<orderperson>John Smith</orderperson>
|
6
|
+
<shipto>
|
7
|
+
<name>Ola Nordmann</name>
|
8
|
+
<address>Langgt 23</address>
|
9
|
+
<city>4000 Stavanger</city>
|
10
|
+
<country>Norway</country>
|
11
|
+
</shipto>
|
12
|
+
<item>
|
13
|
+
<title>Empire Burlesque</title>
|
14
|
+
<note>Special Edition</note>
|
15
|
+
<quantity>1</quantity>
|
16
|
+
<price>10.90</price>
|
17
|
+
</item>
|
18
|
+
<item>
|
19
|
+
<title>Hide your heart</title>
|
20
|
+
<quantity>1</quantity>
|
21
|
+
<price>9.90</price>
|
22
|
+
</item>
|
23
|
+
</shiporder>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1" ?>
|
2
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
3
|
+
<xs:element name="shiporder">
|
4
|
+
<xs:complexType>
|
5
|
+
<xs:sequence>
|
6
|
+
<xs:element name="orderperson" type="xs:string"/>
|
7
|
+
<xs:element name="shipto">
|
8
|
+
<xs:complexType>
|
9
|
+
<xs:sequence>
|
10
|
+
<xs:element name="name" type="xs:string"/>
|
11
|
+
<xs:element name="address" type="xs:string"/>
|
12
|
+
<xs:element name="city" type="xs:string"/>
|
13
|
+
<xs:element name="country" type="xs:string"/>
|
14
|
+
</xs:sequence>
|
15
|
+
</xs:complexType>
|
16
|
+
</xs:element>
|
17
|
+
<xs:element name="item" maxOccurs="unbounded">
|
18
|
+
<xs:complexType>
|
19
|
+
<xs:sequence>
|
20
|
+
<xs:element name="title" type="xs:string"/>
|
21
|
+
<xs:element name="note" type="xs:string" minOccurs="0"/>
|
22
|
+
<xs:element name="quantity" type="xs:positiveInteger"/>
|
23
|
+
<xs:element name="price" type="xs:decimal"/>
|
24
|
+
</xs:sequence>
|
25
|
+
</xs:complexType>
|
26
|
+
</xs:element>
|
27
|
+
</xs:sequence>
|
28
|
+
<xs:attribute name="orderid" type="xs:string" use="required"/>
|
29
|
+
</xs:complexType>
|
30
|
+
</xs:element>
|
31
|
+
</xs:schema>
|
data/test/model/soap.xml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<soap:Envelope
|
3
|
+
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
4
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
5
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
6
|
+
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
|
7
|
+
<soap:Body>
|
8
|
+
<getManufacturerNamesResponse name="widgestRus" xmlns="http://services.somewhere.com">
|
9
|
+
<IDAndNameList xmlns="http://services.somewhere.com">
|
10
|
+
<ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
|
11
|
+
<id xmlns="http://domain.somewhere.com">1</id>
|
12
|
+
<name xmlns="http://domain.somewhere.com">man1</name>
|
13
|
+
|
14
|
+
</ns1:IdAndName>
|
15
|
+
<ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
|
16
|
+
<id xmlns="http://domain.somewhere.com">2</id>
|
17
|
+
<name xmlns="http://domain.somewhere.com">man2</name>
|
18
|
+
|
19
|
+
</ns1:IdAndName>
|
20
|
+
<ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
|
21
|
+
<id xmlns="http://domain.somewhere.com">3</id>
|
22
|
+
<name xmlns="http://domain.somewhere.com">man3</name>
|
23
|
+
</ns1:IdAndName>
|
24
|
+
</IDAndNameList>
|
25
|
+
</getManufacturerNamesResponse>
|
26
|
+
</soap:Body>
|
27
|
+
</soap:Envelope>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/local/ruby/bin/ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
ARGV.reject! { |path| !File.file?(path) }
|
5
|
+
(puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty?
|
6
|
+
|
7
|
+
ARGV.each do |path|
|
8
|
+
ls = IO.readlines(path)
|
9
|
+
ix = ls[0] !~ /^#!/ ? 0 : 1
|
10
|
+
next if ls[ix] =~ /#.*?coding\s*[:=]\s*\S/
|
11
|
+
ls.insert ix, "# encoding: UTF-8\n", ("\n" unless ls[ix] =~ /^#?\s*\n/)
|
12
|
+
open(path, 'w') { |f| f.write ls.join }
|
13
|
+
end
|
14
|
+
|
15
|
+
__END__
|
16
|
+
Add the unicode magic comment to ruby files.
|
17
|
+
|
18
|
+
* Files are modified in-place.
|
19
|
+
* If a file already contains a magic comment, it's skipped.
|
20
|
+
* Comment is added below the shebang if it exists, otherwise as the first line.
|
21
|
+
|
22
|
+
Usage:
|
23
|
+
$0 file-1 [file-2 ... file-n]
|
24
|
+
|
25
|
+
Examples:
|
26
|
+
# Add comment to standalone ruby files:
|
27
|
+
$0 foo.rb bar.rb
|
28
|
+
|
29
|
+
# Add comment to an entire ruby library or app:
|
30
|
+
find . -name '*.rb' -type f -print0 | xargs -0 $0
|
31
|
+
|
32
|
+
# Add comment to app files in a rails application:
|
33
|
+
find app config lib -name '*.rb' -type f -print0 | xargs -0 $0
|
data/test/tc_attr.rb
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class AttrNodeTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
xp = XML::Parser.string(<<-EOS)
|
9
|
+
<CityModel
|
10
|
+
xmlns="http://www.opengis.net/examples"
|
11
|
+
xmlns:city="http://www.opengis.net/examples"
|
12
|
+
xmlns:gml="http://www.opengis.net/gml"
|
13
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
14
|
+
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
|
15
|
+
xsi:schemaLocation="http://www.opengis.net/examples city.xsd">
|
16
|
+
<type>City</type>
|
17
|
+
<cityMember name="Cambridge"
|
18
|
+
xlink:type="simple"
|
19
|
+
xlink:title="Trinity Lane"
|
20
|
+
xlink:href="http://www.foo.net/cgi-bin/wfs?FeatureID=C10239"
|
21
|
+
gml:remoteSchema="city.xsd#xpointer(//complexType[@name='RoadType'])"/>
|
22
|
+
</CityModel>
|
23
|
+
EOS
|
24
|
+
|
25
|
+
@doc = xp.parse
|
26
|
+
end
|
27
|
+
|
28
|
+
def teardown
|
29
|
+
@doc = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def city_member
|
33
|
+
@doc.find('/city:CityModel/city:cityMember').first
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_doc
|
37
|
+
assert_not_nil(@doc)
|
38
|
+
assert_equal(XML::Encoding::NONE, @doc.encoding)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_types
|
42
|
+
attribute = city_member.attributes.get_attribute('name')
|
43
|
+
assert_instance_of(XML::Attr, attribute)
|
44
|
+
assert_equal('attribute', attribute.node_type_name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_name
|
48
|
+
attribute = city_member.attributes.get_attribute('name')
|
49
|
+
assert_equal('name', attribute.name)
|
50
|
+
assert_equal(Encoding::ASCII_8BIT, attribute.name.encoding) if defined?(Encoding)
|
51
|
+
|
52
|
+
attribute = city_member.attributes.get_attribute('href')
|
53
|
+
assert_equal('href', attribute.name)
|
54
|
+
assert_equal('xlink', attribute.ns.prefix)
|
55
|
+
assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
|
56
|
+
|
57
|
+
attribute = city_member.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
|
58
|
+
assert_equal('href', attribute.name)
|
59
|
+
assert_equal('xlink', attribute.ns.prefix)
|
60
|
+
assert_equal('http://www.w3.org/1999/xlink', attribute.ns.href)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_value
|
64
|
+
attribute = city_member.attributes.get_attribute('name')
|
65
|
+
assert_equal('Cambridge', attribute.value)
|
66
|
+
assert_equal(Encoding::ASCII_8BIT, attribute.value.encoding) if defined?(Encoding)
|
67
|
+
|
68
|
+
attribute = city_member.attributes.get_attribute('href')
|
69
|
+
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_set_value
|
73
|
+
attribute = city_member.attributes.get_attribute('name')
|
74
|
+
attribute.value = 'London'
|
75
|
+
assert_equal('London', attribute.value)
|
76
|
+
assert_equal(Encoding::ASCII_8BIT, attribute.value.encoding) if defined?(Encoding)
|
77
|
+
|
78
|
+
attribute = city_member.attributes.get_attribute('href')
|
79
|
+
attribute.value = 'http://i.have.changed'
|
80
|
+
assert_equal('http://i.have.changed', attribute.value)
|
81
|
+
assert_equal(Encoding::ASCII_8BIT, attribute.value.encoding) if defined?(Encoding)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_set_nil
|
85
|
+
attribute = city_member.attributes.get_attribute('name')
|
86
|
+
assert_raise(TypeError) do
|
87
|
+
attribute.value = nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_create
|
92
|
+
attributes = city_member.attributes
|
93
|
+
assert_equal(5, attributes.length)
|
94
|
+
|
95
|
+
attr = XML::Attr.new(city_member, 'size', '50,000')
|
96
|
+
assert_instance_of(XML::Attr, attr)
|
97
|
+
|
98
|
+
attributes = city_member.attributes
|
99
|
+
assert_equal(6, attributes.length)
|
100
|
+
|
101
|
+
assert_equal(attributes['size'], '50,000')
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_create_on_node
|
105
|
+
attributes = city_member.attributes
|
106
|
+
assert_equal(5, attributes.length)
|
107
|
+
|
108
|
+
attributes['country'] = 'England'
|
109
|
+
|
110
|
+
attributes = city_member.attributes
|
111
|
+
assert_equal(6, attributes.length)
|
112
|
+
|
113
|
+
assert_equal(attributes['country'], 'England')
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_create_ns
|
117
|
+
assert_equal(5, city_member.attributes.length)
|
118
|
+
|
119
|
+
ns = XML::Namespace.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
|
120
|
+
attr = XML::Attr.new(city_member, 'rating', 'rocks', ns)
|
121
|
+
assert_instance_of(XML::Attr, attr)
|
122
|
+
assert_equal('rating', attr.name)
|
123
|
+
assert_equal('rocks', attr.value)
|
124
|
+
|
125
|
+
attributes = city_member.attributes
|
126
|
+
assert_equal(6, attributes.length)
|
127
|
+
|
128
|
+
assert_equal('rocks', city_member['rating'])
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_remove
|
132
|
+
attributes = city_member.attributes
|
133
|
+
assert_equal(5, attributes.length)
|
134
|
+
|
135
|
+
attribute = attributes.get_attribute('name')
|
136
|
+
assert_not_nil(attribute.parent)
|
137
|
+
assert(attribute.parent?)
|
138
|
+
|
139
|
+
attribute.remove!
|
140
|
+
assert_equal(4, attributes.length)
|
141
|
+
assert_nil(attribute.parent)
|
142
|
+
assert(!attribute.parent?)
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_first
|
146
|
+
attribute = city_member.attributes.first
|
147
|
+
assert_instance_of(XML::Attr, attribute)
|
148
|
+
assert_equal('name', attribute.name)
|
149
|
+
assert_equal('Cambridge', attribute.value)
|
150
|
+
|
151
|
+
attribute = attribute.next
|
152
|
+
assert_instance_of(XML::Attr, attribute)
|
153
|
+
assert_equal('type', attribute.name)
|
154
|
+
assert_equal('simple', attribute.value)
|
155
|
+
|
156
|
+
attribute = attribute.next
|
157
|
+
assert_instance_of(XML::Attr, attribute)
|
158
|
+
assert_equal('title', attribute.name)
|
159
|
+
assert_equal('Trinity Lane', attribute.value)
|
160
|
+
|
161
|
+
attribute = attribute.next
|
162
|
+
assert_instance_of(XML::Attr, attribute)
|
163
|
+
assert_equal('href', attribute.name)
|
164
|
+
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
165
|
+
|
166
|
+
attribute = attribute.next
|
167
|
+
assert_instance_of(XML::Attr, attribute)
|
168
|
+
assert_equal('remoteSchema', attribute.name)
|
169
|
+
assert_equal("city.xsd#xpointer(//complexType[@name='RoadType'])", attribute.value)
|
170
|
+
|
171
|
+
attribute = attribute.next
|
172
|
+
assert_nil(attribute)
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_no_attributes
|
176
|
+
element = @doc.find('/city:CityModel/city:type').first
|
177
|
+
|
178
|
+
assert_not_nil(element.attributes)
|
179
|
+
assert_equal(0, element.attributes.length)
|
180
|
+
end
|
181
|
+
end
|