xmlrpcs 0.1 → 0.1.1

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.
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'rubygems'
2
+ Gem::manage_gems
3
+ require 'rake/gempackagetask'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/rdoctask'
7
+
8
+ spec = Gem::Specification.new do |s|
9
+ s.name = "xmlrpcs"
10
+ s.version = "0.1.1"
11
+ s.author = "Dario Meloni"
12
+ s.email = "mellon85@gmail.com"
13
+ s.homepage = "http://rubyforge.org/projects/xmlrpcs/"
14
+ s.rubyforge_project = "xmlrpcs"
15
+ s.platform = Gem::Platform::RUBY
16
+ s.summary = "Changes sockets for the XMLRPC Library"
17
+ s.files = FileList['lib/**/*.rb', 'test/**/*.rb', 'Rakefile'].to_a
18
+ s.require_path = "lib"
19
+ s.test_files = Dir.glob('test/**/tc_*.rb')
20
+ s.has_rdoc = true
21
+ end
22
+
23
+ Rake::GemPackageTask.new(spec) do |p|
24
+ p.gem_spec = spec
25
+ p.need_tar = true
26
+ p.need_zip = true
27
+ end
28
+
29
+ Rake::RDocTask.new do |rd|
30
+ rd.rdoc_dir = "rdoc"
31
+ rd.rdoc_files.include("./lib/**/*.rb")
32
+ rd.options = %w(-ap)
33
+ end
34
+
35
+ task :distclean => [:clobber_package, :clobber_rdoc]
36
+ task :dist => [:repackage, :gem, :rdoc]
37
+ task :clean => [:distclean]
38
+ task :default => [ :test, :dist ]
39
+
40
+ #task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
41
+ # puts "generated latest version"
42
+ #end
43
+
@@ -2,11 +2,13 @@
2
2
  # Author: Dario Meloni <mellon85@gmail.com>
3
3
 
4
4
  require 'test/unit'
5
- require 'xmlrpcs'
5
+ require 'rubygems'
6
+ require 'xmlrpc/xmlrpcs'
6
7
  require 'xmlrpc/server'
7
8
  require 'socket'
8
9
 
9
10
  $test_port="20000"
11
+ $test_host="localhost"
10
12
 
11
13
  class TCPXMLClient < XMLRPC::ClientS
12
14
  def new_socket(info,async)
@@ -26,8 +28,17 @@ end
26
28
 
27
29
  class TCPXMLServer < XMLRPC::BasicServer
28
30
 
31
+ attr_reader :host
32
+ attr_reader :port
33
+
34
+ def initialize( host, port )
35
+ @host = host
36
+ @port = port
37
+ @server = TCPServer.new(@host,@port)
38
+ super()
39
+ end
40
+
29
41
  def serve()
30
- @server = TCPServer.new('localhost',20000)
31
42
  catch (:exit_serve) {
32
43
  while(true)
33
44
  @server.listen(5)
@@ -41,15 +52,14 @@ class TCPXMLServer < XMLRPC::BasicServer
41
52
  end
42
53
  }
43
54
  end
44
-
45
- attr_accessor :path
46
55
  end
47
56
 
48
57
  class TC_xmlrpcs_tcp < Test::Unit::TestCase
49
58
  def setup
50
- @s = TCPXMLServer.new()
59
+ @s = TCPXMLServer.new($test_host,$test_port)
51
60
  @s.add_introspection
52
- @s.add_handler("test.add") do |a,b|
61
+ @s.add_multicall
62
+ @s.add_handler("add") do |a,b|
53
63
  a+b
54
64
  end
55
65
  @t = Thread.new do
@@ -62,8 +72,12 @@ class TC_xmlrpcs_tcp < Test::Unit::TestCase
62
72
  end
63
73
 
64
74
  def test_create
65
- c = TCPXMLClient.new({"host" => "localhost", "port" => "#{$test_port}"})
66
- assert(c.call("test.add",2,3) == 5, "Failed calling test.add")
67
- assert(c.call("system.listMethods"),"Failed system.listMethods")
75
+ client = TCPXMLClient.new({"host" => $test_host, "port" => "#{$test_port}"})
76
+ assert(client.call("add",2,3) == 5, "Failed calling add")
77
+ proxy = client.proxy
78
+ assert(proxy.add(1,4) == 5,"Failed using the proxy")
79
+ a, b = client.multicall(["add",3,2],["add",4,1])
80
+ assert( a == 5 && b == 5, "Failed multicall")
81
+ assert(client.call("system.listMethods"),"Failed system.listMethods")
68
82
  end
