krpc 0.4.0.beta2 → 0.4.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/krpc.gemspec +6 -6
- data/lib/krpc.rb +2 -2
- data/lib/krpc/client.rb +35 -27
- data/lib/krpc/connection.rb +17 -17
- data/lib/krpc/core_extensions.rb +3 -3
- data/lib/krpc/decoder.rb +4 -4
- data/lib/krpc/doc.rb +30 -29
- data/lib/krpc/encoder.rb +3 -3
- data/lib/krpc/error.rb +3 -8
- data/lib/krpc/gen.rb +16 -16
- data/lib/krpc/krpc.pb.rb +18 -4
- data/lib/krpc/protobuf_utils.rb +15 -14
- data/lib/krpc/service.rb +19 -11
- data/lib/krpc/streaming.rb +18 -18
- data/lib/krpc/types.rb +19 -19
- data/lib/krpc/version.rb +2 -1
- metadata +15 -15
data/lib/krpc/types.rb
CHANGED
@@ -23,23 +23,23 @@ module KRPC
|
|
23
23
|
STATUS: PB::Status,
|
24
24
|
SERVICES: PB::Services
|
25
25
|
}
|
26
|
-
|
27
|
-
|
26
|
+
|
27
|
+
|
28
28
|
class TypeStore
|
29
29
|
@cache = {}
|
30
30
|
class << self
|
31
|
-
|
31
|
+
|
32
32
|
def [](protobuf_type)
|
33
33
|
@cache[protobuf_type.to_proto.hash] ||= PROTOBUF_TYPE_CODE_TO_TYPE_TYPE[protobuf_type.code].new(protobuf_type)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def coerce_to(value, type)
|
37
37
|
return value if type.is_a?(EnumType) && value.class == Symbol # Enum handling
|
38
38
|
return value if value.is_a?(type.ruby_type)
|
39
39
|
# A NilClass can be coerced to a ClassType
|
40
40
|
return nil if type.is_a?(ClassType) && value.nil?
|
41
41
|
# Handle service' class instance
|
42
|
-
if type.is_a?(ClassType) && value.is_a?(Gen::ClassBase) &&
|
42
|
+
if type.is_a?(ClassType) && value.is_a?(Gen::ClassBase) &&
|
43
43
|
type.ruby_type == value.class
|
44
44
|
return value
|
45
45
|
end
|
@@ -69,11 +69,11 @@ module KRPC
|
|
69
69
|
end
|
70
70
|
raise(ValueError, "Failed to coerce value #{value.to_s} of type #{value.class} to type #{type}")
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
|
77
77
|
class TypeBase
|
78
78
|
attr_reader :protobuf_type, :ruby_type
|
79
79
|
def initialize(protobuf_type, ruby_type)
|
@@ -81,13 +81,13 @@ module KRPC
|
|
81
81
|
@ruby_type = ruby_type
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
class ValueType < TypeBase
|
86
86
|
def initialize(pb_type)
|
87
87
|
super(pb_type, PROTOBUF_TO_RUBY_VALUE_TYPES[pb_type.code] || raise(ValueError, "#{pb_type.code} is not a valid type code for a value type"))
|
88
88
|
end
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
class ClassType < TypeBase
|
92
92
|
attr_reader :service_name, :class_name
|
93
93
|
def initialize(pb_type)
|
@@ -95,7 +95,7 @@ module KRPC
|
|
95
95
|
super(pb_type, Gen.generate_class(service_name, class_name))
|
96
96
|
end
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
class EnumType < TypeBase
|
100
100
|
attr_reader :service_name, :enum_name
|
101
101
|
def initialize(pb_type)
|
@@ -103,12 +103,12 @@ module KRPC
|
|
103
103
|
# Sets ruby_type to nil, set_values must be called to set the ruby_type
|
104
104
|
super(pb_type, nil)
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
def set_values(values)
|
108
108
|
@ruby_type = Gen.generate_enum(service_name, enum_name, values)
|
109
109
|
end
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
class ListType < TypeBase
|
113
113
|
attr_reader :value_type
|
114
114
|
def initialize(pb_type)
|
@@ -116,7 +116,7 @@ module KRPC
|
|
116
116
|
super(pb_type, Array)
|
117
117
|
end
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
class SetType < TypeBase
|
121
121
|
attr_reader :value_type
|
122
122
|
def initialize(pb_type)
|
@@ -124,7 +124,7 @@ module KRPC
|
|
124
124
|
super(pb_type, Set)
|
125
125
|
end
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
class TupleType < TypeBase
|
129
129
|
attr_reader :value_types
|
130
130
|
def initialize(pb_type)
|
@@ -132,7 +132,7 @@ module KRPC
|
|
132
132
|
super(pb_type, Array)
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
class DictionaryType < TypeBase
|
137
137
|
attr_reader :key_type, :value_type
|
138
138
|
def initialize(pb_type)
|
@@ -140,13 +140,13 @@ module KRPC
|
|
140
140
|
super(pb_type, Hash)
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
class MessageType < TypeBase
|
145
145
|
def initialize(pb_type)
|
146
146
|
super(pb_type, PROTOBUF_TO_RUBY_MESSAGE_TYPES[pb_type.code] || raise(ValueError, "\"#{pb_type.code}\" is not a valid type code for a message type"))
|
147
147
|
end
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
PROTOBUF_TYPE_CODE_TO_TYPE_TYPE =
|
151
151
|
PROTOBUF_TO_RUBY_VALUE_TYPES.keys.inject({}) {|a,e| a[e] = ValueType; a }.merge(
|
152
152
|
PROTOBUF_TO_RUBY_MESSAGE_TYPES.keys.inject({}) {|a,e| a[e] = MessageType; a }).merge(
|
@@ -154,6 +154,6 @@ module KRPC
|
|
154
154
|
LIST: ListType, SET: SetType, TUPLE: TupleType, DICTIONARY: DictionaryType
|
155
155
|
)
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
TypeStore = Types::TypeStore
|
159
159
|
end
|
data/lib/krpc/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module KRPC
|
2
2
|
module Version
|
3
|
+
# Dear krpc-rb developer: Before bumping version below, please ensure that protobuf schema is up to date.
|
3
4
|
MAJOR = 0
|
4
5
|
MINOR = 4
|
5
6
|
PATCH = 0
|
6
|
-
LABEL = '
|
7
|
+
LABEL = 'beta3'
|
7
8
|
end
|
8
9
|
|
9
10
|
VERSION = ([Version::MAJOR, Version::MINOR, Version::PATCH, Version::LABEL].compact * '.').freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: krpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.0.
|
4
|
+
version: 0.4.0.beta3
|
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: 2017-
|
11
|
+
date: 2017-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.4'
|
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: '3.
|
26
|
+
version: '3.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: colorize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,70 +44,70 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.8'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.15'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.15'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.11'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.11'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.6'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '12.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '12.1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: hanna-nouveau
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: 1.3.1
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.6.8
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Client library for kRPC
|