xmlhash 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.3.2 / 2012-11-06
2
+
3
+ * elements that have both attributes and content, are now parsed
4
+ as { "attr" => "value", "_content" => "CONTENT" }
5
+
1
6
  === 1.3.1 / 2012-10-08
2
7
 
3
8
  * fix manifest
@@ -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) && RHASH_SIZE(chash) == 0) {
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 = string;
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
@@ -1,7 +1,7 @@
1
1
  require 'xmlhash/xmlhash'
2
2
 
3
3
  module Xmlhash
4
- VERSION = '1.3.1'
4
+ VERSION = '1.3.2'
5
5
 
6
6
  class XMLHash < Hash
7
7
 
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.1
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-10-08 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pkg-config