libxml-xmlrpc 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,6 @@ module XML
20
20
  #
21
21
 
22
22
  module XMLRPC
23
- VERSION = "0.1.2"
23
+ VERSION = "0.1.3"
24
24
  end
25
25
  end
@@ -30,7 +30,20 @@ module XML
30
30
  # UTF-8 before passing them into this module.
31
31
  #
32
32
  module Builder
33
- #
33
+
34
+
35
+ # toggles builder debugging
36
+ def self.debug=(x)
37
+ @debug = x
38
+ end
39
+
40
+ # gets the debugging state
41
+ def self.debug
42
+ @debug
43
+ end
44
+
45
+ self.debug = false
46
+
34
47
  # Builds the appropriate XML for a methodCall.
35
48
  #
36
49
  # Takes a methodname and a series of arguments.
@@ -43,6 +56,8 @@ module XML
43
56
  output += Value.generate(*args)
44
57
  output += "</methodCall>"
45
58
 
59
+ self.debug_output output
60
+
46
61
  return output
47
62
  end
48
63
 
@@ -55,6 +70,9 @@ module XML
55
70
  output += Value.generate(*args)
56
71
  output += "</methodResponse>"
57
72
 
73
+ self.debug_output output
74
+
75
+ return output
58
76
  end
59
77
 
60
78
  #
@@ -68,6 +86,10 @@ module XML
68
86
  output += "<member><name>faultString</name><value><string>#{faultMessage}</string></value></member>"
69
87
  output += "</struct></value></fault>"
70
88
  output += "</methodResponse>"
89
+
90
+ self.debug_output output
91
+
92
+ return output
71
93
  end
72
94
 
73
95
  #
@@ -77,6 +99,14 @@ module XML
77
99
  def self.method_missing(*args)
78
100
  self.call(*args)
79
101
  end
102
+
103
+ private
104
+
105
+ def self.debug_output(output)
106
+ if @debug
107
+ $stderr.puts "Building:\n#{output}"
108
+ end
109
+ end
80
110
  end
81
111
 
82
112
  #
@@ -9,6 +9,17 @@ module XML
9
9
  # It will not handle redirection.
10
10
  #
11
11
  class Client
12
+
13
+ # set the debug state
14
+ def self.debug=(x)
15
+ @debug = x
16
+ end
17
+
18
+ # get the debug state
19
+ def self.debug
20
+ @debug
21
+ end
22
+
12
23
  #
13
24
  # Given an unused Net::HTTP object and a relative URL, it will post
14
25
  # the XML-RPC information to this form after calling a method with
@@ -35,7 +46,10 @@ module XML
35
46
  # fault response.
36
47
  #
37
48
  def call(methodName, *args)
38
- res = @http.post(@url, XML::XMLRPC::Builder.call(methodName, *args))
49
+ XML::XMLRPC::Builder.debug = self.class.debug
50
+ XML::XMLRPC::Parser.debug = self.class.debug
51
+
52
+ res = @http.post(@url, XML::XMLRPC::Builder.call(methodName, *args), { "Content-type" => 'text/xml' })
39
53
  res_args = XML::XMLRPC::Parser.new(res.body)
40
54
  return res_args
41
55
  end
@@ -45,6 +45,18 @@ module XML::XMLRPC
45
45
 
46
46
  include Enumerable
47
47
 
48
+ # set the debugging state
49
+ def self.debug=(x)
50
+ @debug = x
51
+ end
52
+
53
+ # get the debugging state
54
+ def self.debug
55
+ @debug
56
+ end
57
+
58
+ self.debug = false
59
+
48
60
  attr_reader :params
49
61
  attr_reader :method
50
62
 
@@ -64,6 +76,10 @@ module XML::XMLRPC
64
76
  raise ParserError, "Argument to new must be String or IO"
65
77
  end
66
78
 
79
+ if self.class.debug
80
+ $stderr.puts "Parsing:\n#{@string}";
81
+ end
82
+
67
83
  @params = []
68
84
  @method = nil
69
85
  self.parse!
@@ -8,6 +8,22 @@ class TestBuilder < Test::Unit::TestCase
8
8
  @class = XML::XMLRPC::Builder
9
9
  end
10
10
 
11
+ def test_debug
12
+
13
+ assert(!@class.instance_variable_get("@debug"))
14
+
15
+ assert_nothing_raised do
16
+ @class.debug = true
17
+ end
18
+
19
+ assert(@class.instance_variable_get("@debug"))
20
+
21
+ assert_nothing_raised do
22
+ @class.debug = false
23
+ end
24
+ end
25
+
26
+
11
27
  def test_call
12
28
  # ugh. these sure are ugly.
13
29
  assert_equal(@class.foo,
@@ -19,6 +19,20 @@ class TestParserGood < Test::Unit::TestCase
19
19
  end
20
20
  end
21
21
 
22
+ def test_debug
23
+ assert(!XML::XMLRPC::Parser.debug)
24
+
25
+ assert_nothing_raised do
26
+ XML::XMLRPC::Parser.debug = true
27
+ end
28
+
29
+ assert(XML::XMLRPC::Parser.debug)
30
+
31
+ assert_nothing_raised do
32
+ XML::XMLRPC::Parser.debug = false
33
+ end
34
+ end
35
+
22
36
  def test_datatypes
23
37
  xml = nil
24
38
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: libxml-xmlrpc
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2007-11-02 00:00:00 -07:00
6
+ version: 0.1.3
7
+ date: 2007-11-25 00:00:00 -08:00
8
8
  summary: Provides a alternative and faster XML-RPC layer through libxml's parsing framework
9
9
  require_paths:
10
10
  - lib