rubiii-apricoteatsgorilla 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.8
|
data/apricoteatsgorilla.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{apricoteatsgorilla}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Harrington"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-17}
|
13
13
|
s.description = %q{SOAP communication helper}
|
14
14
|
s.email = %q{me@rubiii.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,23 +30,22 @@ Gem::Specification.new do |s|
|
|
30
30
|
"spec/apricoteatsgorilla/xml_node_spec.rb",
|
31
31
|
"spec/spec_helper.rb"
|
32
32
|
]
|
33
|
-
s.has_rdoc = true
|
34
33
|
s.homepage = %q{http://github.com/rubiii/apricoteatsgorilla}
|
35
34
|
s.rdoc_options = ["--charset=UTF-8", "--title", "Apricot eats Gorilla", "--main", "README.rdoc", "--line-numbers", "--inline-source"]
|
36
35
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.
|
36
|
+
s.rubygems_version = %q{1.3.4}
|
38
37
|
s.summary = %q{SOAP communication helper}
|
39
38
|
s.test_files = [
|
40
|
-
"spec/
|
41
|
-
"spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb",
|
39
|
+
"spec/spec_helper.rb",
|
42
40
|
"spec/apricoteatsgorilla/apricoteatsgorilla_xml_to_hash_spec.rb",
|
43
41
|
"spec/apricoteatsgorilla/xml_node_spec.rb",
|
44
|
-
"spec/
|
42
|
+
"spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb",
|
43
|
+
"spec/apricoteatsgorilla/apricoteatsgorilla_hash_to_xml_spec.rb"
|
45
44
|
]
|
46
45
|
|
47
46
|
if s.respond_to? :specification_version then
|
48
47
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
-
s.specification_version =
|
48
|
+
s.specification_version = 3
|
50
49
|
|
51
50
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
51
|
s.add_runtime_dependency(%q<hpricot>, ["= 0.8.241"])
|
@@ -10,6 +10,12 @@ end
|
|
10
10
|
class ApricotEatsGorilla
|
11
11
|
class << self
|
12
12
|
|
13
|
+
# SOAP dateTime format.
|
14
|
+
SOAPDateTimeFormat = "%Y-%m-%dT%H:%M:%S"
|
15
|
+
|
16
|
+
# SOAP dateTime Regexp.
|
17
|
+
SOAPDateTimeRegexp = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
|
18
|
+
|
13
19
|
# SOAP namespaces by SOAP version.
|
14
20
|
SOAPNamespace = {
|
15
21
|
1 => "http://schemas.xmlsoap.org/soap/envelope/",
|
@@ -148,7 +154,9 @@ class ApricotEatsGorilla
|
|
148
154
|
|
149
155
|
# Translates a single XML root node to a Ruby Hash.
|
150
156
|
def single_xml_root_node_to_hash(root)
|
151
|
-
if root.first.children.
|
157
|
+
if root.first.children.nil?
|
158
|
+
{}
|
159
|
+
elsif root.first.children.first.kind_of? Hpricot::Text
|
152
160
|
map_xml_value(root.first.children.to_s)
|
153
161
|
else
|
154
162
|
xml_node_to_hash(root.first)
|
@@ -251,7 +259,7 @@ class ApricotEatsGorilla
|
|
251
259
|
# Converts XML values to more natural Ruby objects.
|
252
260
|
def map_xml_value(value)
|
253
261
|
case value
|
254
|
-
when
|
262
|
+
when SOAPDateTimeRegexp
|
255
263
|
DateTime.parse(value)
|
256
264
|
when "true"
|
257
265
|
true
|
@@ -265,9 +273,9 @@ class ApricotEatsGorilla
|
|
265
273
|
# Converts Hash values into valid XML values.
|
266
274
|
def map_hash_value(value)
|
267
275
|
if value.kind_of? DateTime
|
268
|
-
value.strftime(
|
269
|
-
elsif value.respond_to?
|
270
|
-
value.to_datetime.strftime(
|
276
|
+
value.strftime(SOAPDateTimeFormat)
|
277
|
+
elsif !value.kind_of?(String) && value.respond_to?(:to_datetime)
|
278
|
+
value.to_datetime.strftime(SOAPDateTimeFormat)
|
271
279
|
elsif value.respond_to? :to_s
|
272
280
|
value.to_s
|
273
281
|
else
|
@@ -41,7 +41,6 @@ describe ApricotEatsGorilla do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "converts objects responding to 'to_datetime' into xsd:dateTime Strings" do
|
44
|
-
date = DateTime.new(y=2009, m=9, d=1, h=12, min=0, s=8)
|
45
44
|
TestObject = Struct.new(:whatever) do
|
46
45
|
def to_datetime
|
47
46
|
DateTime.new(y=2009, m=9, d=1, h=12, min=0, s=8)
|
@@ -72,6 +72,11 @@ describe ApricotEatsGorilla do
|
|
72
72
|
ApricotEatsGorilla.xml_to_hash(xml, "//return").should == "123"
|
73
73
|
end
|
74
74
|
|
75
|
+
it "returns an empty Hash in case the root node is an empty-element tag" do
|
76
|
+
xml = '<root><return /></root>'
|
77
|
+
ApricotEatsGorilla.xml_to_hash(xml, "//return").should == {}
|
78
|
+
end
|
79
|
+
|
75
80
|
it "returns an Array of values in case of multiple root nodes without subnodes" do
|
76
81
|
xml = '<root><return>123</return><return>456</return></root>'
|
77
82
|
ApricotEatsGorilla.xml_to_hash(xml, "//return").should == ["123", "456"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubiii-apricoteatsgorilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- spec/apricoteatsgorilla/apricoteatsgorilla_xml_to_hash_spec.rb
|
55
55
|
- spec/apricoteatsgorilla/xml_node_spec.rb
|
56
56
|
- spec/spec_helper.rb
|
57
|
-
has_rdoc:
|
57
|
+
has_rdoc: false
|
58
58
|
homepage: http://github.com/rubiii/apricoteatsgorilla
|
59
59
|
licenses:
|
60
60
|
post_install_message:
|
@@ -85,11 +85,11 @@ requirements: []
|
|
85
85
|
rubyforge_project:
|
86
86
|
rubygems_version: 1.3.5
|
87
87
|
signing_key:
|
88
|
-
specification_version:
|
88
|
+
specification_version: 3
|
89
89
|
summary: SOAP communication helper
|
90
90
|
test_files:
|
91
|
-
- spec/
|
92
|
-
- spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
93
92
|
- spec/apricoteatsgorilla/apricoteatsgorilla_xml_to_hash_spec.rb
|
94
93
|
- spec/apricoteatsgorilla/xml_node_spec.rb
|
95
|
-
- spec/
|
94
|
+
- spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
|
95
|
+
- spec/apricoteatsgorilla/apricoteatsgorilla_hash_to_xml_spec.rb
|