protobuf 3.10.6 → 3.10.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea13b6353fc56a116dc91e87662ffaaac8c4b8cb27dd85be480797e7ef922d2
4
- data.tar.gz: 6f5804860b80527356f1a6cec79def05499abd4a5536038c453e7e65cd05c237
3
+ metadata.gz: 0c5dfe944c45e6d2ae26771385b8bfe7719efe4efd6576d0f95866319872342e
4
+ data.tar.gz: aa4bb74aadc1e5d2462db9df39b8b931e2382478078f4c84aa4c22d1d2145252
5
5
  SHA512:
6
- metadata.gz: a49491b32df80049107f59673008d6f8ac64977abcae332ad407c120f9f9628f4c3b47dbd5f809b8843ce477e02286da3fc1242131a8919ddac7170e2002bbf4
7
- data.tar.gz: b5352584a6c79b77ce1360fb0ce6a03c00a165cdfb8f92b96aaf61d37a3acf7a89f7bd4bd2fc8a3f1c879434b941db3e0689040edf5988cee2c05cb5bfd0a3a5
6
+ metadata.gz: 4b225ea3a368cec4e619d8b117dc8eb1e11fe913ce1563c254c8530a6b18abb6109a5c4aaace7c1fbd7f774df302fce9d182c5db166e5e013e9e8d18334d0fc6
7
+ data.tar.gz: 2450cdba292656144044d49098f9c95cc8e487cf27843ab99abf2d99c1f0478d566b65f181ac87babb05aeab2f62f5cea611d41d717e10eeeaccef59c4cf1f25
data/lib/protobuf/cli.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'active_support/core_ext/hash/keys'
2
3
  require 'active_support/inflector'
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'active_support/core_ext/module/aliasing'
2
3
  require 'protobuf/generators/file_generator'
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'active_support/deprecation'
2
3
 
3
4
  module Protobuf
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
  require 'active_support/core_ext/hash/slice'
2
3
  require 'protobuf/field/field_array'
3
4
  require 'protobuf/field/field_hash'
@@ -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}"
@@ -140,6 +140,8 @@ module Protobuf
140
140
  optionally_upcased_default =
141
141
  if ENV.key?('PB_UPCASE_ENUMS')
142
142
  verbatim_default_value.upcase
143
+ elsif ENV.key?('PB_CAPITALIZE_ENUMS')
144
+ verbatim_default_value.capitalize
143
145
  else
144
146
  verbatim_default_value
145
147
  end
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.10.6' # rubocop:disable Style/MutableConstant
2
+ VERSION = '3.10.8' # rubocop:disable Style/MutableConstant
3
3
  end
data/lib/protobuf.rb CHANGED
@@ -4,6 +4,7 @@ require 'pp'
4
4
  require 'socket'
5
5
  require 'stringio'
6
6
 
7
+ require 'active_support'
7
8
  require 'active_support/core_ext/object/blank'
8
9
  require 'active_support/core_ext/object/try'
9
10
  require 'active_support/inflector'
@@ -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\"" }
@@ -1,5 +1,6 @@
1
1
  require 'ostruct'
2
2
 
3
+ require 'active_support'
3
4
  require 'active_support/core_ext/hash/reverse_merge'
4
5
 
5
6
  require 'spec_helper'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.6
4
+ version: 3.10.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-04-27 00:00:00.000000000 Z
14
+ date: 2023-11-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -486,7 +486,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
486
486
  - !ruby/object:Gem::Version
487
487
  version: '0'
488
488
  requirements: []
489
- rubygems_version: 3.2.28
489
+ rubygems_version: 3.2.33
490
490
  signing_key:
491
491
  specification_version: 4
492
492
  summary: Google Protocol Buffers serialization and RPC implementation for Ruby.