google-protobuf 3.5.0.pre-java → 3.19.1-java
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.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/lib/google/protobuf/any_pb.rb +6 -4
- data/lib/google/protobuf/api_pb.rb +27 -24
- data/lib/google/protobuf/descriptor_dsl.rb +458 -0
- data/lib/google/protobuf/descriptor_pb.rb +268 -0
- data/lib/google/protobuf/duration_pb.rb +6 -4
- data/lib/google/protobuf/empty_pb.rb +4 -2
- data/lib/google/protobuf/field_mask_pb.rb +5 -3
- data/lib/google/protobuf/message_exts.rb +2 -2
- data/lib/google/protobuf/repeated_field.rb +3 -3
- data/lib/google/protobuf/source_context_pb.rb +5 -3
- data/lib/google/protobuf/struct_pb.rb +23 -21
- data/lib/google/protobuf/timestamp_pb.rb +6 -4
- data/lib/google/protobuf/type_pb.rb +77 -74
- data/lib/google/protobuf/well_known_types.rb +25 -2
- data/lib/google/protobuf/wrappers_pb.rb +37 -35
- data/lib/google/protobuf.rb +7 -4
- data/lib/google/protobuf_java.jar +0 -0
- data/tests/basic.rb +407 -1170
- data/tests/generated_code_test.rb +6 -2
- data/tests/stress.rb +1 -1
- metadata +14 -26
@@ -39,6 +39,12 @@ module Google
|
|
39
39
|
module Protobuf
|
40
40
|
|
41
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
|
+
|
42
48
|
def pack(msg, type_url_prefix='type.googleapis.com/')
|
43
49
|
if type_url_prefix.empty? or type_url_prefix[-1] != '/' then
|
44
50
|
self.type_url = "#{type_url_prefix}/#{msg.class.descriptor.name}"
|
@@ -66,13 +72,24 @@ module Google
|
|
66
72
|
end
|
67
73
|
|
68
74
|
Timestamp.class_eval do
|
69
|
-
|
70
|
-
|
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
|
71
83
|
end
|
72
84
|
|
73
85
|
def from_time(time)
|
74
86
|
self.seconds = time.to_i
|
75
87
|
self.nanos = time.nsec
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.from_time(time)
|
92
|
+
new.from_time(time)
|
76
93
|
end
|
77
94
|
|
78
95
|
def to_i
|
@@ -149,6 +166,8 @@ module Google
|
|
149
166
|
Struct.class_eval do
|
150
167
|
def [](key)
|
151
168
|
self.fields[key].to_ruby
|
169
|
+
rescue NoMethodError
|
170
|
+
nil
|
152
171
|
end
|
153
172
|
|
154
173
|
def []=(key, value)
|
@@ -170,6 +189,10 @@ module Google
|
|
170
189
|
hash.each { |key, val| ret[key] = val }
|
171
190
|
ret
|
172
191
|
end
|
192
|
+
|
193
|
+
def has_key?(key)
|
194
|
+
self.fields.has_key?(key)
|
195
|
+
end
|
173
196
|
end
|
174
197
|
|
175
198
|
ListValue.class_eval do
|
@@ -4,45 +4,47 @@
|
|
4
4
|
require 'google/protobuf'
|
5
5
|
|
6
6
|
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
module Google
|
37
39
|
module Protobuf
|
38
|
-
DoubleValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
|
39
|
-
FloatValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
|
40
|
-
Int64Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
|
41
|
-
UInt64Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
|
42
|
-
Int32Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
|
43
|
-
UInt32Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
|
44
|
-
BoolValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
|
45
|
-
StringValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
|
46
|
-
BytesValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
|
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
|
47
49
|
end
|
48
50
|
end
|
data/lib/google/protobuf.rb
CHANGED
@@ -37,6 +37,7 @@ module Google
|
|
37
37
|
module Protobuf
|
38
38
|
class Error < StandardError; end
|
39
39
|
class ParseError < Error; end
|
40
|
+
class TypeError < ::TypeError; end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -49,8 +50,10 @@ else
|
|
49
50
|
rescue LoadError
|
50
51
|
require 'google/protobuf_c'
|
51
52
|
end
|
53
|
+
|
52
54
|
end
|
53
55
|
|
56
|
+
require 'google/protobuf/descriptor_dsl'
|
54
57
|
require 'google/protobuf/repeated_field'
|
55
58
|
|
56
59
|
module Google
|
@@ -60,16 +63,16 @@ module Google
|
|
60
63
|
msg.to_proto
|
61
64
|
end
|
62
65
|
|
63
|
-
def self.encode_json(msg)
|
64
|
-
msg.to_json
|
66
|
+
def self.encode_json(msg, options = {})
|
67
|
+
msg.to_json(options)
|
65
68
|
end
|
66
69
|
|
67
70
|
def self.decode(klass, proto)
|
68
71
|
klass.decode(proto)
|
69
72
|
end
|
70
73
|
|
71
|
-
def self.decode_json(klass, json)
|
72
|
-
klass.decode_json(json)
|
74
|
+
def self.decode_json(klass, json, options = {})
|
75
|
+
klass.decode_json(json, options)
|
73
76
|
end
|
74
77
|
|
75
78
|
end
|
Binary file
|