69
83
  end
@@ -1,12 +1,13 @@
1
1
  #! /usr/bin/ruby
2
2
  # Author: Dario Meloni <mellon85@gmail.com>
3
3
 
4
+ require 'rubygems'
4
5
  require 'test/unit'
5
- require 'xmlrpcs'
6
+ require 'xmlrpc/xmlrpcs'
6
7
  require 'xmlrpc/server'
7
8
  require 'socket'
8
9
 
9
- $socket_path="test.sock"
10
+ $socket_path="/tmp/test.sock"
10
11
 
11
12
  class UnixXMLClient < XMLRPC::ClientS
12
13
  def new_socket(info,async)
@@ -26,8 +27,15 @@ end
26
27
 
27
28
  class UnixXMLServer < XMLRPC::BasicServer
28
29
 
29
- def serve()
30
+ attr_reader :path
31
+
32
+ def initialize( path )
33
+ super()
34
+ @path = path
30
35
  @server = UNIXServer.new(@path)
36
+ end
37
+
38
+ def serve()
31
39
  catch (:exit_serve) {
32
40
  while(true)
33
41
  @server.listen(5)
@@ -41,15 +49,13 @@ class UnixXMLServer < XMLRPC::BasicServer
41
49
  end
42
50
  }
43
51
  end
44
-
45
- attr_accessor :path
46
52
  end
47
53
 
48
54
  class TC_xmlrpcs_unix < Test::Unit::TestCase
49
55
  def setup
50
- @s = UnixXMLServer.new()
51
- @s.path=$socket_path
56
+ @s = UnixXMLServer.new($socket_path)
52
57
  @s.add_introspection
58
+ @s.add_multicall
53
59
  @s.add_handler("test.add") do |a,b|
54
60
  a+b
55
61
  end
@@ -64,8 +70,12 @@ class TC_xmlrpcs_unix < Test::Unit::TestCase
64
70
  end
65
71
 
66
72
  def test_create
67
- c = UnixXMLClient.new($socket_path)
68
- assert(c.call("test.add",2,3) == 5, "Failed calling test.add")
69
- assert(c.call("system.listMethods"),"Failed system.listMethods")
73
+ client = UnixXMLClient.new($socket_path)
74
+ assert(client.call("test.add",2,3) == 5, "Failed calling add")
75
+ proxy = client.proxy "test"
76
+ assert(proxy.add(1,4) == 5,"Failed using the proxy")
77
+ a, b = client.multicall(["test.add",3,2],["test.add",4,1])
78
+ assert( a == 5 && b == 5, "Failed multicall")
79
+ assert(client.call("system.listMethods"),"Failed system.listMethods")
70
80
  end
71
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlrpcs
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dario Meloni
@@ -19,13 +19,13 @@ executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files:
23
- - README
22
+ extra_rdoc_files: []
23
+
24
24
  files:
25
25
  - lib/xmlrpc/xmlrpcs.rb
26
26
  - test/xmlrpc/tc_tcp.rb
27
27
  - test/xmlrpc/tc_unix.rb
28
- - README
28
+ - Rakefile
29
29
  has_rdoc: true
30
30
  homepage: http://rubyforge.org/projects/xmlrpcs/
31
31
  post_install_message:
data/README DELETED
@@ -1,24 +0,0 @@
1
- This gems allow to easily change the transport layer in XMLRPC::Client class.
2
- It adds a new class called XMLRPC::ClientS, subclass of the Client class. This
3
- class must be subclassed to put your own transport code in it.
4
-
5
- There are 3 private method that can be changed.
6
-
7
- *new_socket* (info,async)
8
- This method is called to create a new socket. Info is the parameter you passed
9
- to the constructor and async is a boolean value that tells you if the socket
10
- should be asyncrhonous.
11
- The object returned must answer to read and write methods.
12
-
13
- *read_response* (socket)
14
- Must read the response from the socket and return the data. You may leave this
15
- the default, but it will wait until the socket is closed.
16
-
17
- *write_request* (socket,request)
18
- Writes the request in the socket, this may be left as it is.
19
-
20
-
21
- write_request and read_response have to be changed to use a specific protocol if you don't want the socket to be closed.
22
- In the test i use a very simple one for instance which needs no explanation.
23
-
24
- Author: Dario Meloni <mellon85@gmail.com>