primary_connect_proto 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +39 -0
- data/connect_proto.gemspec +1 -1
- data/lib/connect_proto/build/meta_pb.rb +39 -37
- metadata +3 -37
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/defs.c +0 -2366
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/encode_decode.c +0 -1795
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/extconf.rb +0 -21
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/map.c +0 -836
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/message.c +0 -859
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/protobuf.c +0 -136
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/protobuf.h +0 -667
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/repeated_field.c +0 -686
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/storage.c +0 -1198
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/upb.c +0 -13817
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/upb.h +0 -6777
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/ext/google/protobuf_c/wrap_memcpy.c +0 -51
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/2.3/protobuf_c.bundle +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/2.4/protobuf_c.bundle +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/2.5/protobuf_c.bundle +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/2.6/protobuf_c.bundle +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/2.7/protobuf_c.bundle +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/any_pb.rb +0 -19
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/api_pb.rb +0 -41
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/duration_pb.rb +0 -19
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/empty_pb.rb +0 -17
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/field_mask_pb.rb +0 -18
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/message_exts.rb +0 -53
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/repeated_field.rb +0 -188
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/source_context_pb.rb +0 -18
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/struct_pb.rb +0 -37
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/timestamp_pb.rb +0 -19
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/type_pb.rb +0 -91
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/well_known_types.rb +0 -230
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf/wrappers_pb.rb +0 -50
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/lib/google/protobuf.rb +0 -147
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/tests/basic.rb +0 -543
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/tests/generated_code_test.rb +0 -23
- data/vendor/bundle/ruby/2.6.0/gems/google-protobuf-4.0.0.rc.2-universal-darwin/tests/stress.rb +0 -38
- data/vendor/bundle/ruby/2.6.0/specifications/google-protobuf-4.0.0.rc.2-universal-darwin.gemspec +0 -44
@@ -1,230 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# Protocol Buffers - Google's data interchange format
|
3
|
-
# Copyright 2008 Google Inc. All rights reserved.
|
4
|
-
# https://developers.google.com/protocol-buffers/
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are
|
8
|
-
# met:
|
9
|
-
#
|
10
|
-
# * Redistributions of source code must retain the above copyright
|
11
|
-
# notice, this list of conditions and the following disclaimer.
|
12
|
-
# * Redistributions in binary form must reproduce the above
|
13
|
-
# copyright notice, this list of conditions and the following disclaimer
|
14
|
-
# in the documentation and/or other materials provided with the
|
15
|
-
# distribution.
|
16
|
-
# * Neither the name of Google Inc. nor the names of its
|
17
|
-
# contributors may be used to endorse or promote products derived from
|
18
|
-
# this software without specific prior written permission.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
|
32
|
-
require 'google/protobuf/any_pb'
|
33
|
-
require 'google/protobuf/duration_pb'
|
34
|
-
require 'google/protobuf/field_mask_pb'
|
35
|
-
require 'google/protobuf/struct_pb'
|
36
|
-
require 'google/protobuf/timestamp_pb'
|
37
|
-
|
38
|
-
module Google
|
39
|
-
module Protobuf
|
40
|
-
|
41
|
-
Any.class_eval do
|
42
|
-
def self.pack(msg, type_url_prefix='type.googleapis.com/')
|
43
|
-
any = self.new
|
44
|
-
any.pack(msg, type_url_prefix)
|
45
|
-
any
|
46
|
-
end
|
47
|
-
|
48
|
-
def pack(msg, type_url_prefix='type.googleapis.com/')
|
49
|
-
if type_url_prefix.empty? or type_url_prefix[-1] != '/' then
|
50
|
-
self.type_url = "#{type_url_prefix}/#{msg.class.descriptor.name}"
|
51
|
-
else
|
52
|
-
self.type_url = "#{type_url_prefix}#{msg.class.descriptor.name}"
|
53
|
-
end
|
54
|
-
self.value = msg.to_proto
|
55
|
-
end
|
56
|
-
|
57
|
-
def unpack(klass)
|
58
|
-
if self.is(klass) then
|
59
|
-
klass.decode(self.value)
|
60
|
-
else
|
61
|
-
nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def type_name
|
66
|
-
return self.type_url.split("/")[-1]
|
67
|
-
end
|
68
|
-
|
69
|
-
def is(klass)
|
70
|
-
return self.type_name == klass.descriptor.name
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
Timestamp.class_eval do
|
75
|
-
if RUBY_VERSION < "2.5"
|
76
|
-
def to_time
|
77
|
-
Time.at(self.to_f)
|
78
|
-
end
|
79
|
-
else
|
80
|
-
def to_time
|
81
|
-
Time.at(seconds, nanos, :nanosecond)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def from_time(time)
|
86
|
-
self.seconds = time.to_i
|
87
|
-
self.nanos = time.nsec
|
88
|
-
end
|
89
|
-
|
90
|
-
def to_i
|
91
|
-
self.seconds
|
92
|
-
end
|
93
|
-
|
94
|
-
def to_f
|
95
|
-
self.seconds + (self.nanos.quo(1_000_000_000))
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
Duration.class_eval do
|
100
|
-
def to_f
|
101
|
-
self.seconds + (self.nanos.to_f / 1_000_000_000)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class UnexpectedStructType < Google::Protobuf::Error; end
|
106
|
-
|
107
|
-
Value.class_eval do
|
108
|
-
def to_ruby(recursive = false)
|
109
|
-
case self.kind
|
110
|
-
when :struct_value
|
111
|
-
if recursive
|
112
|
-
self.struct_value.to_h
|
113
|
-
else
|
114
|
-
self.struct_value
|
115
|
-
end
|
116
|
-
when :list_value
|
117
|
-
if recursive
|
118
|
-
self.list_value.to_a
|
119
|
-
else
|
120
|
-
self.list_value
|
121
|
-
end
|
122
|
-
when :null_value
|
123
|
-
nil
|
124
|
-
when :number_value
|
125
|
-
self.number_value
|
126
|
-
when :string_value
|
127
|
-
self.string_value
|
128
|
-
when :bool_value
|
129
|
-
self.bool_value
|
130
|
-
else
|
131
|
-
raise UnexpectedStructType
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def from_ruby(value)
|
136
|
-
case value
|
137
|
-
when NilClass
|
138
|
-
self.null_value = 0
|
139
|
-
when Numeric
|
140
|
-
self.number_value = value
|
141
|
-
when String
|
142
|
-
self.string_value = value
|
143
|
-
when TrueClass
|
144
|
-
self.bool_value = true
|
145
|
-
when FalseClass
|
146
|
-
self.bool_value = false
|
147
|
-
when Struct
|
148
|
-
self.struct_value = value
|
149
|
-
when Hash
|
150
|
-
self.struct_value = Struct.from_hash(value)
|
151
|
-
when ListValue
|
152
|
-
self.list_value = value
|
153
|
-
when Array
|
154
|
-
self.list_value = ListValue.from_a(value)
|
155
|
-
else
|
156
|
-
raise UnexpectedStructType
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
Struct.class_eval do
|
162
|
-
def [](key)
|
163
|
-
self.fields[key].to_ruby
|
164
|
-
rescue NoMethodError
|
165
|
-
nil
|
166
|
-
end
|
167
|
-
|
168
|
-
def []=(key, value)
|
169
|
-
unless key.is_a?(String)
|
170
|
-
raise UnexpectedStructType, "Struct keys must be strings."
|
171
|
-
end
|
172
|
-
self.fields[key] ||= Google::Protobuf::Value.new
|
173
|
-
self.fields[key].from_ruby(value)
|
174
|
-
end
|
175
|
-
|
176
|
-
def to_h
|
177
|
-
ret = {}
|
178
|
-
self.fields.each { |key, val| ret[key] = val.to_ruby(true) }
|
179
|
-
ret
|
180
|
-
end
|
181
|
-
|
182
|
-
def self.from_hash(hash)
|
183
|
-
ret = Struct.new
|
184
|
-
hash.each { |key, val| ret[key] = val }
|
185
|
-
ret
|
186
|
-
end
|
187
|
-
|
188
|
-
def has_key?(key)
|
189
|
-
self.fields.has_key?(key)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
ListValue.class_eval do
|
194
|
-
include Enumerable
|
195
|
-
|
196
|
-
def length
|
197
|
-
self.values.length
|
198
|
-
end
|
199
|
-
|
200
|
-
def [](index)
|
201
|
-
self.values[index].to_ruby
|
202
|
-
end
|
203
|
-
|
204
|
-
def []=(index, value)
|
205
|
-
self.values[index].from_ruby(value)
|
206
|
-
end
|
207
|
-
|
208
|
-
def <<(value)
|
209
|
-
wrapper = Google::Protobuf::Value.new
|
210
|
-
wrapper.from_ruby(value)
|
211
|
-
self.values << wrapper
|
212
|
-
end
|
213
|
-
|
214
|
-
def each
|
215
|
-
self.values.each { |x| yield(x.to_ruby) }
|
216
|
-
end
|
217
|
-
|
218
|
-
def to_a
|
219
|
-
self.values.map { |x| x.to_ruby(true) }
|
220
|
-
end
|
221
|
-
|
222
|
-
def self.from_a(arr)
|
223
|
-
ret = ListValue.new
|
224
|
-
arr.each { |val| ret << val }
|
225
|
-
ret
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
230
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
-
# source: google/protobuf/wrappers.proto
|
3
|
-
|
4
|
-
require 'google/protobuf'
|
5
|
-
|
6
|
-
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
-
add_file("google/protobuf/wrappers.proto", :syntax => :proto3) do
|
8
|
-
add_message "google.protobuf.DoubleValue" do
|
9
|
-
optional :value, :double, 1
|
10
|
-
end
|
11
|
-
add_message "google.protobuf.FloatValue" do
|
12
|
-
optional :value, :float, 1
|
13
|
-
end
|
14
|
-
add_message "google.protobuf.Int64Value" do
|
15
|
-
optional :value, :int64, 1
|
16
|
-
end
|
17
|
-
add_message "google.protobuf.UInt64Value" do
|
18
|
-
optional :value, :uint64, 1
|
19
|
-
end
|
20
|
-
add_message "google.protobuf.Int32Value" do
|
21
|
-
optional :value, :int32, 1
|
22
|
-
end
|
23
|
-
add_message "google.protobuf.UInt32Value" do
|
24
|
-
optional :value, :uint32, 1
|
25
|
-
end
|
26
|
-
add_message "google.protobuf.BoolValue" do
|
27
|
-
optional :value, :bool, 1
|
28
|
-
end
|
29
|
-
add_message "google.protobuf.StringValue" do
|
30
|
-
optional :value, :string, 1
|
31
|
-
end
|
32
|
-
add_message "google.protobuf.BytesValue" do
|
33
|
-
optional :value, :bytes, 1
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
module Google
|
39
|
-
module Protobuf
|
40
|
-
DoubleValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
|
41
|
-
FloatValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
|
42
|
-
Int64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
|
43
|
-
UInt64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
|
44
|
-
Int32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
|
45
|
-
UInt32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
|
46
|
-
BoolValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
|
47
|
-
StringValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
|
48
|
-
BytesValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
|
49
|
-
end
|
50
|
-
end
|
@@ -1,147 +0,0 @@
|
|
1
|
-
# Protocol Buffers - Google's data interchange format
|
2
|
-
# Copyright 2008 Google Inc. All rights reserved.
|
3
|
-
# https://developers.google.com/protocol-buffers/
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
6
|
-
# modification, are permitted provided that the following conditions are
|
7
|
-
# met:
|
8
|
-
#
|
9
|
-
# * Redistributions of source code must retain the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer.
|
11
|
-
# * Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following disclaimer
|
13
|
-
# in the documentation and/or other materials provided with the
|
14
|
-
# distribution.
|
15
|
-
# * Neither the name of Google Inc. nor the names of its
|
16
|
-
# contributors may be used to endorse or promote products derived from
|
17
|
-
# this software without specific prior written permission.
|
18
|
-
#
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
20
|
-
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
21
|
-
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
|
-
# require mixins before we hook them into the java & c code
|
32
|
-
require 'google/protobuf/message_exts'
|
33
|
-
|
34
|
-
# We define these before requiring the platform-specific modules.
|
35
|
-
# That way the module init can grab references to these.
|
36
|
-
module Google
|
37
|
-
module Protobuf
|
38
|
-
class Error < StandardError; end
|
39
|
-
class ParseError < Error; end
|
40
|
-
class TypeError < ::TypeError; end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if RUBY_PLATFORM == "java"
|
45
|
-
require 'json'
|
46
|
-
require 'google/protobuf_java'
|
47
|
-
else
|
48
|
-
begin
|
49
|
-
require "google/#{RUBY_VERSION.sub(/\.\d+$/, '')}/protobuf_c"
|
50
|
-
rescue LoadError
|
51
|
-
require 'google/protobuf_c'
|
52
|
-
end
|
53
|
-
|
54
|
-
module Google
|
55
|
-
module Protobuf
|
56
|
-
module Internal
|
57
|
-
def self.infer_package(names)
|
58
|
-
# Package is longest common prefix ending in '.', if any.
|
59
|
-
if not names.empty?
|
60
|
-
min, max = names.minmax
|
61
|
-
last_common_dot = nil
|
62
|
-
min.size.times { |i|
|
63
|
-
if min[i] != max[i] then break end
|
64
|
-
if min[i] == ?. then last_common_dot = i end
|
65
|
-
}
|
66
|
-
if last_common_dot
|
67
|
-
return min.slice(0, last_common_dot)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
nil
|
72
|
-
end
|
73
|
-
|
74
|
-
class NestingBuilder
|
75
|
-
def initialize(msg_names, enum_names)
|
76
|
-
@to_pos = {nil=>nil}
|
77
|
-
@msg_children = Hash.new { |hash, key| hash[key] = [] }
|
78
|
-
@enum_children = Hash.new { |hash, key| hash[key] = [] }
|
79
|
-
|
80
|
-
msg_names.each_with_index { |name, idx| @to_pos[name] = idx }
|
81
|
-
enum_names.each_with_index { |name, idx| @to_pos[name] = idx }
|
82
|
-
|
83
|
-
msg_names.each { |name| @msg_children[parent(name)] << name }
|
84
|
-
enum_names.each { |name| @enum_children[parent(name)] << name }
|
85
|
-
end
|
86
|
-
|
87
|
-
def build(package)
|
88
|
-
return build_msg(package)
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
def build_msg(msg)
|
93
|
-
return {
|
94
|
-
:pos => @to_pos[msg],
|
95
|
-
:msgs => @msg_children[msg].map { |child| build_msg(child) },
|
96
|
-
:enums => @enum_children[msg].map { |child| @to_pos[child] },
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
private
|
101
|
-
def parent(name)
|
102
|
-
idx = name.rindex(?.)
|
103
|
-
if idx
|
104
|
-
return name.slice(0, idx)
|
105
|
-
else
|
106
|
-
return nil
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def self.fixup_descriptor(package, msg_names, enum_names)
|
112
|
-
if package.nil?
|
113
|
-
package = self.infer_package(msg_names + enum_names)
|
114
|
-
end
|
115
|
-
|
116
|
-
nesting = NestingBuilder.new(msg_names, enum_names).build(package)
|
117
|
-
|
118
|
-
return package, nesting
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
require 'google/protobuf/repeated_field'
|
126
|
-
|
127
|
-
module Google
|
128
|
-
module Protobuf
|
129
|
-
|
130
|
-
def self.encode(msg)
|
131
|
-
msg.to_proto
|
132
|
-
end
|
133
|
-
|
134
|
-
def self.encode_json(msg, options = {})
|
135
|
-
msg.to_json(options)
|
136
|
-
end
|
137
|
-
|
138
|
-
def self.decode(klass, proto)
|
139
|
-
klass.decode(proto)
|
140
|
-
end
|
141
|
-
|
142
|
-
def self.decode_json(klass, json, options = {})
|
143
|
-
klass.decode_json(json, options)
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
end
|