xmlhash 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/ext/xmlhash/xmlhash.c +9 -3
- data/lib/xmlhash.rb +1 -1
- data/test/test_xmlhash.rb +11 -0
- metadata +2 -2
data/History.txt
CHANGED
data/ext/xmlhash/xmlhash.c
CHANGED
@@ -55,7 +55,7 @@ void xml_hash_end_element(const xmlChar *name)
|
|
55
55
|
chash = rb_ary_entry(pair, 1);
|
56
56
|
assert(!strcmp((const char*)name, RSTRING_PTR(cname)));
|
57
57
|
|
58
|
-
if (rb_obj_is_kind_of(chash, rb_cHash)
|
58
|
+
if (rb_obj_is_kind_of(chash, rb_cHash)) {
|
59
59
|
VALUE string;
|
60
60
|
const char *string_ptr;
|
61
61
|
long string_len;
|
@@ -72,9 +72,15 @@ void xml_hash_end_element(const xmlChar *name)
|
|
72
72
|
string_len--;
|
73
73
|
}
|
74
74
|
/* avoid overwriting empty hash with empty string */
|
75
|
-
if (string_len > 0)
|
76
|
-
chash
|
75
|
+
if (string_len > 0) {
|
76
|
+
if (RHASH_SIZE(chash) == 0)
|
77
|
+
chash = string;
|
78
|
+
else {
|
79
|
+
rb_hash_aset(chash, rb_str_new2("_content"), string);
|
80
|
+
}
|
81
|
+
}
|
77
82
|
}
|
83
|
+
rb_ary_clear(m_cstring);
|
78
84
|
if (RARRAY_LEN(m_stack) == 0) {
|
79
85
|
m_result = chash;
|
80
86
|
return;
|
data/lib/xmlhash.rb
CHANGED
data/test/test_xmlhash.rb
CHANGED
@@ -107,4 +107,15 @@ eos
|
|
107
107
|
assert_equal ret.get("value"), "Adrian Schröter"
|
108
108
|
end
|
109
109
|
|
110
|
+
def test_cdata
|
111
|
+
xml = <<eos
|
112
|
+
<sourcediff key="7ebf6606bf56a9f952dda73f0d861738">
|
113
|
+
<new name="myfile" md5="299d8fe34c516b078c3d367e3fb460b9" size="12"/>
|
114
|
+
<diff lines="1">DummyContent</diff>
|
115
|
+
</sourcediff>
|
116
|
+
eos
|
117
|
+
|
118
|
+
ret = Xmlhash.parse(xml)
|
119
|
+
assert_equal ret['diff'], {"lines" => "1", "_content" => "DummyContent" }
|
120
|
+
end
|
110
121
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlhash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pkg-config
|