xmlrpc 0.1.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7aa95821386edf84da95f6c97f01a887192d77de
4
- data.tar.gz: dad4e6704d59d87038e6cdf3f409900525c70e94
2
+ SHA256:
3
+ metadata.gz: beb82c31668a9eac6cc5fec044fd06335c42126ce3d4f1f6defda2c987b42ac7
4
+ data.tar.gz: 216663d8c70e048ad6522be02c15e737da9bb4f29ffb268cd65fd8e270d52f15
5
5
  SHA512:
6
- metadata.gz: e8d9be9f7f92cbb4488890d8d5e9d7615f9906fe201822b522ce56f277c57e380b8ceea36a8a97281bf901a63fb8668f728ba1827c5acec5f286dc77b001fbff
7
- data.tar.gz: 080dbd5adb3aa4180a9c11844cd30eb8f27b393f48b41daafaa24f650f3344fc4d4705f8971d53503140c3f4c2e30c0ac9b48bf347f04d5c52b35c11ed2d9c91
6
+ metadata.gz: f2bc2b1c23323a22e37b5cde407ce06440f16d7b4a7ad733aa996616f04524de93e56b4e4deb37a1bf8a7793234011f4bf88141e4146c1aa5940ffb851de272f
7
+ data.tar.gz: 151dc29ed010ce4610c20d6673dea4ce939fdea3bcf287e7eebf728959768c868afe45a0fa8b0c4393754845efe14d0cf7e86b2c1ce046225aee1c8ca123860e
@@ -0,0 +1,36 @@
1
+ name: Test
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+ name: >-
10
+ ${{ matrix.os }} ${{ matrix.ruby }}
11
+ runs-on: ${{ matrix.os }}-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os:
16
+ - ubuntu
17
+ - macos
18
+ - windows
19
+ ruby:
20
+ - "2.5"
21
+ - "2.6"
22
+ - "2.7"
23
+ - "3.0"
24
+ - head
25
+ include:
26
+ - { os: windows , ruby: mingw }
27
+ - { os: windows , ruby: mswin }
28
+ exclude:
29
+ - { os: windows , ruby: head }
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+ - run: bundle install
36
+ - run: rake
data/NEWS.md ADDED
@@ -0,0 +1,39 @@
1
+ # News
2
+
3
+ ## 0.3.2
4
+
5
+ ### Improvements
6
+
7
+ * Added support for Ruby 3.0.
8
+ [GitHub#27][Reported by Herwin Weststrate]
9
+
10
+ ### Thanks
11
+
12
+ * Herwin Weststrate
13
+
14
+ ## 0.3.1
15
+
16
+ ### Improvements
17
+
18
+ * Added support for comparing `XMLRPC::Base64`.
19
+ [GitHub#14][Patch by Herwin Weststrate]
20
+
21
+ * Added support for `application/xml` as `Content-Type`.
22
+ [GitHub#24][Reported by Reiermeyer]
23
+
24
+ * Added `XMLRPC::Server#port`.
25
+ [GitHub#17][Reported by Harald Sitter]
26
+ [GitHub#18][Patch by Herwin Weststrate]
27
+
28
+ ### Fixes
29
+
30
+ * Fixed a bug that unexpected exception is raised on no data.
31
+ [GitHub#25][Patch by Herwin Weststrate]
32
+
33
+ ### Thanks
34
+
35
+ * Herwin Weststrate
36
+
37
+ * Reiermeyer
38
+
39
+ * Harald Sitter
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # XMLRPC
2
2
 
3
+ [![Build Status](https://travis-ci.org/ruby/xmlrpc.svg?branch=master)](https://travis-ci.org/ruby/xmlrpc)
4
+
3
5
  ## Overview
4
6
 
5
7
  XMLRPC is a lightweight protocol that enables remote procedure calls over
data/lib/xmlrpc.rb CHANGED
@@ -289,5 +289,5 @@
289
289
  #
290
290
  # You can change the XML-writer by calling method ParserWriterChooseMixin#set_writer.
291
291
  module XMLRPC
292
- VERSION = "0.1.1"
292
+ VERSION = "0.3.2"
293
293
  end
data/lib/xmlrpc/base64.rb CHANGED
@@ -13,6 +13,7 @@ module XMLRPC # :nodoc:
13
13
  # You can use XMLRPC::Base64 on the client and server-side as a
14
14
  # parameter and/or return-value.
15
15
  class Base64
16
+ include Comparable
16
17
 
17
18
  # Creates a new XMLRPC::Base64 instance with string +str+ as the
18
19
  # internal string. When +state+ is +:dec+ it assumes that the
@@ -40,6 +41,11 @@ class Base64
40
41
  Base64.encode(@str)
41
42
  end
42
43
 
44
+ # Compare two base64 values, based on decoded string
45
+ def <=>(other)
46
+ return nil unless other.is_a?(self.class)
47
+ decoded <=> other.decoded
48
+ end
43
49
 
44
50
  # Decodes string +str+ with base64 and returns that value.
45
51
  def Base64.decode(str)
data/lib/xmlrpc/client.rb CHANGED
@@ -237,7 +237,7 @@ module XMLRPC # :nodoc:
237
237
  # Each parameter of +args+ must be of one of the following types,
238
238
  # where Hash, Struct and Array can contain any of these listed _types_:
239
239
  #
240
- # * Fixnum, Bignum
240
+ # * Integer
241
241
  # * TrueClass, FalseClass, +true+, +false+
242
242
  # * String, Symbol
243
243
  # * Float
@@ -255,7 +255,7 @@ module XMLRPC # :nodoc:
255
255
  #
256
256
  # The type of the return-value is one of the types shown above.
257
257
  #
258
- # A Bignum is only allowed when it fits in 32-bit. A XML-RPC
258
+ # An Integer is only allowed when it fits in 32-bit. A XML-RPC
259
259
  # +dateTime.iso8601+ type is always returned as a XMLRPC::DateTime object.
260
260
  # Struct is never returned, only a Hash, the same for a Symbol, where as a
261
261
  # String is always returned. XMLRPC::Base64 is returned as a String from
@@ -512,16 +512,26 @@ module XMLRPC # :nodoc:
512
512
  # assume text/xml on instances where Content-Type header is not set
513
513
  ct_expected = resp["Content-Type"] || 'text/xml'
514
514
  ct = parse_content_type(ct_expected).first
515
- if ct != "text/xml"
515
+ case ct
516
+ when "text/xml", "application/xml"
517
+ # OK
518
+ else
519
+ message =
520
+ "Wrong content-type " +
521
+ "(received '#{ct}' but expected 'text/xml' or 'application/xml')"
516
522
  if ct == "text/html"
517
- raise "Wrong content-type (received '#{ct}' but expected 'text/xml'): \n#{data}"
523
+ raise "#{message}:\n#{data}"
518
524
  else
519
- raise "Wrong content-type (received '#{ct}' but expected 'text/xml')"
525
+ raise message
520
526
  end
521
527
  end
522
528
 
529
+ if data.nil?
530
+ raise "No data"
531
+ end
532
+
523
533
  expected = resp["Content-Length"] || "<unknown>"
524
- if data.nil? or data.bytesize == 0
534
+ if data.bytesize == 0
525
535
  raise "Wrong size. Was #{data.bytesize}, should be #{expected}"
526
536
  end
527
537
 
data/lib/xmlrpc/create.rb CHANGED
@@ -12,7 +12,7 @@ module XMLRPC # :nodoc:
12
12
 
13
13
  module XMLWriter
14
14
 
15
- class Abstract
15
+ module Element
16
16
  def ele(name, *children)
17
17
  element(name, nil, *children)
18
18
  end
@@ -23,7 +23,8 @@ module XMLRPC # :nodoc:
23
23
  end
24
24
 
25
25
 
26
- class Simple < Abstract
26
+ class Simple
27
+ include Element
27
28
 
28
29
  def document_to_str(doc)
29
30
  doc
@@ -57,7 +58,8 @@ module XMLRPC # :nodoc:
57
58
  end # class Simple
58
59
 
59
60
 
60
- class XMLParser < Abstract
61
+ class XMLParser
62
+ include Element
61
63
 
62
64
  def initialize
63
65
  require "xmltreebuilder"
@@ -176,15 +178,15 @@ module XMLRPC # :nodoc:
176
178
  def conv2value(param) # :doc:
177
179
 
178
180
  val = case param
179
- when Fixnum, Bignum
180
- # XML-RPC's int is 32bit int, and Fixnum also may be beyond 32bit
181
+ when Integer
182
+ # XML-RPC's int is 32bit int
181
183
  if Config::ENABLE_BIGINT
182
184
  @writer.tag("i4", param.to_s)
183
185
  else
184
186
  if param >= -(2**31) and param <= (2**31-1)
185
187
  @writer.tag("i4", param.to_s)
186
188
  else
187
- raise "Bignum is too big! Must be signed 32-bit integer!"
189
+ raise "Integer is too big! Must be signed 32-bit integer!"
188
190
  end
189
191
  end
190
192
  when TrueClass, FalseClass
@@ -219,8 +221,6 @@ module XMLRPC # :nodoc:
219
221
  @writer.ele("struct", *h)
220
222
 
221
223
  when Hash
222
- # TODO: can a Hash be empty?
223
-
224
224
  h = param.collect do |key, value|
225
225
  @writer.ele("member",
226
226
  @writer.tag("name", key.to_s),
@@ -231,7 +231,6 @@ module XMLRPC # :nodoc:
231
231
  @writer.ele("struct", *h)
232
232
 
233
233
  when Array
234
- # TODO: can an Array be empty?
235
234
  a = param.collect {|v| conv2value(v) }
236
235
 
237
236
  @writer.ele("array",
@@ -24,7 +24,7 @@ class DateTime
24
24
  #
25
25
  # Raises ArgumentError if the given +value+ is out of range, or in the case
26
26
  # of XMLRPC::DateTime#year= if +value+ is not of type Integer.
27
- def year= (value)
27
+ def year=(value)
28
28
  raise ArgumentError, "date/time out of range" unless value.is_a? Integer
29
29
  @year = value
30
30
  end
@@ -32,7 +32,7 @@ class DateTime
32
32
  # Set +value+ as the new date/time component.
33
33
  #
34
34
  # Raises an ArgumentError if the given +value+ isn't between 1 and 12.
35
- def month= (value)
35
+ def month=(value)
36
36
  raise ArgumentError, "date/time out of range" unless (1..12).include? value
37
37
  @month = value
38
38
  end
@@ -40,7 +40,7 @@ class DateTime
40
40
  # Set +value+ as the new date/time component.
41
41
  #
42
42
  # Raises an ArgumentError if the given +value+ isn't between 1 and 31.
43
- def day= (value)
43
+ def day=(value)
44
44
  raise ArgumentError, "date/time out of range" unless (1..31).include? value
45
45
  @day = value
46
46
  end
@@ -48,7 +48,7 @@ class DateTime
48
48
  # Set +value+ as the new date/time component.
49
49
  #
50
50
  # Raises an ArgumentError if the given +value+ isn't between 0 and 24.
51
- def hour= (value)
51
+ def hour=(value)
52
52
  raise ArgumentError, "date/time out of range" unless (0..24).include? value
53
53
  @hour = value
54
54
  end
@@ -56,7 +56,7 @@ class DateTime
56
56
  # Set +value+ as the new date/time component.
57
57
  #
58
58
  # Raises an ArgumentError if the given +value+ isn't between 0 and 59.
59
- def min= (value)
59
+ def min=(value)
60
60
  raise ArgumentError, "date/time out of range" unless (0..59).include? value
61
61
  @min = value
62
62
  end
@@ -64,7 +64,7 @@ class DateTime
64
64
  # Set +value+ as the new date/time component.
65
65
  #
66
66
  # Raises an ArgumentError if the given +value+ isn't between 0 and 59.
67
- def sec= (value)
67
+ def sec=(value)
68
68
  raise ArgumentError, "date/time out of range" unless (0..59).include? value
69
69
  @sec = value
70
70
  end
@@ -87,16 +87,10 @@ class DateTime
87
87
  end
88
88
 
89
89
  # Return a Time object of the date/time which represents +self+.
90
- # If the <code>@year</code> is below 1970, this method returns +nil+,
91
- # because Time cannot handle years below 1970.
92
90
  #
93
91
  # The timezone used is GMT.
94
92
  def to_time
95
- if @year >= 1970
96
- Time.gm(*to_a)
97
- else
98
- nil
99
- end
93
+ Time.gm(*to_a)
100
94
  end
101
95
 
102
96
  # Return a Date object of the date which represents +self+.
data/lib/xmlrpc/server.rb CHANGED
@@ -594,6 +594,11 @@ class Server < WEBrickServlet
594
594
  @server.shutdown
595
595
  end
596
596
 
597
+ # Get the port of the server, useful when started with port=0
598
+ def port
599
+ @server.config[:Port]
600
+ end
601
+
597
602
  end
598
603
 
599
604
 
data/xmlrpc.gemspec CHANGED
@@ -6,19 +6,21 @@ require 'xmlrpc'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "xmlrpc"
8
8
  spec.version = XMLRPC::VERSION
9
- spec.authors = ["SHIBATA Hiroshi"]
10
- spec.email = ["hsbt@ruby-lang.org"]
9
+ spec.authors = ["SHIBATA Hiroshi", "Sutou Kouhei"]
10
+ spec.email = ["hsbt@ruby-lang.org", "kou@cozmixng.org"]
11
11
 
12
12
  spec.summary = %q{XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP.}
13
13
  spec.description = %q{XMLRPC is a lightweight protocol that enables remote procedure calls over HTTP.}
14
14
  spec.homepage = "https://github.com/ruby/xmlrpc"
15
- spec.license = "Ruby"
15
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
- spec.required_ruby_version = ">= 2.4.0dev"
21
+ spec.required_ruby_version = ">= 2.3"
22
+
23
+ spec.add_dependency "webrick"
22
24
 
23
25
  spec.add_development_dependency "bundler"
24
26
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,15 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmlrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIBATA Hiroshi
8
+ - Sutou Kouhei
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
12
+ date: 2021-02-04 00:00:00.000000000 Z
12
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: webrick
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
13
28
  - !ruby/object:Gem::Dependency
14
29
  name: bundler
15
30
  requirement: !ruby/object:Gem::Requirement
@@ -56,14 +71,16 @@ description: XMLRPC is a lightweight protocol that enables remote procedure call
56
71
  over HTTP.
57
72
  email:
58
73
  - hsbt@ruby-lang.org
74
+ - kou@cozmixng.org
59
75
  executables: []
60
76
  extensions: []
61
77
  extra_rdoc_files: []
62
78
  files:
79
+ - ".github/workflows/test.yml"
63
80
  - ".gitignore"
64
- - ".travis.yml"
65
81
  - Gemfile
66
82
  - LICENSE.txt
83
+ - NEWS.md
67
84
  - README.md
68
85
  - Rakefile
69
86
  - bin/console
@@ -82,6 +99,7 @@ files:
82
99
  homepage: https://github.com/ruby/xmlrpc
83
100
  licenses:
84
101
  - Ruby
102
+ - BSD-2-Clause
85
103
  metadata: {}
86
104
  post_install_message:
87
105
  rdoc_options: []
@@ -91,15 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
109
  requirements:
92
110
  - - ">="
93
111
  - !ruby/object:Gem::Version
94
- version: 2.4.0dev
112
+ version: '2.3'
95
113
  required_rubygems_version: !ruby/object:Gem::Requirement
96
114
  requirements:
97
115
  - - ">="
98
116
  - !ruby/object:Gem::Version
99
117
  version: '0'
100
118
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.6.4
119
+ rubygems_version: 3.3.0.dev
103
120
  signing_key:
104
121
  specification_version: 4
105
122
  summary: XMLRPC is a lightweight protocol that enables remote procedure calls over
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - ruby-head
4
- before_install: gem install bundler -v 1.11.2