hashtoxml 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,6 @@
1
1
  module HashToXml
2
2
  require 'rexml/document'
3
3
  require 'rubygems'
4
- require 'merb-core/vendor/facets/inflect.rb' if not 'string'.respond_to? :plural
5
4
 
6
5
  def to_xml(options = {})
7
6
  options[:root_name] ||= 'root'
@@ -18,30 +17,7 @@ module HashToXml
18
17
  end
19
18
 
20
19
  protected
21
- def array_to_xml_document(elements_name, options={}, doc = nil)
22
-
23
- if not doc
24
- doc = REXML::Document.new
25
- root = doc.add_element(options[:root_name] )
26
- root.attributes["type"] = options[:root_type]
27
- end
28
- root = doc.root
29
-
30
- self.each do |value|
31
- element_name = elements_name.to_s.singular
32
- element_type = HashToXml.data_type(value)
33
-
34
- element_text = REXML::Text.new(value.to_s) unless value.nil?
35
-
36
- node = root.add_element(element_name)
37
- node.attributes["type"] = element_type
38
- node << element_text
39
- end
40
-
41
- doc
42
- end
43
-
44
- def hash_to_xml_document(options={}, doc = nil)
20
+ def to_xml_document(options={}, doc = nil)
45
21
  if not doc
46
22
  doc = REXML::Document.new
47
23
  root = doc.add_element(options[:root_name] )
@@ -66,7 +42,7 @@ module HashToXml
66
42
  node << value.hash_to_xml_document(options, doc)
67
43
  elsif value.is_a? Array
68
44
  value.class.send(:include, HashToXml) if not value.respond_to? :to_xml
69
- node = value.array_to_xml_document(key, options, node)
45
+ node = value.to_xml_document(options, node)
70
46
  else
71
47
  node << element_text
72
48
  end
data/lib/hashtoxml.rb CHANGED
@@ -7,7 +7,7 @@ unless defined? HashToXml
7
7
  module HashToXml
8
8
 
9
9
  # :stopdoc:
10
- VERSION = '0.0.2'
10
+ VERSION = '0.0.3'
11
11
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
12
12
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
13
13
  # :startdoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashtoxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Bogaert