jsonrpc2.0 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/jsonrpc2.0.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jsonrpc2.0'
3
- s.version = '0.1.7'
3
+ s.version = '0.1.8'
4
4
  s.summary = 'A server and client implementation of the JsonRpc 2.0 protocol.'
5
5
  s.authors = ['Jannik Theiß']
6
6
  s.email = 'dev@coldsun.org'
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  module JsonRpcErrors
4
- ERRORS = {'ParseError' => -32700, 'InvalidRequest' => -32600, 'MethodNotFound' => -32601, 'InvalidParams' => -32602, 'InternalError' => -32603, 'MethodNotAllowed' => -32099}
4
+ ERRORS = {'ParseError' => -32700, 'InvalidRequest' => -32600, 'MethodNotFound' => -32601, 'InvalidParams' => -32602, 'InternalError' => -32603}
5
5
 
6
6
  class Error < StandardError
7
7
  CODE = nil
@@ -31,10 +31,14 @@ module JsonRpcErrors
31
31
  c.new(inHash['message'], inHash['data'])
32
32
  end
33
33
 
34
- ERRORS.each do |className, errorCode|
35
- c = Class::new(Error) do
36
- const_set('CODE', errorCode)
34
+ def self.addErrors(errors)
35
+ errors.each do |className, errorCode|
36
+ c = Class::new(Error) do
37
+ const_set('CODE', errorCode)
38
+ end
39
+ const_set(className, c)
37
40
  end
38
- const_set(className, c)
39
41
  end
42
+
43
+ addErrors(ERRORS)
40
44
  end
@@ -6,7 +6,7 @@ class JsonRpcServer
6
6
  include JsonRpcConstants
7
7
  include JsonRpcErrors
8
8
 
9
- def handle_message(inMessage, restrictMethod = nil)
9
+ def handle_message(inMessage)
10
10
  begin
11
11
  begin
12
12
  message = JSON.parse inMessage
@@ -14,7 +14,7 @@ class JsonRpcServer
14
14
  raise(ParseError, e.message)
15
15
  end
16
16
 
17
- response = handle_request(message, restrictMethod).to_json
17
+ response = handle_request(message).to_json
18
18
  rescue Error => e
19
19
  id = nil
20
20
  id = message['id'] if (message.class == Hash)
@@ -29,17 +29,13 @@ class JsonRpcServer
29
29
 
30
30
  private
31
31
 
32
- def handle_request(inRequest, restrictMethod = nil)
32
+ def handle_request(inRequest)
33
33
  raise InvalidRequest if (inRequest.class != Hash)
34
34
  raise InvalidRequest if (inRequest['jsonrpc'] != VERSION)
35
35
  raise InvalidRequest if (!inRequest.key?('method'))
36
36
 
37
37
  begin
38
- methodName = 'r_' + inRequest['method']
39
-
40
- unless restrictMethod == nil or restrictMethod == methodName
41
- raise(MethodNotAllowed, "Method not allowed!")
42
- end
38
+ methodName = 'r_' + inRequest['method']
43
39
 
44
40
  method = method(methodName)
45
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonrpc2.0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-27 00:00:00.000000000Z
12
+ date: 2011-06-28 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: dev@coldsun.org