protobuf 3.10.5 → 3.10.7
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/.circleci/config.yml +0 -2
- data/lib/protobuf/generators/enum_generator.rb +1 -0
- data/lib/protobuf/generators/field_generator.rb +2 -0
- data/lib/protobuf/rpc/error.rb +4 -4
- data/lib/protobuf/rpc/middleware/exception_handler.rb +12 -1
- data/lib/protobuf/version.rb +1 -1
- data/spec/lib/protobuf/generators/enum_generator_spec.rb +11 -0
- data/spec/lib/protobuf/generators/field_generator_spec.rb +11 -0
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +3 -3
- data/spec/lib/protobuf/rpc/stat_spec.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f345ac51b45d74ca337c48e64d8ffb42e2447827e9fa5b483a7602ef47cc6743
|
4
|
+
data.tar.gz: d5ac75f75f3e27c75d4ad2066bd5160df7288136fd5c87323a7918034c025adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62c4eb8312892d27bbb8f0f2917a63fd40519c3d6b3e36eb8825128d086d2913fe73f0d3db6acf035086a4b628ffe7ed3d838718f3301061edbf21f5bca81edb
|
7
|
+
data.tar.gz: 6fa9ec62ef8a47feec93a6b9f6b2c1cad220b1dd2001dd4b96a5ac75c1a3f7b81a2c7ee4342244e61ba649a7d075e572991bb162ff1b85cb6f2d5cf974e63d7c
|
data/.circleci/config.yml
CHANGED
@@ -29,6 +29,7 @@ module Protobuf
|
|
29
29
|
|
30
30
|
def build_value(enum_value_descriptor)
|
31
31
|
name = enum_value_descriptor.name
|
32
|
+
name.capitalize! if ENV.key?('PB_CAPITALIZE_ENUMS')
|
32
33
|
name.upcase! if ENV.key?('PB_UPCASE_ENUMS')
|
33
34
|
number = enum_value_descriptor.number
|
34
35
|
"define :#{name}, #{number}"
|
data/lib/protobuf/rpc/error.rb
CHANGED
@@ -13,12 +13,12 @@ module Protobuf
|
|
13
13
|
super message
|
14
14
|
end
|
15
15
|
|
16
|
-
def encode
|
17
|
-
to_response.encode
|
16
|
+
def encode(args = {})
|
17
|
+
to_response(args).encode
|
18
18
|
end
|
19
19
|
|
20
|
-
def to_response
|
21
|
-
::Protobuf::Socketrpc::Response.new(:error => message, :error_reason => error_type)
|
20
|
+
def to_response(args = {})
|
21
|
+
::Protobuf::Socketrpc::Response.new({ :error => message, :error_reason => error_type }.merge(args))
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -22,7 +22,7 @@ module Protobuf
|
|
22
22
|
# Rescue exceptions, re-wrap them as generic Protobuf errors,
|
23
23
|
# and encode them
|
24
24
|
env.response = wrap_exception(exception)
|
25
|
-
env.encoded_response = env.response
|
25
|
+
env.encoded_response = wrap_and_encode_with_server(env.response, env)
|
26
26
|
env
|
27
27
|
end
|
28
28
|
|
@@ -34,6 +34,17 @@ module Protobuf
|
|
34
34
|
exception = RpcFailed.new(exception.message) unless exception.is_a?(PbError)
|
35
35
|
exception
|
36
36
|
end
|
37
|
+
|
38
|
+
# If the response is a PbError, it won't have the server merged into the response proto.
|
39
|
+
# We should add it here since exception handler is always at the bottom of the middleware
|
40
|
+
# stack. Without this, the server hostname in the client rpc log will not be set.
|
41
|
+
def wrap_and_encode_with_server(response, env)
|
42
|
+
if response.is_a?(PbError)
|
43
|
+
response.encode(:server => env.server)
|
44
|
+
else
|
45
|
+
response.encode
|
46
|
+
end
|
47
|
+
end
|
37
48
|
end
|
38
49
|
end
|
39
50
|
end
|
data/lib/protobuf/version.rb
CHANGED
@@ -71,12 +71,23 @@ end
|
|
71
71
|
|
72
72
|
context 'with PB_UPCASE_ENUMS set' do
|
73
73
|
before { allow(ENV).to receive(:key?).with('PB_UPCASE_ENUMS').and_return(true) }
|
74
|
+
before { allow(ENV).to receive(:key?).with('PB_CAPITALIZE_ENUMS').and_return(false) }
|
74
75
|
let(:values) { [{ :name => 'boom', :number => 1 }] }
|
75
76
|
|
76
77
|
it 'returns a string with the given enum name in ALL CAPS' do
|
77
78
|
expect(subject.build_value(enum.value.first)).to eq("define :BOOM, 1")
|
78
79
|
end
|
79
80
|
end
|
81
|
+
|
82
|
+
context 'with PB_CAPITALIZE_ENUMS set' do
|
83
|
+
before { allow(ENV).to receive(:key?).with('PB_UPCASE_ENUMS').and_return(false) }
|
84
|
+
before { allow(ENV).to receive(:key?).with('PB_CAPITALIZE_ENUMS').and_return(true) }
|
85
|
+
let(:values) { [{ :name => 'boom', :number => 1 }] }
|
86
|
+
|
87
|
+
it 'returns a string with the given enum name in ALL CAPS' do
|
88
|
+
expect(subject.build_value(enum.value.first)).to eq("define :Boom, 1")
|
89
|
+
end
|
90
|
+
end
|
80
91
|
end
|
81
92
|
|
82
93
|
end
|
@@ -67,10 +67,21 @@ RSpec.describe ::Protobuf::Generators::FieldGenerator do
|
|
67
67
|
let(:type_name) { '.foo.bar.Baz' }
|
68
68
|
let(:default_value) { 'quux' }
|
69
69
|
before { allow(ENV).to receive(:key?).with('PB_UPCASE_ENUMS').and_return(true) }
|
70
|
+
before { allow(ENV).to receive(:key?).with('PB_CAPITALIZE_ENUMS').and_return(false) }
|
70
71
|
|
71
72
|
specify { expect(subject).to eq " optional ::Foo::Bar::Baz, :foo_bar, 3, :default => ::Foo::Bar::Baz::QUUX\n" }
|
72
73
|
end
|
73
74
|
|
75
|
+
context 'when type is an enum with lowercase default value with PB_CAPITALIZE_ENUMS set' do
|
76
|
+
let(:type_enum) { :TYPE_ENUM }
|
77
|
+
let(:type_name) { '.foo.bar.Baz' }
|
78
|
+
let(:default_value) { 'quux' }
|
79
|
+
before { allow(ENV).to receive(:key?).with('PB_UPCASE_ENUMS').and_return(false) }
|
80
|
+
before { allow(ENV).to receive(:key?).with('PB_CAPITALIZE_ENUMS').and_return(true) }
|
81
|
+
|
82
|
+
specify { expect(subject).to eq " optional ::Foo::Bar::Baz, :foo_bar, 3, :default => ::Foo::Bar::Baz::Quux\n" }
|
83
|
+
end
|
84
|
+
|
74
85
|
context 'when the type is a string' do
|
75
86
|
let(:type_enum) { :TYPE_STRING }
|
76
87
|
let(:default_value) { "a default \"string\"" }
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Protobuf::Rpc::Middleware::ExceptionHandler do
|
4
4
|
let(:app) { proc { |env| env } }
|
5
|
-
let(:env) { Protobuf::Rpc::Env.new }
|
5
|
+
let(:env) { Protobuf::Rpc::Env.new("server" => "cooldude") }
|
6
6
|
|
7
7
|
subject { described_class.new(app) }
|
8
8
|
|
@@ -17,7 +17,7 @@ RSpec.describe Protobuf::Rpc::Middleware::ExceptionHandler do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "when exceptions occur" do
|
20
|
-
let(:encoded_error) { error.encode }
|
20
|
+
let(:encoded_error) { error.encode(:server => "cooldude") }
|
21
21
|
let(:error) { Protobuf::Rpc::MethodNotFound.new('Boom!') }
|
22
22
|
|
23
23
|
before { allow(app).to receive(:call).and_raise(error, 'Boom!') }
|
@@ -42,7 +42,7 @@ RSpec.describe Protobuf::Rpc::Middleware::ExceptionHandler do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when exception is not a Protobuf error" do
|
45
|
-
let(:encoded_error) { error.encode }
|
45
|
+
let(:encoded_error) { error.encode(:server => "cooldude") }
|
46
46
|
let(:error) { Protobuf::Rpc::RpcFailed.new('Boom!') }
|
47
47
|
|
48
48
|
before { allow(app).to receive(:call).and_raise(RuntimeError, 'Boom!') }
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.10.
|
4
|
+
version: 3.10.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BJ Neilsen
|
8
8
|
- Brandon Dewitt
|
9
9
|
- Devin Christensen
|
10
10
|
- Adam Hutchison
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-08-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -471,7 +471,7 @@ homepage: https://github.com/localshred/protobuf
|
|
471
471
|
licenses:
|
472
472
|
- MIT
|
473
473
|
metadata: {}
|
474
|
-
post_install_message:
|
474
|
+
post_install_message:
|
475
475
|
rdoc_options: []
|
476
476
|
require_paths:
|
477
477
|
- lib
|
@@ -486,8 +486,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
486
486
|
- !ruby/object:Gem::Version
|
487
487
|
version: '0'
|
488
488
|
requirements: []
|
489
|
-
rubygems_version: 3.
|
490
|
-
signing_key:
|
489
|
+
rubygems_version: 3.1.4
|
490
|
+
signing_key:
|
491
491
|
specification_version: 4
|
492
492
|
summary: Google Protocol Buffers serialization and RPC implementation for Ruby.
|
493
493
|
test_files:
|