krpc 0.2.2 → 0.3.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 +4 -4
- data/CHANGELOG.md +7 -1
- data/krpc.gemspec +5 -5
- data/lib/krpc.rb +1 -0
- data/lib/krpc/client.rb +3 -4
- data/lib/krpc/connection.rb +3 -1
- data/lib/krpc/decoder.rb +1 -3
- data/lib/krpc/encoder.rb +26 -18
- data/lib/krpc/gen.rb +3 -3
- data/lib/krpc/krpc.pb.rb +128 -0
- data/lib/krpc/protobuf_extensions.rb +20 -0
- data/lib/krpc/protobuf_utils.rb +4 -5
- data/lib/krpc/streaming.rb +1 -1
- data/lib/krpc/types.rb +0 -1
- data/lib/krpc/version.rb +1 -1
- metadata +21 -26
- data/lib/krpc/KRPC.pb.rb +0 -124
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4fe29f9b4d79df0423649f00f97a4f0635e34b55
|
|
4
|
+
data.tar.gz: 46a7add0e30b35ec3b33ba61b0f023052e97de9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9f121f1a6d61dbf3e441124beee9eb83c7ae8303a15e342d723628c5bd6a7e5da28937e20506a7d99eced2c605e6b89c949e6ea0ccf7a1e97fb35a8240915c0
|
|
7
|
+
data.tar.gz: b79787bda276c3fb9332a97f9b8391de2a1e37df6e90494d8f7be28841014e45bfeeb5da6a60cdbe7922726d60880de3773ab0dc873935229ff75f5ac44daf4c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
v0.3.0 (15 Feb 2016)
|
|
2
|
+
========
|
|
3
|
+
+ **Updated to work with kRPC server version 0.2.x** (#6):
|
|
4
|
+
+ Using *google-protobuf* gem instead of *ruby_protobuf*, for protocol buffers version 3
|
|
5
|
+
+ Turned development dependency on *hanna-nouveau* into runtime dependency (Fix #5)
|
|
1
6
|
|
|
2
7
|
v0.2.2 (30 Oct 2015)
|
|
3
8
|
========
|
|
4
|
-
+ Static methods now require KRPC::Client instance as first argument
|
|
9
|
+
+ Static methods now require `KRPC::Client` instance as first argument (Fix #4)
|
|
5
10
|
+ Improved parameters default value handling
|
|
11
|
+
+ Improved collections encoding
|
|
6
12
|
+ Fixed few minor bugs
|
|
7
13
|
|
|
8
14
|
v0.2.0 (26 Sep 2015)
|
data/krpc.gemspec
CHANGED
|
@@ -23,13 +23,13 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
"--title" << "kRPC-rb API Docs" <<
|
|
24
24
|
"--main" << "README.md"
|
|
25
25
|
|
|
26
|
-
s.required_ruby_version =
|
|
26
|
+
s.required_ruby_version = ">= 2.1.0"
|
|
27
27
|
|
|
28
|
-
s.add_runtime_dependency "
|
|
28
|
+
s.add_runtime_dependency "google-protobuf", "~> 3.0.0.alpha.5"
|
|
29
29
|
s.add_runtime_dependency "colorize", "~> 0.7"
|
|
30
30
|
s.add_runtime_dependency "nokogiri", "~> 1.6"
|
|
31
|
-
s.
|
|
31
|
+
s.add_runtime_dependency "hanna-nouveau", "~> 0.4"
|
|
32
|
+
s.add_development_dependency "bundler", "~> 1.11"
|
|
32
33
|
s.add_development_dependency "pry", "~> 0.10"
|
|
33
|
-
s.add_development_dependency "rspec", "~> 3.
|
|
34
|
-
s.add_development_dependency "hanna-nouveau", "~> 0.4"
|
|
34
|
+
s.add_development_dependency "rspec", "~> 3.4"
|
|
35
35
|
end
|
data/lib/krpc.rb
CHANGED
data/lib/krpc/client.rb
CHANGED
|
@@ -6,7 +6,7 @@ require 'krpc/decoder'
|
|
|
6
6
|
require 'krpc/streaming'
|
|
7
7
|
require 'krpc/error'
|
|
8
8
|
require 'krpc/core_extensions'
|
|
9
|
-
require 'krpc/
|
|
9
|
+
require 'krpc/krpc.pb'
|
|
10
10
|
|
|
11
11
|
module KRPC
|
|
12
12
|
|
|
@@ -133,7 +133,7 @@ module KRPC
|
|
|
133
133
|
def execute_rpc(service, procedure, args=[], kwargs={}, param_names=[], param_types=[], param_default=[], return_type: nil)
|
|
134
134
|
send_request(service, procedure, args, kwargs, param_names, param_types, param_default)
|
|
135
135
|
resp = receive_response
|
|
136
|
-
raise(RPCError, resp.error) if resp.
|
|
136
|
+
raise(RPCError, resp.error) if resp.has_error
|
|
137
137
|
unless return_type.nil?
|
|
138
138
|
Decoder.decode(resp.return_value, return_type, self)
|
|
139
139
|
else
|
|
@@ -202,8 +202,7 @@ module KRPC
|
|
|
202
202
|
def receive_response
|
|
203
203
|
resp_length = rpc_connection.recv_varint
|
|
204
204
|
resp_data = rpc_connection.recv resp_length
|
|
205
|
-
resp = PB::Response.
|
|
206
|
-
resp.parse_from_string resp_data
|
|
205
|
+
resp = PB::Response.decode(resp_data)
|
|
207
206
|
end
|
|
208
207
|
|
|
209
208
|
def call_block_and_close(block)
|
data/lib/krpc/connection.rb
CHANGED
data/lib/krpc/decoder.rb
CHANGED
data/lib/krpc/encoder.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'krpc/protobuf_utils'
|
|
2
|
+
require 'krpc/types'
|
|
2
3
|
|
|
3
4
|
module KRPC
|
|
4
5
|
module Encoder
|
|
@@ -10,7 +11,7 @@ module KRPC
|
|
|
10
11
|
|
|
11
12
|
# Given a type object, and ruby object, encode the ruby object
|
|
12
13
|
def encode(obj, type)
|
|
13
|
-
if type.is_a?(Types::MessageType) then obj
|
|
14
|
+
if type.is_a?(Types::MessageType) then type.ruby_type.encode(obj)
|
|
14
15
|
elsif type.is_a?(Types::ValueType) then encode_value(obj, type)
|
|
15
16
|
elsif type.is_a?(Types::EnumType)
|
|
16
17
|
enum_value = type.ruby_type[obj]
|
|
@@ -19,27 +20,34 @@ module KRPC
|
|
|
19
20
|
remote_oid = if obj == nil then 0 else obj.remote_oid end
|
|
20
21
|
encode_value(remote_oid, TypeStore["uint64"])
|
|
21
22
|
elsif type.is_a?(Types::ListType)
|
|
22
|
-
|
|
23
|
-
msg
|
|
24
|
-
|
|
23
|
+
ruby_type = TypeStore["KRPC.List"].ruby_type
|
|
24
|
+
msg = ruby_type.new(
|
|
25
|
+
items: obj.map{|x| encode(TypeStore.coerce_to(x, type.value_type), type.value_type)}.to_a
|
|
26
|
+
)
|
|
27
|
+
ruby_type.encode(msg)
|
|
25
28
|
elsif type.is_a?(Types::DictionaryType)
|
|
29
|
+
ruby_type = TypeStore["KRPC.Dictionary"].ruby_type
|
|
26
30
|
entry_type = TypeStore["KRPC.DictionaryEntry"].ruby_type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
entry
|
|
31
|
+
entries = obj.map do |k,v|
|
|
32
|
+
entry_type.new(
|
|
33
|
+
key: encode(TypeStore.coerce_to(k, type.key_type), type.key_type),
|
|
34
|
+
value: encode(TypeStore.coerce_to(v, type.value_type), type.value_type)
|
|
35
|
+
)
|
|
33
36
|
end
|
|
34
|
-
msg.
|
|
37
|
+
msg = ruby_type.new(entries: entries)
|
|
38
|
+
ruby_type.encode(msg)
|
|
35
39
|
elsif type.is_a?(Types::SetType)
|
|
36
|
-
|
|
37
|
-
msg
|
|
38
|
-
|
|
40
|
+
ruby_type = TypeStore["KRPC.Set"].ruby_type
|
|
41
|
+
msg = ruby_type.new(
|
|
42
|
+
items: obj.map{|x| encode( TypeStore.coerce_to(x, type.value_type), type.value_type )}.to_a
|
|
43
|
+
)
|
|
44
|
+
ruby_type.encode(msg)
|
|
39
45
|
elsif type.is_a?(Types::TupleType)
|
|
40
|
-
|
|
41
|
-
msg
|
|
42
|
-
|
|
46
|
+
ruby_type = TypeStore["KRPC.Tuple"].ruby_type
|
|
47
|
+
msg = ruby_type.new(
|
|
48
|
+
items: obj.zip(type.value_types).map{|x,t| encode( TypeStore.coerce_to(x, t), t )}.to_a
|
|
49
|
+
)
|
|
50
|
+
ruby_type.encode(msg)
|
|
43
51
|
else raise(RuntimeError, "Cannot encode object #{obj} of type #{type}")
|
|
44
52
|
end
|
|
45
53
|
end
|
|
@@ -49,7 +57,7 @@ module KRPC
|
|
|
49
57
|
end
|
|
50
58
|
|
|
51
59
|
def encode_request(req)
|
|
52
|
-
data = req
|
|
60
|
+
data = PB::Request.encode(req)
|
|
53
61
|
length = ProtobufUtils::Encoder.encode_nonnegative_varint(data.length)
|
|
54
62
|
length + data
|
|
55
63
|
end
|
data/lib/krpc/gen.rb
CHANGED
|
@@ -97,12 +97,12 @@ module KRPC
|
|
|
97
97
|
TypeStore.get_parameter_type(i, p.type, proc.attributes)
|
|
98
98
|
end
|
|
99
99
|
param_default = proc.parameters.zip(param_types).map do |param, type|
|
|
100
|
-
if param.
|
|
100
|
+
if param.has_default_argument
|
|
101
101
|
Decoder.decode(param.default_argument, type, :clientless)
|
|
102
102
|
else :no_default_value
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
|
-
return_type = if proc.
|
|
105
|
+
return_type = if proc.has_return_type
|
|
106
106
|
TypeStore.get_return_type(proc.return_type, proc.attributes)
|
|
107
107
|
else nil end
|
|
108
108
|
[param_names, param_types, param_default, return_type]
|
|
@@ -111,7 +111,7 @@ module KRPC
|
|
|
111
111
|
|
|
112
112
|
module RPCMethodGenerator
|
|
113
113
|
def include_rpc_method(method_name, service_name, procedure_name, params: [], return_type: nil, xmldoc: "", options: [])
|
|
114
|
-
Gen.add_rpc_method(self.class, method_name, service_name, PB::Procedure.new(name: procedure_name, parameters: params, return_type: return_type, documentation: xmldoc), options)
|
|
114
|
+
Gen.add_rpc_method(self.class, method_name, service_name, PB::Procedure.new(name: procedure_name, parameters: params, has_return_type: return_type != nil, return_type: return_type != nil ? return_type : "", documentation: xmldoc), options)
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
data/lib/krpc/krpc.pb.rb
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# source: krpc.proto
|
|
3
|
+
|
|
4
|
+
require 'google/protobuf'
|
|
5
|
+
|
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
7
|
+
add_message "krpc.schema.Request" do
|
|
8
|
+
optional :service, :string, 1
|
|
9
|
+
optional :procedure, :string, 2
|
|
10
|
+
repeated :arguments, :message, 3, "krpc.schema.Argument"
|
|
11
|
+
end
|
|
12
|
+
add_message "krpc.schema.Argument" do
|
|
13
|
+
optional :position, :uint32, 1
|
|
14
|
+
optional :value, :bytes, 2
|
|
15
|
+
end
|
|
16
|
+
add_message "krpc.schema.Response" do
|
|
17
|
+
optional :time, :double, 1
|
|
18
|
+
optional :has_error, :bool, 2
|
|
19
|
+
optional :error, :string, 3
|
|
20
|
+
optional :has_return_value, :bool, 4
|
|
21
|
+
optional :return_value, :bytes, 5
|
|
22
|
+
end
|
|
23
|
+
add_message "krpc.schema.StreamMessage" do
|
|
24
|
+
repeated :responses, :message, 1, "krpc.schema.StreamResponse"
|
|
25
|
+
end
|
|
26
|
+
add_message "krpc.schema.StreamResponse" do
|
|
27
|
+
optional :id, :uint32, 1
|
|
28
|
+
optional :response, :message, 2, "krpc.schema.Response"
|
|
29
|
+
end
|
|
30
|
+
add_message "krpc.schema.Services" do
|
|
31
|
+
repeated :services, :message, 1, "krpc.schema.Service"
|
|
32
|
+
end
|
|
33
|
+
add_message "krpc.schema.Service" do
|
|
34
|
+
optional :name, :string, 1
|
|
35
|
+
repeated :procedures, :message, 2, "krpc.schema.Procedure"
|
|
36
|
+
repeated :classes, :message, 3, "krpc.schema.Class"
|
|
37
|
+
repeated :enumerations, :message, 4, "krpc.schema.Enumeration"
|
|
38
|
+
optional :documentation, :string, 5
|
|
39
|
+
end
|
|
40
|
+
add_message "krpc.schema.Procedure" do
|
|
41
|
+
optional :name, :string, 1
|
|
42
|
+
repeated :parameters, :message, 2, "krpc.schema.Parameter"
|
|
43
|
+
optional :has_return_type, :bool, 3
|
|
44
|
+
optional :return_type, :string, 4
|
|
45
|
+
repeated :attributes, :string, 5
|
|
46
|
+
optional :documentation, :string, 6
|
|
47
|
+
end
|
|
48
|
+
add_message "krpc.schema.Parameter" do
|
|
49
|
+
optional :name, :string, 1
|
|
50
|
+
optional :type, :string, 2
|
|
51
|
+
optional :has_default_argument, :bool, 3
|
|
52
|
+
optional :default_argument, :bytes, 4
|
|
53
|
+
end
|
|
54
|
+
add_message "krpc.schema.Class" do
|
|
55
|
+
optional :name, :string, 1
|
|
56
|
+
optional :documentation, :string, 2
|
|
57
|
+
end
|
|
58
|
+
add_message "krpc.schema.Enumeration" do
|
|
59
|
+
optional :name, :string, 1
|
|
60
|
+
repeated :values, :message, 2, "krpc.schema.EnumerationValue"
|
|
61
|
+
optional :documentation, :string, 3
|
|
62
|
+
end
|
|
63
|
+
add_message "krpc.schema.EnumerationValue" do
|
|
64
|
+
optional :name, :string, 1
|
|
65
|
+
optional :value, :int32, 2
|
|
66
|
+
optional :documentation, :string, 3
|
|
67
|
+
end
|
|
68
|
+
add_message "krpc.schema.List" do
|
|
69
|
+
repeated :items, :bytes, 1
|
|
70
|
+
end
|
|
71
|
+
add_message "krpc.schema.Dictionary" do
|
|
72
|
+
repeated :entries, :message, 1, "krpc.schema.DictionaryEntry"
|
|
73
|
+
end
|
|
74
|
+
add_message "krpc.schema.DictionaryEntry" do
|
|
75
|
+
optional :key, :bytes, 1
|
|
76
|
+
optional :value, :bytes, 2
|
|
77
|
+
end
|
|
78
|
+
add_message "krpc.schema.Set" do
|
|
79
|
+
repeated :items, :bytes, 1
|
|
80
|
+
end
|
|
81
|
+
add_message "krpc.schema.Tuple" do
|
|
82
|
+
repeated :items, :bytes, 1
|
|
83
|
+
end
|
|
84
|
+
add_message "krpc.schema.Status" do
|
|
85
|
+
optional :version, :string, 1
|
|
86
|
+
optional :bytes_read, :uint64, 2
|
|
87
|
+
optional :bytes_written, :uint64, 3
|
|
88
|
+
optional :bytes_read_rate, :float, 4
|
|
89
|
+
optional :bytes_written_rate, :float, 5
|
|
90
|
+
optional :rpcs_executed, :uint64, 6
|
|
91
|
+
optional :rpc_rate, :float, 7
|
|
92
|
+
optional :one_rpc_per_update, :bool, 8
|
|
93
|
+
optional :max_time_per_update, :uint32, 9
|
|
94
|
+
optional :adaptive_rate_control, :bool, 10
|
|
95
|
+
optional :blocking_recv, :bool, 11
|
|
96
|
+
optional :recv_timeout, :uint32, 12
|
|
97
|
+
optional :time_per_rpc_update, :float, 13
|
|
98
|
+
optional :poll_time_per_rpc_update, :float, 14
|
|
99
|
+
optional :exec_time_per_rpc_update, :float, 15
|
|
100
|
+
optional :stream_rpcs, :uint32, 16
|
|
101
|
+
optional :stream_rpcs_executed, :uint64, 17
|
|
102
|
+
optional :stream_rpc_rate, :float, 18
|
|
103
|
+
optional :time_per_stream_update, :float, 19
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
module KRPC
|
|
108
|
+
module PB
|
|
109
|
+
Request = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Request").msgclass
|
|
110
|
+
Argument = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Argument").msgclass
|
|
111
|
+
Response = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Response").msgclass
|
|
112
|
+
StreamMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.StreamMessage").msgclass
|
|
113
|
+
StreamResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.StreamResponse").msgclass
|
|
114
|
+
Services = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Services").msgclass
|
|
115
|
+
Service = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Service").msgclass
|
|
116
|
+
Procedure = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Procedure").msgclass
|
|
117
|
+
Parameter = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Parameter").msgclass
|
|
118
|
+
Class = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Class").msgclass
|
|
119
|
+
Enumeration = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Enumeration").msgclass
|
|
120
|
+
EnumerationValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.EnumerationValue").msgclass
|
|
121
|
+
List = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.List").msgclass
|
|
122
|
+
Dictionary = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Dictionary").msgclass
|
|
123
|
+
DictionaryEntry = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.DictionaryEntry").msgclass
|
|
124
|
+
Set = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Set").msgclass
|
|
125
|
+
Tuple = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Tuple").msgclass
|
|
126
|
+
Status = Google::Protobuf::DescriptorPool.generated_pool.lookup("krpc.schema.Status").msgclass
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'krpc/krpc.pb'
|
|
2
|
+
|
|
3
|
+
module KRPC
|
|
4
|
+
module ProtobufExtensions
|
|
5
|
+
|
|
6
|
+
module MessageExtensions
|
|
7
|
+
def ==(other)
|
|
8
|
+
super
|
|
9
|
+
rescue TypeError
|
|
10
|
+
false
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
KRPC::PB.constants(false).map {|const_name| KRPC::PB.const_get(const_name,true)}.each do |msgclass|
|
|
18
|
+
msgclass.prepend KRPC::ProtobufExtensions::MessageExtensions
|
|
19
|
+
end
|
|
20
|
+
|
data/lib/krpc/protobuf_utils.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
require 'krpc/
|
|
1
|
+
require 'krpc/krpc.pb'
|
|
2
2
|
|
|
3
3
|
module KRPC
|
|
4
4
|
module ProtobufUtils
|
|
5
5
|
class << self
|
|
6
6
|
def create_PB_to_PB_message_class_hash(package)
|
|
7
7
|
protobuf_module = Kernel.const_get(package.gsub(".","::") + "::PB")
|
|
8
|
-
|
|
9
|
-
msg_classes_names.map do |name|
|
|
8
|
+
protobuf_module.constants.map do |name|
|
|
10
9
|
[package + "." + name.to_s, protobuf_module.const_get(name,false)]
|
|
11
10
|
end.to_h
|
|
12
11
|
end
|
|
@@ -60,11 +59,11 @@ module KRPC
|
|
|
60
59
|
end
|
|
61
60
|
def decode_string(bytes)
|
|
62
61
|
size, pos = decode_varint_pos(bytes)
|
|
63
|
-
bytes[pos..(pos+size)]
|
|
62
|
+
bytes[pos..(pos+size)].force_encoding(Encoding::UTF_8)
|
|
64
63
|
end
|
|
65
64
|
def decode_bytes(bytes)
|
|
66
65
|
size, pos = decode_varint_pos(bytes)
|
|
67
|
-
bytes[pos..(pos+size)]
|
|
66
|
+
bytes[pos..(pos+size)].bytes
|
|
68
67
|
end
|
|
69
68
|
|
|
70
69
|
end
|
data/lib/krpc/streaming.rb
CHANGED
|
@@ -62,7 +62,7 @@ module KRPC
|
|
|
62
62
|
stream_msg.responses.each do |stream_resp|
|
|
63
63
|
next unless @streams.include? stream_resp.id
|
|
64
64
|
stream = @streams[stream_resp.id]
|
|
65
|
-
if stream_resp.response.
|
|
65
|
+
if stream_resp.response.has_error
|
|
66
66
|
stream.value = RPCError.new(stream_resp.response.error)
|
|
67
67
|
else
|
|
68
68
|
stream.value = Decoder.decode(stream_resp.response.return_value, stream.return_type, client)
|
data/lib/krpc/types.rb
CHANGED
|
@@ -37,7 +37,6 @@ module KRPC
|
|
|
37
37
|
elsif type_string.start_with? "Dictionary(" || type_string == "Dictionary" then DictionaryType.new(type_string)
|
|
38
38
|
elsif type_string.start_with? "Set(" || type_string == "Set" then SetType.new(type_string)
|
|
39
39
|
elsif type_string.start_with? "Tuple(" || type_string == "Tuple" then TupleType.new(type_string)
|
|
40
|
-
elsif type_string == "Test.TestEnum" then ValueType.new("int32")
|
|
41
40
|
else # A message type (eg. type_string = "KRPC.List" or "KRPC.Services")
|
|
42
41
|
raise(ValueError, "\"#{type_string}\" is not a valid type string") unless /^[A-Za-z0-9_\.]+$/ =~ type_string
|
|
43
42
|
if PROTOBUF_TO_MESSAGE_TYPE.has_key? type_string
|
data/lib/krpc/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: krpc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tomasz Więch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: google-protobuf
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 3.0.0.alpha.5
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 3.0.0.alpha.5
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: colorize
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,67 +53,61 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '1.6'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: hanna-nouveau
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
62
|
-
|
|
63
|
-
- !ruby/object:Gem::Version
|
|
64
|
-
version: 1.7.0
|
|
65
|
-
type: :development
|
|
61
|
+
version: '0.4'
|
|
62
|
+
type: :runtime
|
|
66
63
|
prerelease: false
|
|
67
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
68
65
|
requirements:
|
|
69
66
|
- - "~>"
|
|
70
67
|
- !ruby/object:Gem::Version
|
|
71
|
-
version: '
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: 1.7.0
|
|
68
|
+
version: '0.4'
|
|
75
69
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
70
|
+
name: bundler
|
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
|
78
72
|
requirements:
|
|
79
73
|
- - "~>"
|
|
80
74
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
75
|
+
version: '1.11'
|
|
82
76
|
type: :development
|
|
83
77
|
prerelease: false
|
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
79
|
requirements:
|
|
86
80
|
- - "~>"
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
82
|
+
version: '1.11'
|
|
89
83
|
- !ruby/object:Gem::Dependency
|
|
90
|
-
name:
|
|
84
|
+
name: pry
|
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
|
92
86
|
requirements:
|
|
93
87
|
- - "~>"
|
|
94
88
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
89
|
+
version: '0.10'
|
|
96
90
|
type: :development
|
|
97
91
|
prerelease: false
|
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
93
|
requirements:
|
|
100
94
|
- - "~>"
|
|
101
95
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
96
|
+
version: '0.10'
|
|
103
97
|
- !ruby/object:Gem::Dependency
|
|
104
|
-
name:
|
|
98
|
+
name: rspec
|
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
|
106
100
|
requirements:
|
|
107
101
|
- - "~>"
|
|
108
102
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
103
|
+
version: '3.4'
|
|
110
104
|
type: :development
|
|
111
105
|
prerelease: false
|
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
107
|
requirements:
|
|
114
108
|
- - "~>"
|
|
115
109
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '
|
|
110
|
+
version: '3.4'
|
|
117
111
|
description: kRPC-rb is a Ruby client library for kRPC, a Kerbal Space Program mod
|
|
118
112
|
that allows you to control KSP from external scripts running outside of the game.
|
|
119
113
|
email:
|
|
@@ -129,7 +123,6 @@ files:
|
|
|
129
123
|
- README.md
|
|
130
124
|
- krpc.gemspec
|
|
131
125
|
- lib/krpc.rb
|
|
132
|
-
- lib/krpc/KRPC.pb.rb
|
|
133
126
|
- lib/krpc/attributes.rb
|
|
134
127
|
- lib/krpc/client.rb
|
|
135
128
|
- lib/krpc/connection.rb
|
|
@@ -139,6 +132,8 @@ files:
|
|
|
139
132
|
- lib/krpc/encoder.rb
|
|
140
133
|
- lib/krpc/error.rb
|
|
141
134
|
- lib/krpc/gen.rb
|
|
135
|
+
- lib/krpc/krpc.pb.rb
|
|
136
|
+
- lib/krpc/protobuf_extensions.rb
|
|
142
137
|
- lib/krpc/protobuf_utils.rb
|
|
143
138
|
- lib/krpc/repl_tools.rb
|
|
144
139
|
- lib/krpc/service.rb
|
|
@@ -173,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
173
168
|
version: '0'
|
|
174
169
|
requirements: []
|
|
175
170
|
rubyforge_project:
|
|
176
|
-
rubygems_version: 2.4.
|
|
171
|
+
rubygems_version: 2.4.8
|
|
177
172
|
signing_key:
|
|
178
173
|
specification_version: 4
|
|
179
174
|
summary: Client library for kRPC
|
data/lib/krpc/KRPC.pb.rb
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
### Generated by rprotoc. DO NOT EDIT!
|
|
3
|
-
|
|
4
|
-
require 'protobuf/message/message'
|
|
5
|
-
require 'protobuf/message/enum'
|
|
6
|
-
require 'protobuf/message/service'
|
|
7
|
-
require 'protobuf/message/extend'
|
|
8
|
-
|
|
9
|
-
module KRPC
|
|
10
|
-
module PB
|
|
11
|
-
class Request < ::Protobuf::Message
|
|
12
|
-
defined_in __FILE__
|
|
13
|
-
required :string, :service, 1
|
|
14
|
-
required :string, :procedure, 2
|
|
15
|
-
repeated :Argument, :arguments, 3
|
|
16
|
-
end
|
|
17
|
-
class Argument < ::Protobuf::Message
|
|
18
|
-
defined_in __FILE__
|
|
19
|
-
required :uint32, :position, 1
|
|
20
|
-
required :bytes, :value, 2
|
|
21
|
-
end
|
|
22
|
-
class Response < ::Protobuf::Message
|
|
23
|
-
defined_in __FILE__
|
|
24
|
-
required :double, :time, 1
|
|
25
|
-
optional :string, :error, 2
|
|
26
|
-
optional :bytes, :return_value, 3
|
|
27
|
-
end
|
|
28
|
-
class StreamMessage < ::Protobuf::Message
|
|
29
|
-
defined_in __FILE__
|
|
30
|
-
repeated :StreamResponse, :responses, 1
|
|
31
|
-
end
|
|
32
|
-
class StreamResponse < ::Protobuf::Message
|
|
33
|
-
defined_in __FILE__
|
|
34
|
-
required :uint32, :id, 1
|
|
35
|
-
required :Response, :response, 2
|
|
36
|
-
end
|
|
37
|
-
class Services < ::Protobuf::Message
|
|
38
|
-
defined_in __FILE__
|
|
39
|
-
repeated :Service, :services, 1
|
|
40
|
-
end
|
|
41
|
-
class Service < ::Protobuf::Message
|
|
42
|
-
defined_in __FILE__
|
|
43
|
-
required :string, :name, 1
|
|
44
|
-
repeated :Procedure, :procedures, 2
|
|
45
|
-
repeated :Class, :classes, 3
|
|
46
|
-
repeated :Enumeration, :enumerations, 4
|
|
47
|
-
optional :string, :documentation, 5
|
|
48
|
-
end
|
|
49
|
-
class Procedure < ::Protobuf::Message
|
|
50
|
-
defined_in __FILE__
|
|
51
|
-
required :string, :name, 1
|
|
52
|
-
repeated :Parameter, :parameters, 2
|
|
53
|
-
optional :string, :return_type, 3
|
|
54
|
-
repeated :string, :attributes, 4
|
|
55
|
-
optional :string, :documentation, 5
|
|
56
|
-
end
|
|
57
|
-
class Parameter < ::Protobuf::Message
|
|
58
|
-
defined_in __FILE__
|
|
59
|
-
required :string, :name, 1
|
|
60
|
-
required :string, :type, 2
|
|
61
|
-
optional :bytes, :default_argument, 3
|
|
62
|
-
end
|
|
63
|
-
class Class < ::Protobuf::Message
|
|
64
|
-
defined_in __FILE__
|
|
65
|
-
required :string, :name, 1
|
|
66
|
-
optional :string, :documentation, 2
|
|
67
|
-
end
|
|
68
|
-
class Enumeration < ::Protobuf::Message
|
|
69
|
-
defined_in __FILE__
|
|
70
|
-
required :string, :name, 1
|
|
71
|
-
repeated :EnumerationValue, :values, 2
|
|
72
|
-
optional :string, :documentation, 3
|
|
73
|
-
end
|
|
74
|
-
class EnumerationValue < ::Protobuf::Message
|
|
75
|
-
defined_in __FILE__
|
|
76
|
-
required :string, :name, 1
|
|
77
|
-
required :int32, :value, 2
|
|
78
|
-
optional :string, :documentation, 3
|
|
79
|
-
end
|
|
80
|
-
class List < ::Protobuf::Message
|
|
81
|
-
defined_in __FILE__
|
|
82
|
-
repeated :bytes, :items, 1
|
|
83
|
-
end
|
|
84
|
-
class Dictionary < ::Protobuf::Message
|
|
85
|
-
defined_in __FILE__
|
|
86
|
-
repeated :DictionaryEntry, :entries, 1
|
|
87
|
-
end
|
|
88
|
-
class DictionaryEntry < ::Protobuf::Message
|
|
89
|
-
defined_in __FILE__
|
|
90
|
-
required :bytes, :key, 1
|
|
91
|
-
required :bytes, :value, 2
|
|
92
|
-
end
|
|
93
|
-
class Set < ::Protobuf::Message
|
|
94
|
-
defined_in __FILE__
|
|
95
|
-
repeated :bytes, :items, 1
|
|
96
|
-
end
|
|
97
|
-
class Tuple < ::Protobuf::Message
|
|
98
|
-
defined_in __FILE__
|
|
99
|
-
repeated :bytes, :items, 1
|
|
100
|
-
end
|
|
101
|
-
class Status < ::Protobuf::Message
|
|
102
|
-
defined_in __FILE__
|
|
103
|
-
required :string, :version, 1
|
|
104
|
-
required :uint64, :bytes_read, 2
|
|
105
|
-
required :uint64, :bytes_written, 3
|
|
106
|
-
required :float, :bytes_read_rate, 4
|
|
107
|
-
required :float, :bytes_written_rate, 5
|
|
108
|
-
required :uint64, :rpcs_executed, 6
|
|
109
|
-
required :float, :rpc_rate, 7
|
|
110
|
-
required :bool, :one_rpc_per_update, 8
|
|
111
|
-
required :uint32, :max_time_per_update, 9
|
|
112
|
-
required :bool, :adaptive_rate_control, 10
|
|
113
|
-
required :bool, :blocking_recv, 11
|
|
114
|
-
required :uint32, :recv_timeout, 12
|
|
115
|
-
required :float, :time_per_rpc_update, 13
|
|
116
|
-
required :float, :poll_time_per_rpc_update, 14
|
|
117
|
-
required :float, :exec_time_per_rpc_update, 15
|
|
118
|
-
required :uint32, :stream_rpcs, 16
|
|
119
|
-
required :uint64, :stream_rpcs_executed, 17
|
|
120
|
-
required :float, :stream_rpc_rate, 18
|
|
121
|
-
required :float, :time_per_stream_update, 19
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|