xmlcodec 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  PKG_NAME = 'xmlcodec'
2
- PKG_VERSION = '0.0.4'
2
+ PKG_VERSION = '0.0.5'
3
3
 
4
4
  require 'rake'
5
5
  require 'rake/testtask'
data/lib/XMLElement.rb CHANGED
@@ -71,6 +71,7 @@ module XMLCodec
71
71
 
72
72
  # Add a xmlsubel_mult type attribute (wrapper around attr_accessor)
73
73
  def self.xmlsubel_mult(name) #:doc:
74
+ name = name.to_sym
74
75
  self._xmlsubel(name)
75
76
  self.xmlsubelmultiples << name
76
77
  define_method(name){
@@ -86,7 +86,7 @@ module XMLUtils
86
86
  end
87
87
 
88
88
  def text(text)
89
- @contents << text
89
+ @contents << XMLUtils.escape_xml(text)
90
90
  end
91
91
 
92
92
  def tag_end(name)
@@ -44,4 +44,12 @@ class TestXMLStreamParser < Test::Unit::TestCase
44
44
  assert_equal(1, listener.abc_id)
45
45
  assert(listener.def_id > listener.def_parent_id)
46
46
  end
47
+
48
+ def test_entities
49
+ edoc = '<root>&amp;</root>'
50
+
51
+ parser = XMLUtils::XMLStreamParser.new
52
+ parser.parse(edoc)
53
+ assert_equal(edoc, parser.content)
54
+ end
47
55
  end
data/test/TestXMLUtils.rb CHANGED
@@ -13,6 +13,7 @@ class TestXMLUtils < Test::Unit::TestCase
13
13
  assert_equal '&lt; abc', XMLUtils::escape_xml('< abc')
14
14
  assert_equal '&gt; abc', XMLUtils::escape_xml('> abc')
15
15
  assert_equal '&amp; abc', XMLUtils::escape_xml('& abc')
16
+ assert_equal 'abc', XMLUtils::escape_xml('abc')
16
17
  end
17
18
 
18
19
  def test_get_xpath
@@ -43,7 +43,7 @@ end
43
43
  class SubelMultElement < XMLElement
44
44
  elname 'mult'
45
45
  xmlsubel_mult :abc
46
- xmlsubel_mult :abc2
46
+ xmlsubel_mult 'abc2' # Use a string and a symbol so that both are checked
47
47
  end
48
48
 
49
49
  class Recursive < XMLElement
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: xmlcodec
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.4
7
- date: 2006-07-06 00:00:00 +01:00
6
+ version: 0.0.5
7
+ date: 2006-07-20 00:00:00 +01:00
8
8
  summary: Generic Importer/Exporter of XML formats
9
9
  require_paths:
10
10
  - lib