rubysl-xmlrpc 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/rubysl/xmlrpc.rb +1 -0
- data/lib/rubysl/xmlrpc/version.rb +5 -0
- data/lib/xmlrpc/README.txt +31 -0
- data/lib/xmlrpc/base64.rb +81 -0
- data/lib/xmlrpc/client.rb +625 -0
- data/lib/xmlrpc/config.rb +40 -0
- data/lib/xmlrpc/create.rb +290 -0
- data/lib/xmlrpc/datetime.rb +142 -0
- data/lib/xmlrpc/httpserver.rb +178 -0
- data/lib/xmlrpc/marshal.rb +76 -0
- data/lib/xmlrpc/parser.rb +813 -0
- data/lib/xmlrpc/server.rb +782 -0
- data/lib/xmlrpc/utils.rb +165 -0
- data/rubysl-xmlrpc.gemspec +23 -0
- metadata +120 -0
data/lib/xmlrpc/utils.rb
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
#
|
2
|
+
# Defines ParserWriterChooseMixin, which makes it possible to choose a
|
3
|
+
# different XML writer and/or XML parser then the default one.
|
4
|
+
# The Mixin is used in client.rb (class Client) and server.rb (class
|
5
|
+
# BasicServer)
|
6
|
+
#
|
7
|
+
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
|
8
|
+
#
|
9
|
+
# $Id: utils.rb 13771 2007-10-24 23:04:42Z jeg2 $
|
10
|
+
#
|
11
|
+
|
12
|
+
module XMLRPC
|
13
|
+
|
14
|
+
#
|
15
|
+
# This module enables a user-class to be marshalled
|
16
|
+
# by XML-RPC for Ruby into a Hash, with one additional
|
17
|
+
# key/value pair "___class___" => ClassName
|
18
|
+
#
|
19
|
+
module Marshallable
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
module ParserWriterChooseMixin
|
24
|
+
|
25
|
+
def set_writer(writer)
|
26
|
+
@create = Create.new(writer)
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_parser(parser)
|
31
|
+
@parser = parser
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def create
|
38
|
+
# if set_writer was not already called then call it now
|
39
|
+
if @create.nil? then
|
40
|
+
set_writer(Config::DEFAULT_WRITER.new)
|
41
|
+
end
|
42
|
+
@create
|
43
|
+
end
|
44
|
+
|
45
|
+
def parser
|
46
|
+
# if set_parser was not already called then call it now
|
47
|
+
if @parser.nil? then
|
48
|
+
set_parser(Config::DEFAULT_PARSER.new)
|
49
|
+
end
|
50
|
+
@parser
|
51
|
+
end
|
52
|
+
|
53
|
+
end # module ParserWriterChooseMixin
|
54
|
+
|
55
|
+
|
56
|
+
module Service
|
57
|
+
|
58
|
+
#
|
59
|
+
# base class for Service Interface definitions, used
|
60
|
+
# by BasicServer#add_handler
|
61
|
+
#
|
62
|
+
|
63
|
+
class BasicInterface
|
64
|
+
attr_reader :prefix, :methods
|
65
|
+
|
66
|
+
def initialize(prefix)
|
67
|
+
@prefix = prefix
|
68
|
+
@methods = []
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_method(sig, help=nil, meth_name=nil)
|
72
|
+
mname = nil
|
73
|
+
sig = [sig] if sig.kind_of? String
|
74
|
+
|
75
|
+
sig = sig.collect do |s|
|
76
|
+
name, si = parse_sig(s)
|
77
|
+
raise "Wrong signatures!" if mname != nil and name != mname
|
78
|
+
mname = name
|
79
|
+
si
|
80
|
+
end
|
81
|
+
|
82
|
+
@methods << [mname, meth_name || mname, sig, help]
|
83
|
+
end
|
84
|
+
|
85
|
+
private # ---------------------------------
|
86
|
+
|
87
|
+
def parse_sig(sig)
|
88
|
+
# sig is a String
|
89
|
+
if sig =~ /^\s*(\w+)\s+([^(]+)(\(([^)]*)\))?\s*$/
|
90
|
+
params = [$1]
|
91
|
+
name = $2.strip
|
92
|
+
$4.split(",").each {|i| params << i.strip} if $4 != nil
|
93
|
+
return name, params
|
94
|
+
else
|
95
|
+
raise "Syntax error in signature"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end # class BasicInterface
|
100
|
+
|
101
|
+
#
|
102
|
+
# class which wraps a Service Interface definition, used
|
103
|
+
# by BasicServer#add_handler
|
104
|
+
#
|
105
|
+
class Interface < BasicInterface
|
106
|
+
def initialize(prefix, &p)
|
107
|
+
raise "No interface specified" if p.nil?
|
108
|
+
super(prefix)
|
109
|
+
instance_eval(&p)
|
110
|
+
end
|
111
|
+
|
112
|
+
def get_methods(obj, delim=".")
|
113
|
+
prefix = @prefix + delim
|
114
|
+
@methods.collect { |name, meth, sig, help|
|
115
|
+
[prefix + name, obj.method(meth).to_proc, sig, help]
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
private # ---------------------------------
|
120
|
+
|
121
|
+
def meth(*a)
|
122
|
+
add_method(*a)
|
123
|
+
end
|
124
|
+
|
125
|
+
end # class Interface
|
126
|
+
|
127
|
+
class PublicInstanceMethodsInterface < BasicInterface
|
128
|
+
def initialize(prefix)
|
129
|
+
super(prefix)
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_methods(obj, delim=".")
|
133
|
+
prefix = @prefix + delim
|
134
|
+
obj.class.public_instance_methods(false).collect { |name|
|
135
|
+
[prefix + name, obj.method(name).to_proc, nil, nil]
|
136
|
+
}
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
end # module Service
|
142
|
+
|
143
|
+
|
144
|
+
#
|
145
|
+
# short-form to create a Service::Interface
|
146
|
+
#
|
147
|
+
def self.interface(prefix, &p)
|
148
|
+
Service::Interface.new(prefix, &p)
|
149
|
+
end
|
150
|
+
|
151
|
+
# short-cut for creating a PublicInstanceMethodsInterface
|
152
|
+
def self.iPIMethods(prefix)
|
153
|
+
Service::PublicInstanceMethodsInterface.new(prefix)
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
module ParseContentType
|
158
|
+
def parse_content_type(str)
|
159
|
+
a, *b = str.split(";")
|
160
|
+
return a.strip.downcase, *b
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
end # module XMLRPC
|
165
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require './lib/rubysl/xmlrpc/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rubysl-xmlrpc"
|
6
|
+
spec.version = RubySL::XMLRPC::VERSION
|
7
|
+
spec.authors = ["Brian Shirai"]
|
8
|
+
spec.email = ["brixen@gmail.com"]
|
9
|
+
spec.description = %q{Ruby standard library xmlrpc.}
|
10
|
+
spec.summary = %q{Ruby standard library xmlrpc.}
|
11
|
+
spec.homepage = "https://github.com/rubysl/rubysl-xmlrpc"
|
12
|
+
spec.license = "BSD"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "mspec", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubysl-xmlrpc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Shirai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubysl-prettyprint
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
description: Ruby standard library xmlrpc.
|
70
|
+
email:
|
71
|
+
- brixen@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/rubysl/xmlrpc.rb
|
83
|
+
- lib/rubysl/xmlrpc/version.rb
|
84
|
+
- lib/xmlrpc/README.txt
|
85
|
+
- lib/xmlrpc/base64.rb
|
86
|
+
- lib/xmlrpc/client.rb
|
87
|
+
- lib/xmlrpc/config.rb
|
88
|
+
- lib/xmlrpc/create.rb
|
89
|
+
- lib/xmlrpc/datetime.rb
|
90
|
+
- lib/xmlrpc/httpserver.rb
|
91
|
+
- lib/xmlrpc/marshal.rb
|
92
|
+
- lib/xmlrpc/parser.rb
|
93
|
+
- lib/xmlrpc/server.rb
|
94
|
+
- lib/xmlrpc/utils.rb
|
95
|
+
- rubysl-xmlrpc.gemspec
|
96
|
+
homepage: https://github.com/rubysl/rubysl-xmlrpc
|
97
|
+
licenses:
|
98
|
+
- BSD
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.0.7
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Ruby standard library xmlrpc.
|
120
|
+
test_files: []
|