benhutton-active_shipping 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +38 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +142 -0
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/common/connection.rb +177 -0
- data/lib/active_merchant/common/country.rb +328 -0
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/common/posts_data.rb +63 -0
- data/lib/active_merchant/common/requires_parameters.rb +16 -0
- data/lib/active_merchant/common/utils.rb +22 -0
- data/lib/active_merchant/common/validateable.rb +76 -0
- data/lib/active_shipping.rb +49 -0
- data/lib/active_shipping/shipping/base.rb +13 -0
- data/lib/active_shipping/shipping/carrier.rb +70 -0
- data/lib/active_shipping/shipping/carriers.rb +20 -0
- data/lib/active_shipping/shipping/carriers/bogus_carrier.rb +16 -0
- data/lib/active_shipping/shipping/carriers/canada_post.rb +268 -0
- data/lib/active_shipping/shipping/carriers/fedex.rb +331 -0
- data/lib/active_shipping/shipping/carriers/kunaki.rb +165 -0
- data/lib/active_shipping/shipping/carriers/new_zealand_post.rb +139 -0
- data/lib/active_shipping/shipping/carriers/shipwire.rb +172 -0
- data/lib/active_shipping/shipping/carriers/ups.rb +390 -0
- data/lib/active_shipping/shipping/carriers/usps.rb +441 -0
- data/lib/active_shipping/shipping/location.rb +109 -0
- data/lib/active_shipping/shipping/package.rb +147 -0
- data/lib/active_shipping/shipping/rate_estimate.rb +54 -0
- data/lib/active_shipping/shipping/rate_response.rb +19 -0
- data/lib/active_shipping/shipping/response.rb +46 -0
- data/lib/active_shipping/shipping/shipment_event.rb +14 -0
- data/lib/active_shipping/shipping/tracking_response.rb +22 -0
- data/lib/active_shipping/version.rb +3 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/certs/eParcel.dtd +111 -0
- data/lib/vendor/quantified/MIT-LICENSE +22 -0
- data/lib/vendor/quantified/README.markdown +49 -0
- data/lib/vendor/quantified/Rakefile +21 -0
- data/lib/vendor/quantified/init.rb +0 -0
- data/lib/vendor/quantified/lib/quantified.rb +8 -0
- data/lib/vendor/quantified/lib/quantified/attribute.rb +208 -0
- data/lib/vendor/quantified/lib/quantified/length.rb +20 -0
- data/lib/vendor/quantified/lib/quantified/mass.rb +19 -0
- data/lib/vendor/quantified/test/length_test.rb +92 -0
- data/lib/vendor/quantified/test/mass_test.rb +88 -0
- data/lib/vendor/quantified/test/test_helper.rb +2 -0
- data/lib/vendor/test_helper.rb +13 -0
- data/lib/vendor/xml_node/README +36 -0
- data/lib/vendor/xml_node/Rakefile +21 -0
- data/lib/vendor/xml_node/benchmark/bench_generation.rb +32 -0
- data/lib/vendor/xml_node/init.rb +1 -0
- data/lib/vendor/xml_node/lib/xml_node.rb +222 -0
- data/lib/vendor/xml_node/test/test_generating.rb +94 -0
- data/lib/vendor/xml_node/test/test_parsing.rb +43 -0
- metadata +125 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module Quantified
|
2
|
+
class Mass < Attribute
|
3
|
+
system :metric do
|
4
|
+
primitive :gram
|
5
|
+
|
6
|
+
one :milligram, :is => Mass.new(0.001, :grams)
|
7
|
+
one :kilogram, :is => Mass.new(1000, :grams)
|
8
|
+
end
|
9
|
+
|
10
|
+
system :imperial do
|
11
|
+
primitive :ounce
|
12
|
+
one :ounce, :is => Mass.new(28.349523125, :grams)
|
13
|
+
|
14
|
+
one :pound, :is => Mass.new(16, :ounces)
|
15
|
+
one :stone, :is => Mass.new(14, :pounds)
|
16
|
+
one :short_ton, :is => Mass.new(2000, :pounds)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'quantified/length'
|
3
|
+
|
4
|
+
class LengthTest < Test::Unit::TestCase
|
5
|
+
include Quantified
|
6
|
+
Length.numeric_methods :metres, :centimetres, :inches, :feet
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@length = Length.new(5, :feet)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_inspect
|
13
|
+
assert_equal "#<Quantified::Length: 5 feet>", @length.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_to_s
|
17
|
+
assert_equal "5 feet", @length.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_initialize_from_numeric
|
21
|
+
assert_equal "5 feet", 5.feet.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_equalities
|
25
|
+
assert_equal 1.feet, (1.0).feet
|
26
|
+
# == based on value
|
27
|
+
assert_equal 6.feet, Length.new(2, :yards)
|
28
|
+
# eql? based on value and unit
|
29
|
+
assert !6.feet.eql?(Length.new(2, :yards))
|
30
|
+
# equal? based on object identity
|
31
|
+
assert !2.feet.equal?(2.feet)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_convert_yards_to_feet
|
35
|
+
assert 6.feet.eql?(Length.new(2, :yards).to_feet)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_convert_feet_to_yards
|
39
|
+
assert Length.new(2, :yards).eql?(6.feet.to_yards)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_convert_yards_to_millimetres
|
43
|
+
assert Length.new(914.4, :millimetres).eql?(Length.new(1, :yards).to_millimetres)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_convert_millimetres_to_yards
|
47
|
+
assert Length.new(1, :yards).eql?(Length.new(914.4, :millimetres).to_yards)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_convert_metres_to_inches
|
51
|
+
assert_equal 1.inches, (0.0254).metres.to_inches
|
52
|
+
assert 1.inches.eql?((0.0254).metres.to_inches)
|
53
|
+
assert 1.inches.eql?((0.0254).metres.in_inches)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_comparison_with_numeric
|
57
|
+
assert 2.feet > 1
|
58
|
+
assert 2.feet == 2
|
59
|
+
assert 2.feet <= 2
|
60
|
+
assert 2.feet < 3
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_method_missing_to_i
|
64
|
+
assert_equal 2, (2.4).feet.to_i
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_method_missing_to_f
|
68
|
+
assert_equal 2.4, (2.4).feet.to_f
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_method_missing_minus
|
72
|
+
assert_equal 2.feet, 5.feet - 3.feet
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_numeric_methods_not_added_for_some_units
|
76
|
+
assert_raises NoMethodError do
|
77
|
+
2.yards
|
78
|
+
end
|
79
|
+
assert_raises NoMethodError do
|
80
|
+
2.millimetres
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_systems
|
85
|
+
assert_equal [:metric, :imperial], Length.systems
|
86
|
+
assert_equal [:metres, :centimetres, :millimetres, :kilometres], Length.units(:metric)
|
87
|
+
assert_equal [:inches, :feet, :yards, :miles], Length.units(:imperial)
|
88
|
+
|
89
|
+
assert_equal :metric, 2.centimetres.system
|
90
|
+
assert_equal :imperial, 2.feet.system
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'quantified/mass'
|
3
|
+
|
4
|
+
class MassTest < Test::Unit::TestCase
|
5
|
+
include Quantified
|
6
|
+
Mass.numeric_methods :grams, :kilograms, :ounces, :pounds
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@mass = Mass.new(5, :pounds)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_inspect
|
13
|
+
assert_equal "#<Quantified::Mass: 5 pounds>", @mass.inspect
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_to_s
|
17
|
+
assert_equal "5 pounds", @mass.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_initialize_from_numeric
|
21
|
+
assert_equal "5 pounds", 5.pounds.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_equalities
|
25
|
+
assert_equal 1.pounds, (1.0).pounds
|
26
|
+
# == based on value
|
27
|
+
assert_equal 4000.pounds, Mass.new(2, :short_tons)
|
28
|
+
# eql? based on value and unit
|
29
|
+
assert !4000.pounds.eql?(Mass.new(2, :short_tons))
|
30
|
+
# equal? based on object identity
|
31
|
+
assert !2.pounds.equal?(2.pounds)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_convert_short_tons_to_pounds
|
35
|
+
assert 4000.pounds.eql?(Mass.new(2, :short_tons).to_pounds)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_convert_pounds_to_short_tons
|
39
|
+
assert Mass.new(2, :short_tons).eql?(4000.pounds.to_short_tons)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_convert_short_tons_to_milligrams
|
43
|
+
assert Mass.new(907_184_740, :milligrams).eql?(Mass.new(1, :short_tons).to_milligrams)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_convert_milligrams_to_short_tons
|
47
|
+
assert Mass.new(1, :short_tons).eql?(Mass.new(907_184_740, :milligrams).to_short_tons)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_convert_grams_to_ounces
|
51
|
+
assert 1.ounces.eql?((28.349523125).grams.to_ounces)
|
52
|
+
assert 1.ounces.eql?((28.349523125).grams.in_ounces)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_comparison_with_numeric
|
56
|
+
assert 2.pounds > 1
|
57
|
+
assert 2.pounds == 2
|
58
|
+
assert 2.pounds <= 2
|
59
|
+
assert 2.pounds < 3
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_method_missing_to_i
|
63
|
+
assert_equal 2, (2.4).pounds.to_i
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_method_missing_to_f
|
67
|
+
assert_equal 2.4, (2.4).pounds.to_f
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_method_missing_minus
|
71
|
+
assert_equal 2.pounds, 5.pounds - 3.pounds
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_numeric_methods_not_added_for_some_units
|
75
|
+
assert_raises NoMethodError do
|
76
|
+
2.short_tons
|
77
|
+
end
|
78
|
+
assert_raises NoMethodError do
|
79
|
+
2.milligrams
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_systems
|
84
|
+
assert_equal [:metric, :imperial], Mass.systems
|
85
|
+
assert_equal [:grams, :milligrams, :kilograms], Mass.units(:metric)
|
86
|
+
assert_equal [:ounces, :pounds, :stones, :short_tons], Mass.units(:imperial)
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
XML Node
|
2
|
+
==========
|
3
|
+
|
4
|
+
|
5
|
+
Example for generating xml:
|
6
|
+
|
7
|
+
# Create an atom like document
|
8
|
+
|
9
|
+
root = XmlNode.new 'feed' do |feed|
|
10
|
+
|
11
|
+
feed << XmlNode.new('id', 'tag:atom.com,2007:1')
|
12
|
+
feed << XmlNode.new('title', 'Atom test feed')
|
13
|
+
feed << XmlNode.new('author') do |author|
|
14
|
+
author << XmlNode.new("name", "tobi")
|
15
|
+
author << XmlNode.new("email", "tobi@gmail.com")
|
16
|
+
end
|
17
|
+
|
18
|
+
feed << XmlNode.new('entry') do |entry|
|
19
|
+
entry << XmlNode.new('title', 'First post')
|
20
|
+
entry << XmlNode.new('summary', 'Lorem ipsum', :type => 'xhtml')
|
21
|
+
entry << XmlNode.new('created_at', Time.now)
|
22
|
+
end
|
23
|
+
|
24
|
+
feed << XmlNode.new('dc:published', Time.now)
|
25
|
+
end
|
26
|
+
|
27
|
+
root.to_xml #=> Well formatted xml
|
28
|
+
|
29
|
+
|
30
|
+
Example for parsing xml:
|
31
|
+
|
32
|
+
|
33
|
+
xml = XmlNode.parse('<feed attr="1"><element>text</element><element>text</element></feed>')
|
34
|
+
xml['attr'] #=> '1'
|
35
|
+
xml.children['element'].text #=> 'text'
|
36
|
+
xml.children.each { |e| e... }
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/test_*.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the calculations plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'XmlNode'
|
19
|
+
rdoc.options << '--line-numbers --inline-source'
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "benchmark"
|
2
|
+
require File.dirname(__FILE__) + "/../lib/xml_node"
|
3
|
+
|
4
|
+
class XmlNode
|
5
|
+
|
6
|
+
def to_xml_as_array
|
7
|
+
xml = []
|
8
|
+
document = REXML::Document.new
|
9
|
+
document << REXML::XMLDecl.new('1.0')
|
10
|
+
document << @element
|
11
|
+
document.write( xml, 0)
|
12
|
+
xml.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_xml_no_format
|
16
|
+
xml = ''
|
17
|
+
document = REXML::Document.new
|
18
|
+
document << REXML::XMLDecl.new('1.0')
|
19
|
+
document << @element
|
20
|
+
document.write( xml)
|
21
|
+
xml
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
TESTS = 10000
|
27
|
+
|
28
|
+
Benchmark.bmbm do |results|
|
29
|
+
results.report { TESTS.times do XmlNode.new('feed') { |n| n << XmlNode.new('element', 'test'); n << XmlNode.new('element') }.to_xml end }
|
30
|
+
results.report { TESTS.times do XmlNode.new('feed') { |n| n << XmlNode.new('element', 'test'); n << XmlNode.new('element') }.to_xml_as_array end }
|
31
|
+
results.report { TESTS.times do XmlNode.new('feed') { |n| n << XmlNode.new('element', 'test'); n << XmlNode.new('element') }.to_xml_no_format end }
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# Include hook code here
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
class Object
|
4
|
+
def to_xml_value
|
5
|
+
to_s
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class NilClass
|
10
|
+
def to_xml_value
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class TrueClass
|
16
|
+
def to_xml_value
|
17
|
+
to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class FalseClass
|
22
|
+
def to_xml_value
|
23
|
+
to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Time
|
28
|
+
def to_xml_value
|
29
|
+
self.xmlschema
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class DateTime
|
34
|
+
def to_xml_value
|
35
|
+
self.xmlschema
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Date
|
40
|
+
def to_xml_value
|
41
|
+
self.to_time.xmlschema
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class REXML::Element
|
46
|
+
def to_xml_element
|
47
|
+
self
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class XmlNode
|
52
|
+
attr_accessor :child_nodes
|
53
|
+
attr_reader :element
|
54
|
+
|
55
|
+
class List
|
56
|
+
include Enumerable
|
57
|
+
|
58
|
+
def initialize(parent)
|
59
|
+
@parent = parent
|
60
|
+
@children = {}
|
61
|
+
end
|
62
|
+
|
63
|
+
def [](value)
|
64
|
+
node_for @parent.element.elements[value]
|
65
|
+
end
|
66
|
+
|
67
|
+
def []=(value, key)
|
68
|
+
@parent.element.elements[value.to_s] = key.to_xml_element
|
69
|
+
end
|
70
|
+
|
71
|
+
def each(&block)
|
72
|
+
@parent.element.each_element { |e| yield node_for(e) }
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def node_for(element)
|
78
|
+
@parent.child_nodes[element] ||= XmlNode.new(element)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Allows for very pretty xml generation akin to xml builder.
|
83
|
+
#
|
84
|
+
# Example:
|
85
|
+
#
|
86
|
+
# # Create an atom like document
|
87
|
+
# doc = Document.new
|
88
|
+
# doc.root = XmlNode.new 'feed' do |feed|
|
89
|
+
#
|
90
|
+
# feed << XmlNode.new('id', 'tag:atom.com,2007:1')
|
91
|
+
# feed << XmlNode.new('title', 'Atom test feed')
|
92
|
+
# feed << XmlNode.new('author') do |author|
|
93
|
+
# author << XmlNode.new("name", "tobi")
|
94
|
+
# author << XmlNode.new("email", "tobi@gmail.com")
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# feed << XmlNode.new('entry') do |entry|
|
98
|
+
# entry << XmlNode.new('title', 'First post')
|
99
|
+
# entry << XmlNode.new('summary', 'Lorem ipsum', :type => 'xhtml')
|
100
|
+
# entry << XmlNode.new('created_at', Time.now)
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
# feed << XmlNode.new('dc:published', Time.now)
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
def initialize(node, *args)
|
107
|
+
@element = if node.is_a?(REXML::Element)
|
108
|
+
node
|
109
|
+
else
|
110
|
+
REXML::Element.new(node)
|
111
|
+
end
|
112
|
+
|
113
|
+
@child_nodes = {}
|
114
|
+
|
115
|
+
if attributes = args.last.is_a?(Hash) ? args.pop : nil
|
116
|
+
attributes.each { |k,v| @element.add_attribute(k.to_s, v.to_xml_value) }
|
117
|
+
end
|
118
|
+
|
119
|
+
if !args[0].nil?
|
120
|
+
@element.text = args[0].to_xml_value
|
121
|
+
end
|
122
|
+
|
123
|
+
if block_given?
|
124
|
+
yield self
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.parse(xml)
|
129
|
+
self.new(REXML::Document.new(xml).root)
|
130
|
+
end
|
131
|
+
|
132
|
+
def children
|
133
|
+
XmlNode::List.new(self)
|
134
|
+
end
|
135
|
+
|
136
|
+
def []=(key, value)
|
137
|
+
@element.attributes[key.to_s] = value.to_xml_value
|
138
|
+
end
|
139
|
+
|
140
|
+
def [](key)
|
141
|
+
@element.attributes[key]
|
142
|
+
end
|
143
|
+
|
144
|
+
# Add a namespace to the node
|
145
|
+
# Example
|
146
|
+
#
|
147
|
+
# node.namespace 'http://www.w3.org/2005/Atom'
|
148
|
+
# node.namespace :opensearch, 'http://a9.com/-/spec/opensearch/1.1/'
|
149
|
+
#
|
150
|
+
def namespace(*args)
|
151
|
+
args[0] = args[0].to_s if args[0].is_a?(Symbol)
|
152
|
+
@element.add_namespace(*args)
|
153
|
+
end
|
154
|
+
|
155
|
+
def cdata=(value)
|
156
|
+
new_cdata = REXML::CData.new( value )
|
157
|
+
@element.children.each do |c|
|
158
|
+
if c.is_a?(REXML::CData)
|
159
|
+
return @element.replace_child(c,new_cdata)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
@element << new_cdata
|
163
|
+
rescue RuntimeError => e
|
164
|
+
@element << REXML::Text.new(e.message)
|
165
|
+
end
|
166
|
+
|
167
|
+
def cdata
|
168
|
+
@element.cdatas.first.to_s
|
169
|
+
end
|
170
|
+
|
171
|
+
def name
|
172
|
+
@element.name
|
173
|
+
end
|
174
|
+
|
175
|
+
def text=(value)
|
176
|
+
@element.text = REXML::Text.new( value )
|
177
|
+
end
|
178
|
+
|
179
|
+
def text
|
180
|
+
@element.text
|
181
|
+
end
|
182
|
+
|
183
|
+
def find(scope, xpath)
|
184
|
+
case scope
|
185
|
+
when :first
|
186
|
+
elem = @element.elements[xpath]
|
187
|
+
elem.nil? ? nil : child_nodes[elem] ||= XmlNode.new(elem)
|
188
|
+
when :all
|
189
|
+
@element.elements.to_a(xpath).collect { |e| child_nodes[e] ||= XmlNode.new(e) }
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def <<(elem)
|
194
|
+
case elem
|
195
|
+
when nil then return
|
196
|
+
when Array
|
197
|
+
elem.each { |e| @element << e.to_xml_element }
|
198
|
+
else
|
199
|
+
@element << elem.to_xml_element
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def to_xml_element
|
204
|
+
@element
|
205
|
+
end
|
206
|
+
|
207
|
+
def to_s
|
208
|
+
@element.to_s
|
209
|
+
end
|
210
|
+
|
211
|
+
# Use to get pretty formatted xml including DECL
|
212
|
+
# instructions
|
213
|
+
def to_xml
|
214
|
+
xml = []
|
215
|
+
document = REXML::Document.new
|
216
|
+
document << REXML::XMLDecl.new('1.0')
|
217
|
+
document << @element
|
218
|
+
document.write( xml, 0)
|
219
|
+
xml.join
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|