jimson 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -0
- data/VERSION +1 -1
- data/lib/jimson/client.rb +2 -2
- data/spec/client_spec.rb +41 -15
- data/spec/router_spec.rb +1 -1
- data/spec/server_spec.rb +23 -1
- metadata +99 -113
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/lib/jimson/client.rb
CHANGED
@@ -159,11 +159,11 @@ module Jimson
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def method_missing(sym, *args, &block)
|
162
|
-
|
162
|
+
@helper.process_call(sym, args)
|
163
163
|
end
|
164
164
|
|
165
165
|
def [](method, *args)
|
166
|
-
@helper.process_call(method, args
|
166
|
+
@helper.process_call(method, args)
|
167
167
|
end
|
168
168
|
|
169
169
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -24,27 +24,37 @@ module Jimson
|
|
24
24
|
|
25
25
|
describe "#[]" do
|
26
26
|
before(:each) do
|
27
|
-
expected = MultiJson.encode({
|
28
|
-
'jsonrpc' => '2.0',
|
29
|
-
'method' => 'foo',
|
30
|
-
'params' => [1,2,3],
|
31
|
-
'id' => 1
|
32
|
-
})
|
33
|
-
response = MultiJson.encode(BOILERPLATE.merge({'result' => 42}))
|
34
|
-
RestClient.should_receive(:post).with(SPEC_URL, expected, {:content_type => 'application/json'}).and_return(@resp_mock)
|
35
|
-
@resp_mock.should_receive(:body).at_least(:once).and_return(response)
|
36
27
|
@client = Client.new(SPEC_URL)
|
37
28
|
end
|
38
29
|
|
39
|
-
context "when
|
40
|
-
it "sends a request with the correct method and args" do
|
41
|
-
@client['foo', [1,2,3]].should == 42
|
42
|
-
end
|
43
|
-
end
|
44
|
-
context "when using a splat for args" do
|
30
|
+
context "when sending positional arguments" do
|
45
31
|
it "sends a request with the correct method and args" do
|
32
|
+
expected = MultiJson.encode({
|
33
|
+
'jsonrpc' => '2.0',
|
34
|
+
'method' => 'foo',
|
35
|
+
'params' => [1,2,3],
|
36
|
+
'id' => 1
|
37
|
+
})
|
38
|
+
response = MultiJson.encode(BOILERPLATE.merge({'result' => 42}))
|
39
|
+
RestClient.should_receive(:post).with(SPEC_URL, expected, {:content_type => 'application/json'}).and_return(@resp_mock)
|
40
|
+
@resp_mock.should_receive(:body).at_least(:once).and_return(response)
|
46
41
|
@client['foo', 1, 2, 3].should == 42
|
47
42
|
end
|
43
|
+
|
44
|
+
context "when one of the args is an array" do
|
45
|
+
it "sends a request with the correct method and args" do
|
46
|
+
expected = MultiJson.encode({
|
47
|
+
'jsonrpc' => '2.0',
|
48
|
+
'method' => 'foo',
|
49
|
+
'params' => [[1,2],3],
|
50
|
+
'id' => 1
|
51
|
+
})
|
52
|
+
response = MultiJson.encode(BOILERPLATE.merge({'result' => 42}))
|
53
|
+
RestClient.should_receive(:post).with(SPEC_URL, expected, {:content_type => 'application/json'}).and_return(@resp_mock)
|
54
|
+
@resp_mock.should_receive(:body).at_least(:once).and_return(response)
|
55
|
+
@client['foo', [1, 2], 3].should == 42
|
56
|
+
end
|
57
|
+
end
|
48
58
|
end
|
49
59
|
end
|
50
60
|
|
@@ -74,6 +84,22 @@ module Jimson
|
|
74
84
|
client.foo(1,2,3).should == 42
|
75
85
|
end
|
76
86
|
end
|
87
|
+
|
88
|
+
context "when one of the parameters is an array" do
|
89
|
+
it "sends a correct JSON-RPC request (array is preserved) and returns the result" do
|
90
|
+
expected = MultiJson.encode({
|
91
|
+
'jsonrpc' => '2.0',
|
92
|
+
'method' => 'foo',
|
93
|
+
'params' => [[1,2],3],
|
94
|
+
'id' => 1
|
95
|
+
})
|
96
|
+
response = MultiJson.encode(BOILERPLATE.merge({'result' => 42}))
|
97
|
+
RestClient.should_receive(:post).with(SPEC_URL, expected, {:content_type => 'application/json'}).and_return(@resp_mock)
|
98
|
+
@resp_mock.should_receive(:body).at_least(:once).and_return(response)
|
99
|
+
client = Client.new(SPEC_URL)
|
100
|
+
client.foo([1,2],3).should == 42
|
101
|
+
end
|
102
|
+
end
|
77
103
|
end
|
78
104
|
|
79
105
|
describe "sending a batch request" do
|
data/spec/router_spec.rb
CHANGED
data/spec/server_spec.rb
CHANGED
@@ -20,6 +20,10 @@ module Jimson
|
|
20
20
|
a + b + c
|
21
21
|
end
|
22
22
|
|
23
|
+
def car(array)
|
24
|
+
array.first
|
25
|
+
end
|
26
|
+
|
23
27
|
def notify_hello(*args)
|
24
28
|
# notification, doesn't do anything
|
25
29
|
end
|
@@ -96,6 +100,24 @@ module Jimson
|
|
96
100
|
}
|
97
101
|
end
|
98
102
|
|
103
|
+
it "handles an array in the parameters" do
|
104
|
+
req = {
|
105
|
+
'jsonrpc' => '2.0',
|
106
|
+
'method' => 'car',
|
107
|
+
'params' => [['a', 'b']],
|
108
|
+
'id' => 1
|
109
|
+
}
|
110
|
+
post_json(req)
|
111
|
+
|
112
|
+
last_response.should be_ok
|
113
|
+
resp = MultiJson.decode(last_response.body)
|
114
|
+
resp.should == {
|
115
|
+
'jsonrpc' => '2.0',
|
116
|
+
'result' => 'a',
|
117
|
+
'id' => 1
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
99
121
|
it "handles bignums" do
|
100
122
|
req = {
|
101
123
|
'jsonrpc' => '2.0',
|
@@ -368,7 +390,7 @@ module Jimson
|
|
368
390
|
resp = MultiJson.decode(last_response.body)
|
369
391
|
resp['jsonrpc'].should == '2.0'
|
370
392
|
resp['id'].should == 1
|
371
|
-
expected = ['get_data', 'notify_hello', 'subtract', 'sum', 'ugly_method', 'update', 'system.isAlive', 'system.listMethods', 'other.multiply']
|
393
|
+
expected = ['get_data', 'notify_hello', 'subtract', 'sum', 'car', 'ugly_method', 'update', 'system.isAlive', 'system.listMethods', 'other.multiply']
|
372
394
|
(resp['result'] - expected).should == []
|
373
395
|
end
|
374
396
|
end
|
metadata
CHANGED
@@ -1,134 +1,120 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jimson
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.7.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Chris Kite
|
7
|
+
authors:
|
8
|
+
- Chris Kite
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.1.0
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rack
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '1.3'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1.3'
|
12
|
+
|
13
|
+
date: 2012-08-16 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: blankslate
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.2.3
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rest-client
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.6.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: multi_json
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.1.0
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rack
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "1.3"
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id004
|
78
59
|
description:
|
79
60
|
email:
|
80
61
|
executables: []
|
62
|
+
|
81
63
|
extensions: []
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
- lib/jimson
|
92
|
-
- lib/jimson/
|
93
|
-
- lib/jimson/router
|
94
|
-
- lib/jimson/
|
95
|
-
- lib/jimson/
|
96
|
-
- lib/jimson/client.rb
|
97
|
-
- lib/jimson/handler.rb
|
98
|
-
- lib/jimson/
|
99
|
-
- lib/jimson.rb
|
100
|
-
-
|
101
|
-
- spec/
|
102
|
-
- spec/
|
103
|
-
- spec/
|
104
|
-
- spec/
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- README.md
|
67
|
+
files:
|
68
|
+
- VERSION
|
69
|
+
- LICENSE.txt
|
70
|
+
- CHANGELOG.rdoc
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/jimson.rb
|
74
|
+
- lib/jimson/request.rb
|
75
|
+
- lib/jimson/router.rb
|
76
|
+
- lib/jimson/response.rb
|
77
|
+
- lib/jimson/server.rb
|
78
|
+
- lib/jimson/client.rb
|
79
|
+
- lib/jimson/handler.rb
|
80
|
+
- lib/jimson/router/map.rb
|
81
|
+
- lib/jimson/client/error.rb
|
82
|
+
- lib/jimson/server/error.rb
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
- spec/router_spec.rb
|
85
|
+
- spec/client_spec.rb
|
86
|
+
- spec/handler_spec.rb
|
87
|
+
- spec/server_spec.rb
|
105
88
|
homepage: http://www.github.com/chriskite/jimson
|
106
89
|
licenses: []
|
90
|
+
|
107
91
|
post_install_message:
|
108
92
|
rdoc_options: []
|
109
|
-
|
110
|
-
|
111
|
-
|
93
|
+
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
97
|
none: false
|
113
|
-
requirements:
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
103
|
none: false
|
119
|
-
requirements:
|
120
|
-
|
121
|
-
|
122
|
-
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "0"
|
123
108
|
requirements: []
|
109
|
+
|
124
110
|
rubyforge_project:
|
125
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.15
|
126
112
|
signing_key:
|
127
113
|
specification_version: 3
|
128
114
|
summary: JSON-RPC 2.0 client and server
|
129
|
-
test_files:
|
130
|
-
- spec/spec_helper.rb
|
131
|
-
- spec/router_spec.rb
|
132
|
-
- spec/client_spec.rb
|
133
|
-
- spec/handler_spec.rb
|
134
|
-
- spec/server_spec.rb
|
115
|
+
test_files:
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/router_spec.rb
|
118
|
+
- spec/client_spec.rb
|
119
|
+
- spec/handler_spec.rb
|
120
|
+
- spec/server_spec.rb
|