xmlrpc 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +56 -0
- data/README.md +58 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/xmlrpc.rb +293 -0
- data/lib/xmlrpc/base64.rb +63 -0
- data/lib/xmlrpc/client.rb +629 -0
- data/lib/xmlrpc/config.rb +39 -0
- data/lib/xmlrpc/create.rb +287 -0
- data/lib/xmlrpc/datetime.rb +130 -0
- data/lib/xmlrpc/marshal.rb +67 -0
- data/lib/xmlrpc/parser.rb +642 -0
- data/lib/xmlrpc/server.rb +708 -0
- data/lib/xmlrpc/utils.rb +172 -0
- data/xmlrpc.gemspec +26 -0
- metadata +107 -0
data/lib/xmlrpc/utils.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
|
4
|
+
#
|
5
|
+
# $Id$
|
6
|
+
#
|
7
|
+
module XMLRPC # :nodoc:
|
8
|
+
|
9
|
+
|
10
|
+
# This module enables a user-class to be marshalled
|
11
|
+
# by XML-RPC for Ruby into a Hash, with one additional
|
12
|
+
# key/value pair <code>___class___ => ClassName</code>
|
13
|
+
#
|
14
|
+
module Marshallable
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# Defines ParserWriterChooseMixin, which makes it possible to choose a
|
19
|
+
# different XMLWriter and/or XMLParser then the default one.
|
20
|
+
#
|
21
|
+
# The Mixin is used in client.rb (class XMLRPC::Client)
|
22
|
+
# and server.rb (class XMLRPC::BasicServer)
|
23
|
+
module ParserWriterChooseMixin
|
24
|
+
|
25
|
+
# Sets the XMLWriter to use for generating XML output.
|
26
|
+
#
|
27
|
+
# Should be an instance of a class from module XMLRPC::XMLWriter.
|
28
|
+
#
|
29
|
+
# If this method is not called, then XMLRPC::Config::DEFAULT_WRITER is used.
|
30
|
+
def set_writer(writer)
|
31
|
+
@create = Create.new(writer)
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sets the XMLParser to use for parsing XML documents.
|
36
|
+
#
|
37
|
+
# Should be an instance of a class from module XMLRPC::XMLParser.
|
38
|
+
#
|
39
|
+
# If this method is not called, then XMLRPC::Config::DEFAULT_PARSER is used.
|
40
|
+
def set_parser(parser)
|
41
|
+
@parser = parser
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def create
|
48
|
+
# if set_writer was not already called then call it now
|
49
|
+
if @create.nil? then
|
50
|
+
set_writer(Config::DEFAULT_WRITER.new)
|
51
|
+
end
|
52
|
+
@create
|
53
|
+
end
|
54
|
+
|
55
|
+
def parser
|
56
|
+
# if set_parser was not already called then call it now
|
57
|
+
if @parser.nil? then
|
58
|
+
set_parser(Config::DEFAULT_PARSER.new)
|
59
|
+
end
|
60
|
+
@parser
|
61
|
+
end
|
62
|
+
|
63
|
+
end # module ParserWriterChooseMixin
|
64
|
+
|
65
|
+
|
66
|
+
module Service
|
67
|
+
|
68
|
+
# Base class for XMLRPC::Service::Interface definitions, used
|
69
|
+
# by XMLRPC::BasicServer#add_handler
|
70
|
+
class BasicInterface
|
71
|
+
attr_reader :prefix, :methods
|
72
|
+
|
73
|
+
def initialize(prefix)
|
74
|
+
@prefix = prefix
|
75
|
+
@methods = []
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_method(sig, help=nil, meth_name=nil)
|
79
|
+
mname = nil
|
80
|
+
sig = [sig] if sig.kind_of? String
|
81
|
+
|
82
|
+
sig = sig.collect do |s|
|
83
|
+
name, si = parse_sig(s)
|
84
|
+
raise "Wrong signatures!" if mname != nil and name != mname
|
85
|
+
mname = name
|
86
|
+
si
|
87
|
+
end
|
88
|
+
|
89
|
+
@methods << [mname, meth_name || mname, sig, help]
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def parse_sig(sig)
|
95
|
+
# sig is a String
|
96
|
+
if sig =~ /^\s*(\w+)\s+([^(]+)(\(([^)]*)\))?\s*$/
|
97
|
+
params = [$1]
|
98
|
+
name = $2.strip
|
99
|
+
$4.split(",").each {|i| params << i.strip} if $4 != nil
|
100
|
+
return name, params
|
101
|
+
else
|
102
|
+
raise "Syntax error in signature"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end # class BasicInterface
|
107
|
+
|
108
|
+
#
|
109
|
+
# Class which wraps a XMLRPC::Service::Interface definition, used
|
110
|
+
# by XMLRPC::BasicServer#add_handler
|
111
|
+
#
|
112
|
+
class Interface < BasicInterface
|
113
|
+
def initialize(prefix, &p)
|
114
|
+
raise "No interface specified" if p.nil?
|
115
|
+
super(prefix)
|
116
|
+
instance_eval(&p)
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_methods(obj, delim=".")
|
120
|
+
prefix = @prefix + delim
|
121
|
+
@methods.collect { |name, meth, sig, help|
|
122
|
+
[prefix + name.to_s, obj.method(meth).to_proc, sig, help]
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def meth(*a)
|
129
|
+
add_method(*a)
|
130
|
+
end
|
131
|
+
|
132
|
+
end # class Interface
|
133
|
+
|
134
|
+
class PublicInstanceMethodsInterface < BasicInterface
|
135
|
+
def initialize(prefix)
|
136
|
+
super(prefix)
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_methods(obj, delim=".")
|
140
|
+
prefix = @prefix + delim
|
141
|
+
obj.class.public_instance_methods(false).collect { |name|
|
142
|
+
[prefix + name.to_s, obj.method(name).to_proc, nil, nil]
|
143
|
+
}
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
end # module Service
|
149
|
+
|
150
|
+
|
151
|
+
#
|
152
|
+
# Short-form to create a XMLRPC::Service::Interface
|
153
|
+
#
|
154
|
+
def self.interface(prefix, &p)
|
155
|
+
Service::Interface.new(prefix, &p)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Short-cut for creating a XMLRPC::Service::PublicInstanceMethodsInterface
|
159
|
+
def self.iPIMethods(prefix)
|
160
|
+
Service::PublicInstanceMethodsInterface.new(prefix)
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
module ParseContentType
|
165
|
+
def parse_content_type(str)
|
166
|
+
a, *b = str.split(";")
|
167
|
+
return a.strip.downcase, *b
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end # module XMLRPC
|
172
|
+
|
data/xmlrpc.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xmlrpc'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xmlrpc"
|
8
|
+
spec.version = XMLRPC::VERSION
|
9
|
+
spec.authors = ["SHIBATA Hiroshi"]
|
10
|
+
spec.email = ["hsbt@ruby-lang.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP.}
|
13
|
+
spec.description = %q{XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP.}
|
14
|
+
spec.homepage = "https://github.com/ruby/xmlrpc"
|
15
|
+
spec.license = "Ruby"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.required_ruby_version = ">= 2.4.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "test-unit"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xmlrpc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SHIBATA Hiroshi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-15 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: XMLRPC is a lightweight protocol that enables remote procedure calls
|
56
|
+
over HTTP.
|
57
|
+
email:
|
58
|
+
- hsbt@ruby-lang.org
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/xmlrpc.rb
|
72
|
+
- lib/xmlrpc/base64.rb
|
73
|
+
- lib/xmlrpc/client.rb
|
74
|
+
- lib/xmlrpc/config.rb
|
75
|
+
- lib/xmlrpc/create.rb
|
76
|
+
- lib/xmlrpc/datetime.rb
|
77
|
+
- lib/xmlrpc/marshal.rb
|
78
|
+
- lib/xmlrpc/parser.rb
|
79
|
+
- lib/xmlrpc/server.rb
|
80
|
+
- lib/xmlrpc/utils.rb
|
81
|
+
- xmlrpc.gemspec
|
82
|
+
homepage: https://github.com/ruby/xmlrpc
|
83
|
+
licenses:
|
84
|
+
- Ruby
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.4.0
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.6.4
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: XMLRPC is a lightweight protocol that enables remote procedure calls over
|
106
|
+
HTTP.
|
107
|
+
test_files: []
|