1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/xmlrpc/parser.rb: support i8 types. Thanks Stas Kelvich!

[ruby-core:29246] [Feature #3090]

* test/xmlrpc/test_client.rb: supporting test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2012-03-06 23:30:03 +00:00
parent 9e9264c8d5
commit ce2f69862e
3 changed files with 26 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Wed Mar 7 08:28:00 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/xmlrpc/parser.rb: support i8 types. Thanks Stas Kelvich!
[ruby-core:29246] [Feature #3090]
* test/xmlrpc/test_client.rb: supporting test
Wed Mar 7 07:43:29 2012 Aaron Patterson <aaron@tenderlovemaking.com> Wed Mar 7 07:43:29 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/xmlrpc/client.rb: assume servers that do not send a Content-Type * lib/xmlrpc/client.rb: assume servers that do not send a Content-Type

View file

@ -169,7 +169,7 @@ module XMLRPC
private private
# #
# remove all whitespaces but in the tags i4, int, boolean.... # remove all whitespaces but in the tags i4, i8, int, boolean....
# and all comments # and all comments
# #
def removeWhitespacesAndComments(node) def removeWhitespacesAndComments(node)
@ -179,7 +179,7 @@ module XMLRPC
case _nodeType(nd) case _nodeType(nd)
when :TEXT when :TEXT
# TODO: add nil? # TODO: add nil?
unless %w(i4 int boolean string double dateTime.iso8601 base64).include? node.nodeName unless %w(i4 i8 int boolean string double dateTime.iso8601 base64).include? node.nodeName
if node.nodeName == "value" if node.nodeName == "value"
if not node.childNodes.to_a.detect {|n| _nodeType(n) == :ELEMENT}.nil? if not node.childNodes.to_a.detect {|n| _nodeType(n) == :ELEMENT}.nil?
@ -253,7 +253,7 @@ module XMLRPC
def integer(node) def integer(node)
#TODO: check string for float because to_i returnsa #TODO: check string for float because to_i returnsa
# 0 when wrong string # 0 when wrong string
nodeMustBe(node, %w(i4 int)) nodeMustBe(node, %w(i4 i8 int))
hasOnlyOneChild(node) hasOnlyOneChild(node)
Convert.int(text(node.firstChild)) Convert.int(text(node.firstChild))
@ -415,7 +415,7 @@ module XMLRPC
text_zero_one(node) text_zero_one(node)
when :ELEMENT when :ELEMENT
case child.nodeName case child.nodeName
when "i4", "int" then integer(child) when "i4", "i8", "int" then integer(child)
when "boolean" then boolean(child) when "boolean" then boolean(child)
when "string" then string(child) when "string" then string(child)
when "double" then double(child) when "double" then double(child)
@ -525,7 +525,7 @@ module XMLRPC
case name case name
when "string" when "string"
@value = @data @value = @data
when "i4", "int" when "i4", "i8", "int"
@value = Convert.int(@data) @value = Convert.int(@data)
when "boolean" when "boolean"
@value = Convert.boolean(@data) @value = Convert.boolean(@data)

View file

@ -233,6 +233,20 @@ module XMLRPC
assert_equal expected, resp assert_equal expected, resp
end end
def test_i8_tag
fh = read('blog.xml').gsub(/string/, 'i8')
responses = {
'/foo' => [ Fake::Response.new(fh) ]
}
client = fake_client(responses).new2 'http://example.org/foo'
resp = client.call('wp.getUsersBlogs', 'tlo', 'omg')
assert_equal 1, resp.first['blogid']
end
private private
def read filename def read filename
File.read File.expand_path(File.join(__FILE__, '..', 'data', filename)) File.read File.expand_path(File.join(__FILE__, '..', 'data', filename))